Skip to content

BB927 RPG36

Process Steps of the RPG Program

This RPG III program (BB927) is designed to print a formatted report of the product code cross-reference file, processing sorted input records and enriching them with lookup data from supporting files. It operates in a level-break structure typical of RPG report programs, where records are grouped by key fields (company number at level L2, cross-reference set at level L1). The program assumes the input file (BBPRXR) has been pre-sorted (as done in the calling OCL procedure) by company number, cross-reference set, and product cross-reference. Below is a step-by-step breakdown of the program's execution:

  1. File Initialization and Input Reading:
  2. The program reads records sequentially from the primary input file BBPRXR (a 60-byte disk file). Each record triggers indicator 01 (NS 01).
  3. Fields are extracted from the input record: BXDEL (delete code), BXCONO (company number), BXPXRC (product cross-reference), BXPROD (product code), BXXSET (cross-reference set), and BXCNTR (container code).
  4. Level indicators L1 and L2 are automatically set by RPG based on control breaks: L2 fires when BXCONO changes (higher-level group, e.g., new company), L1 when BXXSET changes (sub-group, e.g., new cross-reference set within a company).

  5. Level Break Processing at L2 (Company Level):

  6. When a new company group starts (L2 indicator on), the program chains (keys into) the BICONT file using BXCONO to retrieve the company name (BCNAME).
    • If the record is not found (indicator 99 on), BCNAME is set to blanks.
  7. Captures the current system time (12-digit format) and moves it to TIME (6 digits) and DATE (6 digits, in YYMMDD format).
  8. Resets the page counter (PAGE) to 0.
  9. Prepares table lookup keys: Sets TBLKEY to 'PRODCD' (commented out in modification), XSKEY to 'BBXSET' followed by BXCONO moved to HLD6 (a 6-byte hold field).
  10. This step handles header setup for a new company section in the report.

  11. Level Break Processing at L1 (Cross-Reference Set Level):

  12. When a new cross-reference set group starts (L1 indicator on), the program updates XSKEY with BXXSET and chains to GSTABL using XSKEY to retrieve the cross-reference set description (XSDESC from TBDESC).
    • If not found (indicator 98 on), XSDESC is blanked.
  13. Prepares product lookup: Moves BXPROD to HLD6, then sets KLPROD to HLD6 and chains to GSPROD to retrieve the product description (PRDESC from TPDESC).

    • If not found (indicator 98 on), PRDESC is blanked.
    • Note: A modification (JK01) replaces the original GSTABL chain for product description with GSPROD, and adds TPFLCD (possibly a flag code) from GSPROD.
  14. Detail Record Processing (Indicator 01):

  15. For each input record read, the program outputs a detail line to the printer file (PRINT), including:
    • BXDEL (delete flag).
    • BXPXRC (product cross-reference).
    • BXPROD (product code).
    • BXCNTR (container code).
    • PRDESC (product description from lookup).
    • XSDESC (cross-reference set description).
    • BXXSET (cross-reference set code).
  16. This occurs after any level breaks are handled.

  17. Header and Formatting Output:

  18. Headers are printed on level breaks (L1 or overflow OF with NL1 for new page):
    • Company-level header (line 103): Prints BCNAME, 'PAGE' label with PAGE number, 'DATE' label with DATE.
    • Report title header (line 2): Prints XSDESC, BXXSET, and fixed text ' PRODUCT CODE CROSS REFERENCE FILE ', along with 'TIME' and TIME value.
    • Column headings (line 1): Fixed labels like 'CUSTOMER PRODUCT CD', 'ARG CODE', 'ARG CNTR', 'CUSTOMER NAME', 'XREF CODE'.
  19. Overflow handling (OF) ensures headers repeat on new pages.
  20. Paging is managed with PAGE incrementing implicitly on overflow.

  21. End of Processing:

  22. The program cycles through all records in BBPRXR until end-of-file.
  23. No explicit termination logic is shown, but RPG automatically ends after the last record, closing files and ending the job.

The program is cycle-driven (RPG's automatic read-process-output loop), with calculations interspersed for lookups and formatting. Modifications (JK01) update the product description lookup to use GSPROD instead of GSTABL, reflecting a change in data sourcing (e.g., from a general table to a product-specific file).

Business Rules

  • Data Grouping and Sorting Assumption: Records must be pre-sorted by company number (positions 2-3), cross-reference set (28-33), and product cross-reference (4-23) for level breaks to function correctly. This enforces hierarchical reporting: companies > cross-reference sets > individual product references.
  • Delete Handling: Records with BXDEL = 'D' (or TBDEL/TPDEL in tables) are printed but flagged, indicating they are marked for deletion (likely soft deletes).
  • Lookup Rules:
  • Company name (BCNAME) is always attempted from BICONT; defaults to blank if missing.
  • Cross-reference set description (XSDESC) from GSTABL; blank if not found.
  • Product description (PRDESC) from GSPROD (post-modification); blank if not found. Original logic used GSTABL with key 'PRODCD' + product code.
  • Validation and Defaults: No explicit error handling beyond blanking missing descriptions. Assumes valid keys; no additional edits or calculations (e.g., no arithmetic on quantities).
  • Report Structure:
  • Hierarchical: New company triggers full header reset (page=0, time/date capture).
  • New cross-reference set triggers sub-header and description refresh.
  • Detail lines include enriched data (descriptions) for readability.
  • Modification Impact (JK01): Shifts product description sourcing to GSPROD, potentially for more detailed or up-to-date data (e.g., GSPROD has 512-byte records vs. GSTABL's 256). Adds TPFLCD field, though not used in output.
  • Output Focus: Purely a print report; no updates to files. Emphasizes cross-references between products, containers, and sets, useful for inventory or catalog management.

Tables Used

  • GSTABL: Keyed table file (256-byte records, key length 12). Used for looking up cross-reference set descriptions (TBDESC) via XSKEY. Also checks for delete flag (TBDEL).
  • GSPROD: Keyed table file (512-byte records, key length 6). Used (post-modification) for looking up product descriptions (TPDESC) via KLPROD. Includes delete flag (TPDEL) and additional field TPFLCD (flag code, not used in output).
  • BICONT: Keyed control file (256-byte records, key length 2). Used for company name lookups (BCNAME) via BXCONO. Not explicitly a "table" but functions as a lookup source.

External Programs Called

  • None. The program performs all operations internally via file chains and built-in RPG functions (e.g., TIME, Z-ADD). No CALL opcodes or external program invocations are present. It is invoked by the parent OCL procedure but does not call others.