BB802F RPGLE
The BB802F RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W
) with sales history detail data from the BB802FQF
file, which is a logical file joining SA5FILD
(sales history details) and SA5SHP
(sales history headers). It is called by the BB802C CLP program, which sets up the query environment and file overrides. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BB802F RPG Program¶
The program reads records from the BB802FQF
file, processes them based on a level break (L1), and updates or adds corresponding records to the BB802W
work file. The steps focus on data transfer with no user interaction. Here’s a breakdown of the key process steps:
- Initialization (
*inzsr
Subroutine): - Purpose: Sets up the program environment and initializes variables.
-
Actions:
- Receives the input parameter:
p$fgrp
(1 character, file group: 'G' or 'Z'). - Defines a key list (
klwrk
) for accessing the work fileBB802W
, using fields:saco
(company),sacust
(customer),saord
(order number), andsainvn
(invoice number).
- Receives the input parameter:
-
Main Processing Loop:
- Purpose: Reads
BB802FQF
records and processes them based on a level break. -
Actions:
- Reads
BB802FQF
records sequentially, with level break indicators (L1
) set on fieldssaco
,sacust
,saord
, andsainvn
. - When the level break indicator
*inl1
is on, executes theupdwrkf
subroutine to process the record.
- Reads
-
Update Work File (
updwrkf
Subroutine): - Purpose: Adds or updates records in the
BB802W
work file based onBB802FQF
data. -
Actions:
- Uses the
klwrk
key list (saco
,sacust
,saord
,sainvn
) to check if a matching record exists inBB802W
usingCHAIN
(sets*in99
if no match). - If no matching record exists (
*in99 = *on
): - Clears the
BB802W
record format (bb802wpf
). - Maps fields from
BB802FQF
toBB802W
:w1co
←saco
(company)w1cust
←sacust
(customer)w1ord#
←saord
(order number)w1inv#
←sainvn
(invoice number)w1ship
←saship
(ship-to code)w1pord
←shpord
(purchase order)w1slmn
←shslmn
(salesman)w1crid
←shrtg1
(carrier ID)w1carn
←shcarn
(carrier name)w1sdat
←shsmd8
(ship date)w1frcd
←shfrcd
(freight code)w1sfrt
←shsfrt
(ship freight)w1cafr
←shcafr
(carrier freight)w1cacd
←shcacd
(carrier code)w1trk#
←shtrk#
(tracking number)w1loc
←saloc
(location)w1prod
←saprod
(product)w1cntr
←sacntr
(container)w1qty
←sactqt
(quantity, added by jk01)w1um
←saum
(unit of measure, added by jk01)w1orpr
←saorpr
(order process, added by jk01)w1oori
←'I'
(invoice origin indicator)- Additional fields (per jk02):
w1tkby
←shtkby
(taken by)w1rush
←sarush
(rush order flag)w1gpby
←shgpby
(group by)w1racd
←shracd
(reason code)w1mulo
←shmulo
(multi-order flag)w1mlcd
←shmlcd
(multi-code)w1tolo
←shtolo
(total order)w1loda
←shloda
(load date)w1lovo
←shlovo
(load volume)w1indt
←shimdy
(invoice date)w1inva
←shitot
(invoice amount)w1fccd
←shfccd
(freight charge code)
- Writes the new record to
BB802W
(write bb802wpf
). - If a matching record exists (
*in99 = *off
): - Updates the existing record with
w1oori = 'B'
(indicating both order and invoice data). - Updates the
BB802W
record (update bb802wpf
).
- Uses the
-
Program Termination:
- Purpose: Completes processing and exits.
- Actions:
- Ends the program after processing all
BB802FQF
records, closing files implicitly (asBB802FQF
andBB802W
are defined withip
anduf
respectively).
- Ends the program after processing all
Business Rules¶
- Work File Population:
- The program adds or updates records in
BB802W
fromBB802FQF
(joiningSA5FILD
andSA5SHP
) for sales history details, using the invoice number (sainvn
) as a key component. - If no matching record exists in
BB802W
, a new record is created withw1oori = 'I'
(indicating invoice origin). -
If a matching record exists, it is updated with
w1oori = 'B'
to indicate combined order and invoice data. -
Level Break Processing:
- Processes
BB802FQF
records on a level break (L1
) defined bysaco
(company),sacust
(customer),saord
(order number), andsainvn
(invoice number). -
Ensures records are processed only when the level break occurs, optimizing performance.
-
Field Mapping:
- Maps fields from
BB802FQF
, combining detail data (SA5FILD
: e.g.,saloc
,saprod
,sactqt
) and header data (SA5SHP
: e.g.,shpord
,shslmn
,shsmd8
). -
Includes additional fields added in revisions jk01 (
w1qty
,w1um
,w1orpr
) and jk02 (w1tkby
,w1rush
,w1gpby
, etc.) to support enhanced inquiry capabilities (e.g., quantity, invoice date, freight charge code). -
File Group Handling:
-
Relies on
p$fgrp
('G' or 'Z') set by BB802C to access the correct library (GSA5FILD
,GSA5SHP
orZSA5FILD
,ZSA5SHP
) via overrides in the CLP. -
Data Integrity:
- Uses
CHAIN
to check for existing records inBB802W
, ensuring no duplicates are created unnecessarily. - Clears the record format before writing new records to prevent residual data.
-
Updates existing records to reflect combined data (
w1oori = 'B'
) when applicable. -
Revision-Specific Rules:
- jk01: Added
w1qty
(quantity),w1um
(unit of measure), andw1orpr
(order process) toBB802W
to include sales detail quantities and processing status. - jk02: Added fields to
BB802W
(w1tkby
,w1rush
,w1gpby
,w1racd
,w1mulo
,w1mlcd
,w1tolo
,w1loda
,w1lovo
,w1indt
,w1inva
,w1fccd
) to capture additional sales history data (e.g., taken by, invoice date, invoice amount).
Tables Used¶
The program accesses the following database files:
- BB802FQF: Logical file (input primary,
ip
), joinsSA5FILD
(sales history details) andSA5SHP
(sales history headers), containing fields likesaco
,sacust
,saord
,sainvn
,saloc
,saprod
, etc. - BB802W: Work file (update file,
uf
), stores processed inquiry data inQTEMP
with fields likew1co
,w1cust
,w1ord#
,w1inv#
,w1qty
, etc.
External Programs Called¶
The program does not call any external programs. It operates independently, relying on file I/O operations and the environment set up by BB802C (e.g., file overrides and open query).
Additional Notes¶
- Indicator Usage: Uses
*inl1
for level break processing and*in99
for file access control (CHAIN
operation). - Field Prefixes: Uses
w1
prefix forBB802W
fields, aligning with the work file structure. - Key List: The
klwrk
key list ensures unique identification of records inBB802W
usingsaco
,sacust
,saord
, andsainvn
. - Context: Called by BB802C in
SAD
mode (sales history detail processing, whenP$PMOV ≠ 'Y'
), whereBB802FQF
is queried with a selection string (QRYSLT
) to filter records. - Efficiency: The program uses a simple, non-interactive approach, focusing on data transfer to the work file, with no user interface or message handling.
- Update Logic: Like BB802E, it updates existing records with
w1oori = 'B'
to indicate combined data, reflecting integration with other inquiry data.
This program is a critical backend component of the inquiry system, ensuring that sales history detail data is efficiently transferred to the BB802W
work file for further processing by the BB802 inquiry interface.