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 (
*inzsrSubroutine): - 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
SA5SHPrecords and processes them based on a level break. -
Actions:
- Reads
SA5SHPrecords sequentially, with level break indicators (L1) set on fieldsshco,shcust,shord, andshinv. - When the level break indicator
*inl1is on, executes theupdwrkfsubroutine to process the record.
- Reads
-
Update Work File (
updwrkfSubroutine): - Purpose: Adds or updates records in the
BB802Wwork file based onSA5SHPdata. -
Actions:
- Uses the
klwrkkey list (shco,shcust,shord,shinv) to check if a matching record exists inBB802WusingCHAIN(sets*in99if no match). - If no matching record exists (
*in99 = *on): - Clears the
BB802Wrecord format (bb802wpf). - Maps fields from
SA5SHPtoBB802W: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
BB802Wrecord (update bb802wpf).
- Uses the
-
Program Termination:
- Purpose: Completes processing and exits.
- Actions:
- Ends the program after processing all
SA5SHPrecords, closing files implicitly (asSA5SHPandBB802Ware defined withipandufrespectively).
- Ends the program after processing all
Business Rules¶
- Work File Population:
- The program adds or updates records in
BB802WfromSA5SHPfor 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
SA5SHPrecords 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
SA5SHPtoBB802W, 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 (GSA5SHPorZSA5SHP) via overrides in the CLP. -
Data Integrity:
- Uses
CHAINto 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) toBB802Wto 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 inQTEMPwith 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
*inl1for level break processing and*in99for file access control (CHAINoperation). - Field Prefixes: Uses
w1prefix forBB802Wfields, aligning with the work file structure. - Key List: The
klwrkkey list ensures unique identification of records inBB802Wusingshco,shcust,shord, andshinv. - Context: Called by BB802C in
SAHmode (sales history header processing), whereSA5SHPis 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.