BB7051 RPG36
The provided document, BB7051.rpg36.txt, is an RPG program for the IBM System/36, called by the OCL program BB705.ocl36.txt as part of the workflow to generate a Pending Orders Report. This program builds a work file (BB705O) from the order data file (BBORDR) by filtering and enhancing records with location, request date, and carrier code information. Below, I’ll explain the process steps, business rules, tables used, and external programs called, integrating context from the related programs (BB705P.ocl36.txt, BB705P.rpg36.txt, BB705.ocl36.txt, and BB705.rpg36.txt).
Process Steps of the RPG Program¶
The BB7051 RPG program processes records from BBORDR, filters out deleted records, and writes selected records to BB705O with additional fields for sorting and reporting. Here’s a step-by-step breakdown:
- File and Data Definitions:
- Input File:
BBORDR(512 bytes, primary input, indexed): Contains order data with header, detail, and miscellaneous/remark records.
- Output File:
BB705O(532 bytes, output): Work file to store processed records with added fields for location, request date, and carrier code.
- Record Formats (from
BBORDR):- Header Record (
NS 01): BODEL(position 1): Delete flag ('D' for deleted).BOCO(positions 2-3): Company number (level breakL2).BORDNO(positions 4-9): Order number (level breakL1).BOCACD(positions 84-85): Carrier code (e.g., CC, CT, RC).BORQD8(positions 299-306): Request date in 8-digit format (CCYYMMDD).HREC1(positions 1-256),HREC2(positions 257-512): Entire record split for output.- Detail Record (
NS 02): BDDEL(position 1): Delete flag.BOCO(positions 2-3): Company number.BORDNO(positions 4-9): Order number.BDLOC(positions 22-24): Location code.DREC1(positions 1-256),DREC2(positions 257-512): Entire record split.- Miscellaneous/Remark Record (
NS 03): BMDEL(position 1): Delete flag.BOCO(positions 2-3): Company number.BORDNO(positions 4-9): Order number.MREC1(positions 1-256),MREC2(positions 257-512): Entire record split.
- Header Record (
-
Variables:
DCNT(3 digits): Counter for detail records per order.SVLOC(3 characters): Saved location code from the first detail record.SVRQD8(8 digits): Saved request date from the header.SVCACD(2 characters): Saved carrier code from the header.
-
Main Processing (RPG Cycle):
- The program uses the RPG cycle to process
BBORDRrecords sequentially, with level breaks on company (L2,BOCO) and order (L1,BORDNO). - Level Break (
L1, Order Change) (lines 0043-0048):- Resets
DCNTto 0 (detail counter). - Clears
SVLOCto blanks. - Resets
SVRQD8to 0 (request date). - Clears
SVCACDto blanks (carrier code).
- Resets
- Header Record Processing (
NS 01) (lines 0050-0053):- Stores
BORQD8(request date) inSVRQD8. - Stores
BOCACD(carrier code) inSVCACD.
- Stores
- Detail Record Processing (
NS 02) (lines 0055-0062):- Increments
DCNT(detail counter). - Stores
BDLOC(location) inSVLOC. - If
DCNT = 1(first detail record for the order), writes the header record toBB705Ousing theHOUTexception output (includesHREC1,HREC2,SVLOC,SVRQD8,SVCACD). - Writes the detail record to
BB705Ousing theDOUTexception output.
- Increments
-
Miscellaneous/Remark Record Processing (
NS 03) (lines 0064-0066):- Writes the remark record to
BB705Ousing theMOUTexception output.
- Writes the remark record to
-
Output to BB705O:
- HOUT (Header Output) (lines 0069-0074):
- Writes
HREC1(1-256),HREC2(257-512),SVLOC(513-515),SVRQD8(516-523),SVCACD(524-525).
- Writes
- DOUT (Detail Output) (lines 0076-0081):
- Writes
DREC1(1-256),DREC2(257-512),SVLOC(513-515),SVRQD8(516-523),SVCACD(524-525).
- Writes
- MOUT (Remark Output) (lines 0083-0088):
- Writes
MREC1(1-256),MREC2(257-512),SVLOC(513-515),SVRQD8(516-523),SVCACD(524-525).
- Writes
-
The output file
BB705OextendsBBORDR’s 512-byte records to 532 bytes by addingSVLOC,SVRQD8, andSVCACDfor sorting by#GSORTinBB705.ocl36.txt. -
Program Termination:
- The program ends when all
BBORDRrecords are processed, producingBB705Ofor subsequent sorting and reporting.
Business Rules¶
The program enforces the following business rules for building the work file:
- Record Filtering:
-
Records with delete flags (
BODEL,BDDEL,BMDEL = 'D') are not explicitly filtered inBB7051but are handled by#GSORTinBB705.ocl36.txt(conditionI C 1 1NECD). -
Data Enhancement:
- For each order, the first detail record’s location (
BDLOC) is saved asSVLOCand written to all records (header, detail, remark) in positions 513-515. - The header’s request date (
BORQD8) is saved asSVRQD8and written to positions 516-523. - The header’s carrier code (
BOCACD) is saved asSVCACDand written to positions 524-525. -
This ensures all records in
BB705Ohave consistent sort fields for#GSORT. -
Order-Level Processing:
- Header records are written only once per order, triggered by the first detail record (
DCNT = 1). -
Detail and remark records are written as they are read, preserving the order structure.
-
Record Integrity:
- The entire 512-byte record (
HREC1,HREC2,DREC1,DREC2,MREC1,MREC2) is copied toBB705O, with additional fields appended. - The program assumes
BBORDRis pre-filtered by company (BOCO) and date range (BORQD8) based on parameters fromBB705P.rpg36.txt.
Tables Used¶
No explicit RPG tables (e.g., TABxxx or arrays like COM in BB705P.rpg36.txt or AST/HYP in BB705.rpg36.txt) are defined. The following files function as data sources (relational tables):
- BBORDR:
- Input file containing order header (
NS 01), detail (NS 02), and miscellaneous/remark (NS 03) records. -
Key fields:
BOCO(company),BORDNO(order),BDLOC(location),BORQD8(request date),BOCACD(carrier code). -
BB705O:
- Output work file, extended to 532 bytes with
SVLOC(513-515),SVRQD8(516-523), andSVCACD(524-525). - Stores processed records for sorting by
#GSORT.
External Programs Called¶
- None:
- The
BB7051program does not call any external programs. It performs straightforward data processing and file output within the RPG cycle.
Summary¶
- Process Steps:
- Define input (
BBORDR) and output (BB705O) files. - Process
BBORDRrecords using the RPG cycle with level breaks (L1for order,L2for company). - On order change, reset counters and saved fields (
DCNT,SVLOC,SVRQD8,SVCACD). - For header records, save request date and carrier code.
- For detail records, increment counter, save location, write header (if first detail), and write detail.
- For remark records, write directly to
BB705O. -
Output records to
BB705Owith appended sort fields (SVLOC,SVRQD8,SVCACD). -
Business Rules:
- Enhance records with location, request date, and carrier code for sorting.
- Write header only on first detail record per order.
- Preserve entire input record content, appending sort fields.
-
Assume pre-filtering by company and date range from
BB705P. -
Tables Used:
-
Files:
BBORDR(input),BB705O(output). -
External Programs Called:
- None.
This program is a critical step in the workflow, preparing BB705O for sorting by #GSORT and reporting by BB705. It integrates with BB705P (input validation) and BB705.ocl36.txt (orchestration). If you have additional file layouts (e.g., for BBORDR) or need further analysis, let me know!