BB802A RPGLE
The BB802A RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W) with open order header data from the BBORDH 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 BB802A RPG Program¶
The program reads records from the BBORDH file, processes them based on a level break (L1), and updates or adds corresponding records to the BB802W work file. The steps are straightforward, focusing on data transfer with minimal 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:boco(company),bocust(customer),bordno(order number), andk$invn(invoice number, initialized to zeros). - Defines
k$invnas a field likeboinvn(invoice number fromBBORDH) and sets it to zeros.
- Receives the input parameter:
-
Main Processing Loop:
- Purpose: Reads
BBORDHrecords and processes them based on a level break. -
Actions:
- Reads
BBORDHrecords sequentially, with level break indicators (L1) set on fieldsboco,bocust,bordno, andboinvn. - 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 onBBORDHdata. -
Actions:
- Uses the
klwrkkey list (boco,bocust,bordno,k$invn) to check if a matching record exists inBB802WusingSETLL(sets*in99if no match). - If no matching record exists (
*in99 = *off), chains toBB802Wto verify existence (*in99 = *onif not found). - If the record does not exist (
*in99 = *on): - Clears the
BB802Wrecord format (bb802wpf). - Maps fields from
BBORDHtoBB802W:w1co←boco(company)w1cust←bocust(customer)w1ord#←bordno(order number)w1inv#←k$invn(invoice number, zeros)w1ship←boship(ship-to code)w1pord←bopord(purchase order)w1slmn←boslmn(salesman)w1crid←bortg1(carrier ID)w1carn←bocar(carrier name)w1sdat←borqd8(request date)w1frcd←bofrcd(freight code)w1sfrt←bosfrt(ship freight)w1cafr←bocafr(carrier freight)w1cacd←bocacd(carrier code)w1oori←'O'(order origin indicator)- Additional fields (per jk01):
w1tkby←botkby(taken by)w1rush←borush(rush order flag)w1gpby←bogpby(group by)w1racd←boracd(reason code)w1mulo←bomulo(multi-order flag)w1mlcd←bomlcd(multi-code)w1tolo←botolo(total order)w1loda←boloda(load date)w1lovo←bolovo(load volume)
- Writes the new record to
BB802W(write bb802wpf). - If a matching record exists (
*in99 = *off), no update is performed (implicitly skips to the next record).
- Uses the
-
Program Termination:
- Purpose: Completes processing and exits.
- Actions:
- Ends the program after processing all
BBORDHrecords, closing files implicitly (asBBORDHandBB802Ware defined withipandufrespectively).
- Ends the program after processing all
Business Rules¶
- Work File Population:
- The program adds records to
BB802WfromBBORDHfor open order headers, using a fixed invoice number of zeros (k$invn = *zeros) to align with the query structure set by BB802C. -
Only adds new records if no matching record exists in
BB802W(based onboco,bocust,bordno,k$invn). -
Level Break Processing:
- Processes
BBORDHrecords on a level break (L1) defined byboco(company),bocust(customer),bordno(order number), andboinvn(invoice number). -
Ensures records are processed only when the level break occurs, optimizing performance.
-
Field Mapping:
- Maps specific fields from
BBORDHtoBB802W, preserving key order and inquiry data (e.g., customer, order, ship-to, salesman, freight details). -
Includes additional fields added in revision jk01 to support enhanced inquiry capabilities (e.g., rush order, load date, total order).
-
File Group Handling:
-
Relies on
p$fgrp('G' or 'Z') set by BB802C to access the correct library (GBBORDHorZBBORDH) via overrides in the CLP. -
Data Integrity:
- Uses
SETLLandCHAINto ensure no duplicate records are written toBB802W. -
Clears the record format before writing to prevent residual data.
-
Revision-Specific Rules:
- jk01: Added fields to
BB802W(w1tkby,w1rush,w1gpby,w1racd,w1mulo,w1mlcd,w1tolo,w1loda,w1lovo) to capture additional order header data (e.g., taken by, rush flag, load volume).
Tables Used¶
The program accesses the following database files:
- BBORDH: Open order header file (input primary,
ip), contains order header data (e.g.,boco,bocust,bordno,boinvn,boship, etc.). - BB802W: Work file (update file,
uf), stores processed inquiry data inQTEMPwith fields likew1co,w1cust,w1ord#,w1inv#, 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 (SETLLandCHAINoperations). - Field Prefixes: Uses
w1prefix forBB802Wfields, aligning with the work file structure. - Key List: The
klwrkkey list ensures unique identification of records inBB802Wusingboco,bocust,bordno, andk$invn. - Context: Called by BB802C in
ORHmode (open order header processing), whereBBORDHis 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.
This program is a critical backend component of the inquiry system, ensuring that open order header data is efficiently transferred to the BB802W work file for further processing by the BB802 inquiry interface.