Skip to content

BB9511 RPG36

The provided RPG/36 program, BB9511.rpg36.txt, is a preprocessing program called by the BB951.ocl36.txt OCL program to prepare data for the rack price list report. It processes the rack price master file (BBPRCE), retrieves additional data from product and table files, and creates a temporary output file (BB9511) with enriched data. Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.


Process Steps of the RPG Program

The BB9511 RPG program reads records from the BBPRCE file, validates and filters them, retrieves descriptive data from GSPROD and GSTABL, and writes processed records to the BB9511 output file. Here’s a detailed breakdown of the process steps:

  1. File and Data Structure Definitions:
  2. Files:
    • BBPRCE: Input file (128 bytes, indexed, key length 27 bytes), the rack price master file.
    • GSTABL: Input file (256 bytes, indexed, key length 12 bytes), a table file for reference data (e.g., product class).
    • GSPROD: Input file (512 bytes, indexed, key length 6 bytes), a product file replacing GSTABL for product code data (per revision JK01).
    • BB9511: Output file (166 bytes), a temporary file for processed rack price data.
  3. Arrays:
    • RKPR (5 elements, 9.4): Stores rack prices from BBPRCE.
    • RKQT (5 elements, 7.0): Stores quantity levels from BBPRCE.
    • HLPR (5 elements, 9.4): Holds current rack prices for comparison.
    • HLQT (5 elements, 7.0): Holds current quantity levels for comparison.
    • PRPR (5 elements, 9.4): Stores previous prices (not used in output but initialized).
  4. Data Structures:
    • PRCEKY (25 bytes): Key for BBPRCE (not used in chaining but defined).
    • Unnamed DS (lines 0040–0048): Defines fields for a key structure (CUPROD, CUCNTR, CUUNMS, XXULO, XXCYMD, XXHHMM).
    • Unnamed DS (lines 0236–0239): Defines date fields ($CYMD, $CN, $YMD) for date calculations.
    • UDS (User Data Structure): Contains KYCO (company number), Y2KCEN (century, e.g., 19), and Y2KCMP (year comparison, e.g., 80).
  5. Input Fields:

    • BBPRCE: Includes RKDEL (delete flag), RKCONO (company), RKLOC (location), RKPROD (product code), RKCNTR (container), RKUNMS (unit of measure), RKDATE (date, CYMD), RKTIME (time, HHMM), RKPR (prices), RKQT (quantities), RKMINQ (minimum quantity), RKRKRQ (rack price required), RKINAC (inactive flag).
    • GSTABL: Includes TBDEL (delete flag), TBTYPE (table type), TBCODE (table code), TBPROD (product), TBDESC (description), TBDES1 (complete description), TBPRGP (product group), TBPRCL (product class), TBABDS (short description), TBCSRT (inventory sort code).
    • GSPROD: Includes TPDEL (delete flag), TPDESC (description), TPDES1 (complete description), TPPRGP (product group), TPPRCL (product class), TPABDS (short description).
  6. Initialization and Date Calculation (Indicator N09):

  7. Date Calculation (lines 0270–0287):
    • Calculates today’s date (UDATE) in YYYYMMDD format (KYDAT8):
    • Multiplies UDATE (MMDDYY) by 10000.01 to get KYDAT6 (YYMMDD).
    • Determines century (UCN): If UYEARY2KCMP (80), uses Y2KCEN (19); else, adds 1 to Y2KCEN (e.g., 20).
    • Combines century and KYDAT6 into KYDAT8.
    • Calculates date 30 days ago (DT3AGO):
    • Converts KYDAT8 to $CYMD (YYYYMMDD).
    • Extracts MMDDYY ($YMD), multiplies by 100.0001 to get MMDD.YY ($MDY).
    • Calls @GTOJ to convert to Julian date (G$JD).
    • Subtracts 31 days (SUB 31 G$JD).
    • Calls @JTOG to convert back to Gregorian date ($CYMD).
    • Stores result in DT3AGO (YYYYMMDD).
    • Sets indicator 09 to prevent re-execution.
  8. Purpose: Ensures date calculations for filtering or reporting are ready.

  9. Main Processing Loop (Level L1):

  10. Skip Special Product (lines 0053–0054):
    • If RKPROD = '7287', sets YES = 'YES' (likely a flag for special handling, but not used further).
  11. Filter Deleted Records (lines 0055–0057):
    • If RKDEL = 'D', skips to END (ignores deleted records).
  12. Filter by Company (lines 0060–0062):
    • If RKCONO ≠ KYCO (company from UDS), skips to END.
  13. Initialize Hold Fields (lines 0066–0069, JB02):
    • Clears HLQT (quantity array), HLPR (price array), PRPR (previous price array), HLRKRQ (rack required), and HLINAC (inactive flag).
    • Sets WRITIT = ' '.
  14. Retrieve Product Data (lines 0073–0077, JK01):
    • Builds key KLPROD with RKCONO and RKPROD.
    • Chains to GSPROD using KLPROD. If not found (92 on), clears TPDES1, TPABDS, TPPRGP; else, moves TPDES1 to DES1 (20 bytes), TPABDS to ABDS (10 bytes), and TPPRGP to PRGP (2 bytes).
  15. Retrieve Product Class Data (lines 0072–0077):
    • Builds key TBLKEY with 'PRODCL' and TPPRCL (product class from GSPROD).
    • Chains to GSTABL using TBLKEY. If found (N92), moves TBCSRT to CSRT (inventory sort code); else, clears CSRT.
  16. Set Write Flag (line 0083):

    • Sets WRITIT = 'Y' to indicate the record should be written.
  17. Price and Quantity Comparison (lines 0085–0099, JB02):

  18. Compares current record’s prices (RKPR,1 to RKPR,5), quantities (RKQT), rack required (RKRKRQ), and inactive flag (RKINAC) with hold arrays (HLPR, HLQT, HLRKRQ, HLINAC).
  19. If any differ (10 on), updates hold arrays:

    • Moves RKPR to HLPR.
    • Moves RKQT to HLQT.
    • Moves RKRKRQ to HLRKRQ.
    • Moves RKINAC to HLINAC.
  20. Write Output Record (lines 0106–0108):

  21. If WRITIT = 'Y' and level L1 is active, writes to BB9511 using the ADD951 exception output:

    • RKCONO (company, pos 1–2).
    • RKLOC (location, pos 3–5).
    • PRGP (product group, pos 6–7, binary).
    • RKPROD (product code, pos 8–11).
    • RKCNTR (container, pos 12–14).
    • RKUNMS (unit of measure, pos 15–17).
    • HLQT (quantity array, pos 18–52).
    • HLPR (price array, pos 53–82, packed).
    • PRPR (previous price array, pos 83–112, packed).
    • DES1 (complete description, pos 113–132, binary).
    • ABDS (short description, pos 133–142, binary).
    • RKDATE (date, pos 143–150).
    • RKTIME (time, pos 151–154).
    • RKMINQ (minimum quantity, pos 155–161).
    • HLRKRQ (rack required, pos 163).
    • HLINAC (inactive flag, pos 164).
    • CSRT (inventory sort code, pos 165–166).
  22. Date Conversion Subroutines:

  23. @GTOJ (lines 0320–0384):
    • Converts Gregorian date ($MDY, MMDDYY; $CN, century) to Julian date (G$JD).
    • Breaks down $MDY into year, month, day.
    • Adjusts century if not provided (similar to initialization).
    • Converts month and year to Julian days, adds day, and calculates day of week (G$JW).
  24. @JTOG (lines 0388–0438):

    • Converts Julian date (G$JD) to Gregorian date ($MDY, MMDDYY; $CN, century).
    • Calculates year, month, and day from Julian days, adjusting for leap years and month boundaries.
  25. Program Termination:

  26. The program ends at the END tag (line 0102) after processing each record or skipping invalid ones, looping through BBPRCE until all records are processed.

Business Rules

The RPG program enforces the following business rules for preprocessing the rack price list:

  1. Record Filtering:
  2. Excludes deleted records (RKDEL = 'D').
  3. Processes only records for the specified company (RKCONO = KYCO).

  4. Product Data Enrichment:

  5. Retrieves product description (TPDES1), short description (TPABDS), and product group (TPPRGP) from GSPROD using RKCONO and RKPROD.
  6. If not found, uses blank values.

  7. Product Class Data:

  8. Retrieves inventory sort code (TBCSRT) from GSTABL using PRODCL and TPPRCL (product class from GSPROD).
  9. If not found, uses blank CSRT.

  10. Price and Quantity Tracking:

  11. Compares current record’s prices (RKPR), quantities (RKQT), rack required (RKRKRQ), and inactive flag (RKINAC) with hold arrays.
  12. Updates hold arrays (HLPR, HLQT, HLRKRQ, HLINAC) if differences are found, ensuring the latest values are written.

  13. Date Handling:

  14. Calculates today’s date and 30 days prior in YYYYMMDD format for potential filtering (though not explicitly used in filtering logic).
  15. Handles century calculation for Y2K compliance (years ≥ 80 use 19xx, else 20xx).

  16. Output Record:

  17. Writes only valid records (WRITIT = 'Y') with enriched data (descriptions, sort code) to BB9511.
  18. Includes company, location, product group, product, container, unit of measure, prices, quantities, descriptions, date, time, minimum quantity, rack required, and inactive flags.

  19. Special Product Handling:

  20. Flags product code '7287' with YES = 'YES', but no further action is taken (possibly a legacy or debugging flag).

Tables/Files Used

The RPG program uses the following files: 1. BBPRCE (?9?BBPRCE): Input rack price master file, containing company, location, product, container, unit of measure, prices, quantities, date, time, minimum quantity, rack required, and inactive flags. 2. GSTABL (?9?GSTABL): Input table file, used for product class data (e.g., inventory sort code TBCSRT). 3. GSPROD (?9?GSPROD): Input product file, used for product descriptions, product group, and product class. 4. BB9511 (?9?BB9511): Output temporary file, containing processed rack price data with enriched fields.


External Programs Called

The RPG program does not explicitly call any external programs. It performs file operations (CHAIN, READ, EXCPT) and internal subroutines (@GTOJ, @JTOG) but does not invoke other programs. It is called by the BB951.ocl36.txt OCL program as part of the rack price list process.


Summary

  • Process Overview: The BB9511 RPG program preprocesses the BBPRCE rack price master file, filtering by company and non-deleted records, enriching with product data from GSPROD and product class data from GSTABL, and writing a temporary file (BB9511) with prices, quantities, descriptions, and other fields for the rack price report.
  • Business Rules: Filters out deleted records and non-matching companies, retrieves product and class data, tracks price/quantity changes, and handles Y2K-compliant dates. Writes enriched records to BB9511.
  • Files/Tables: BBPRCE (input), GSTABL (input table), GSPROD (input product file), BB9511 (output).
  • External Programs: None called directly.

If you need further details (e.g., file structures, output format ADD951, or interactions with other programs like BB951 or BB9518), please provide them, or I can search for related information if desired!