Skip to content

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:

  1. File and Data Definitions:
  2. Input File:
    • BBORDR (512 bytes, primary input, indexed): Contains order data with header, detail, and miscellaneous/remark records.
  3. Output File:
    • BB705O (532 bytes, output): Work file to store processed records with added fields for location, request date, and carrier code.
  4. Record Formats (from BBORDR):
    • Header Record (NS 01):
    • BODEL (position 1): Delete flag ('D' for deleted).
    • BOCO (positions 2-3): Company number (level break L2).
    • BORDNO (positions 4-9): Order number (level break L1).
    • 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.
  5. 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.
  6. Main Processing (RPG Cycle):

  7. The program uses the RPG cycle to process BBORDR records sequentially, with level breaks on company (L2, BOCO) and order (L1, BORDNO).
  8. Level Break (L1, Order Change) (lines 0043-0048):
    • Resets DCNT to 0 (detail counter).
    • Clears SVLOC to blanks.
    • Resets SVRQD8 to 0 (request date).
    • Clears SVCACD to blanks (carrier code).
  9. Header Record Processing (NS 01) (lines 0050-0053):
    • Stores BORQD8 (request date) in SVRQD8.
    • Stores BOCACD (carrier code) in SVCACD.
  10. Detail Record Processing (NS 02) (lines 0055-0062):
    • Increments DCNT (detail counter).
    • Stores BDLOC (location) in SVLOC.
    • If DCNT = 1 (first detail record for the order), writes the header record to BB705O using the HOUT exception output (includes HREC1, HREC2, SVLOC, SVRQD8, SVCACD).
    • Writes the detail record to BB705O using the DOUT exception output.
  11. Miscellaneous/Remark Record Processing (NS 03) (lines 0064-0066):

    • Writes the remark record to BB705O using the MOUT exception output.
  12. Output to BB705O:

  13. HOUT (Header Output) (lines 0069-0074):
    • Writes HREC1 (1-256), HREC2 (257-512), SVLOC (513-515), SVRQD8 (516-523), SVCACD (524-525).
  14. DOUT (Detail Output) (lines 0076-0081):
    • Writes DREC1 (1-256), DREC2 (257-512), SVLOC (513-515), SVRQD8 (516-523), SVCACD (524-525).
  15. MOUT (Remark Output) (lines 0083-0088):
    • Writes MREC1 (1-256), MREC2 (257-512), SVLOC (513-515), SVRQD8 (516-523), SVCACD (524-525).
  16. The output file BB705O extends BBORDR’s 512-byte records to 532 bytes by adding SVLOC, SVRQD8, and SVCACD for sorting by #GSORT in BB705.ocl36.txt.

  17. Program Termination:

  18. The program ends when all BBORDR records are processed, producing BB705O for subsequent sorting and reporting.

Business Rules

The program enforces the following business rules for building the work file:

  1. Record Filtering:
  2. Records with delete flags (BODEL, BDDEL, BMDEL = 'D') are not explicitly filtered in BB7051 but are handled by #GSORT in BB705.ocl36.txt (condition I C 1 1NECD).

  3. Data Enhancement:

  4. For each order, the first detail record’s location (BDLOC) is saved as SVLOC and written to all records (header, detail, remark) in positions 513-515.
  5. The header’s request date (BORQD8) is saved as SVRQD8 and written to positions 516-523.
  6. The header’s carrier code (BOCACD) is saved as SVCACD and written to positions 524-525.
  7. This ensures all records in BB705O have consistent sort fields for #GSORT.

  8. Order-Level Processing:

  9. Header records are written only once per order, triggered by the first detail record (DCNT = 1).
  10. Detail and remark records are written as they are read, preserving the order structure.

  11. Record Integrity:

  12. The entire 512-byte record (HREC1, HREC2, DREC1, DREC2, MREC1, MREC2) is copied to BB705O, with additional fields appended.
  13. The program assumes BBORDR is pre-filtered by company (BOCO) and date range (BORQD8) based on parameters from BB705P.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):

  1. BBORDR:
  2. Input file containing order header (NS 01), detail (NS 02), and miscellaneous/remark (NS 03) records.
  3. Key fields: BOCO (company), BORDNO (order), BDLOC (location), BORQD8 (request date), BOCACD (carrier code).

  4. BB705O:

  5. Output work file, extended to 532 bytes with SVLOC (513-515), SVRQD8 (516-523), and SVCACD (524-525).
  6. Stores processed records for sorting by #GSORT.

External Programs Called

  • None:
  • The BB7051 program 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 BBORDR records using the RPG cycle with level breaks (L1 for order, L2 for 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 BB705O with 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!