BB802E RPGLE
The BB802E RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W
) with sales history header data from the SA5SHP
file. 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 BB802E RPG Program¶
The program reads records from the SA5SHP
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:shco
(company),shcust
(customer),shord
(order number), andshinv
(invoice number).
- Receives the input parameter:
-
Main Processing Loop:
- Purpose: Reads
SA5SHP
records and processes them based on a level break. -
Actions:
- Reads
SA5SHP
records sequentially, with level break indicators (L1
) set on fieldsshco
,shcust
,shord
, andshinv
. - 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 onSA5SHP
data. -
Actions:
- Uses the
klwrk
key list (shco
,shcust
,shord
,shinv
) 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
SA5SHP
toBB802W
:w1co
←shco
(company)w1cust
←shcust
(customer)w1ord#
←shord
(order number)w1inv#
←shinv
(invoice number)w1ship
←shship
(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)w1oori
←'I'
(invoice origin indicator)- Additional fields:
w1orpr
←saorpr
(order process, added by JK01)w1tkby
←shtkby
(taken by, added by JK02)w1rush
←sarush
(rush order flag, added by JK02)w1gpby
←shgpby
(group by, added by JK02)w1racd
←shracd
(reason code, added by JK02)w1mulo
←shmulo
(multi-order flag, added by JK02)w1mlcd
←shmlcd
(multi-code, added by JK02)w1tolo
←shtolo
(total order, added by JK02)w1loda
←shloda
(load date, added by JK02)w1lovo
←shlovo
(load volume, added by JK02)w1indt
←shimdy
(invoice date, added by JK02)w1inva
←shitot
(invoice amount, added by JK02)w1fccd
←shfccd
(freight charge code, added by JK02)
- 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
SA5SHP
records, closing files implicitly (asSA5SHP
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
fromSA5SHP
for sales history headers, using the invoice number (shinv
) 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
SA5SHP
records on a level break (L1
) defined byshco
(company),shcust
(customer),shord
(order number), andshinv
(invoice number). -
Ensures records are processed only when the level break occurs, optimizing performance.
-
Field Mapping:
- Maps fields from
SA5SHP
toBB802W
, including key inquiry data (e.g., customer, order, invoice, ship-to, salesman, freight details). -
Includes additional fields added in revisions JK01 (
w1orpr
) and JK02 (w1tkby
,w1rush
,w1gpby
, etc.) to support enhanced inquiry capabilities (e.g., invoice date, invoice amount, freight charge code). -
File Group Handling:
-
Relies on
p$fgrp
('G' or 'Z') set by BB802C to access the correct library (GSA5SHP
orZSA5SHP
) 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
w1orpr
(order process) toBB802W
to capture order 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:
- SA5SHP: Sales history header file (input primary,
ip
), contains sales header data (e.g.,shco
,shcust
,shord
,shinv
,shship
, etc.). - BB802W: Work file (update file,
uf
), stores processed inquiry data inQTEMP
with fields likew1co
,w1cust
,w1ord#
,w1inv#
,w1orpr
, 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
usingshco
,shcust
,shord
, andshinv
. - Context: Called by BB802C in
SAH
mode (sales history header processing), whereSA5SHP
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: Unlike similar programs (e.g., BB802A, BB802B), it updates existing records with
w1oori = 'B'
to indicate combined data, reflecting the integration of sales history with other inquiry data.
This program is a critical backend component of the inquiry system, ensuring that sales history header data is efficiently transferred to the BB802W
work file for further processing by the BB802 inquiry interface.