BB802B RPGLE
The BB802B RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W) with open order detail data from the BB802BQF file, which is a logical file joining BBORDD (order details) and BBORDH (order 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 BB802B RPG Program¶
The program reads records from the BB802BQF file, processes them based on a level break (L1), and updates or adds corresponding records to the BB802W work file. The steps are focused 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:bdco(company),bocust(customer),bdordn(order number), andboinvn(invoice number).
- Receives the input parameter:
-
Main Processing Loop:
- Purpose: Reads
BB802BQFrecords and processes them based on a level break. -
Actions:
- Reads
BB802BQFrecords sequentially, with level break indicators (L1) set on fieldsbdco,bocust,bdordn, 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 onBB802BQFdata. -
Actions:
- Uses the
klwrkkey list (bdco,bocust,bdordn,boinvn) 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
BB802BQFtoBB802W:w1co←bdco(company)w1cust←bocust(customer)w1ord#←bdordn(order number)w1inv#←boinvn(invoice number)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)w1loc←bdloc(location)w1prod←bdprod(product)w1cntr←bdcntr(container)w1qty←bdqty(quantity, added by jk01)w1um←bdum(unit of measure, added by jk01)w1oori←'O'(order origin indicator)- Additional fields (per jk02):
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
BB802BQFrecords, closing files implicitly (asBB802BQFandBB802Ware defined withipandufrespectively).
- Ends the program after processing all
Business Rules¶
- Work File Population:
- The program adds records to
BB802WfromBB802BQF(joiningBBORDDandBBORDH) for open order details, preserving the invoice number (boinvn) from the header. -
Only adds new records if no matching record exists in
BB802W(based onbdco,bocust,bdordn,boinvn). -
Level Break Processing:
- Processes
BB802BQFrecords on a level break (L1) defined bybdco(company),bocust(customer),bdordn(order number), andboinvn(invoice number). -
Ensures records are processed only when the level break occurs, optimizing performance.
-
Field Mapping:
- Maps fields from
BB802BQFtoBB802W, including both header (BBORDH) and detail (BBORDD) data (e.g., customer, order, ship-to, product, quantity). -
Includes additional fields added in revisions jk01 (quantity, unit of measure) and jk02 (taken by, rush flag, load volume, etc.) to support enhanced inquiry capabilities.
-
File Group Handling:
-
Relies on
p$fgrp('G' or 'Z') set by BB802C to access the correct library (GBBORDD,GBBORDHorZBBORDD,ZBBORDH) 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
w1qty(quantity) andw1um(unit of measure) toBB802Wto include order detail quantities. - jk02: 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:
- BB802BQF: Logical file (input primary,
ip), joinsBBORDD(order details) andBBORDH(order headers), containing fields likebdco,bocust,bdordn,boinvn,bdloc,bdprod, etc. - BB802W: Work file (update file,
uf), stores processed inquiry data inQTEMPwith 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
*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 inBB802Wusingbdco,bocust,bdordn, andboinvn. - Context: Called by BB802C in
ORDmode (open order detail processing), whereBB802BQFis 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 detail data is efficiently transferred to the BB802W work file for further processing by the BB802 inquiry interface.