Skip to content

BI9443 RPG

The RPG program BI9443.rpg is an RPG/400 program called by the OCL program BI944.ocl36.txt to update the Customer Sales Agreement file (BICUAG) by adding salesman, product class, and division information, producing an output file (BICUAGNW). It includes logic to filter out expired agreements based on their end dates. Below, I’ll explain the process steps, business rules, tables used, and any external programs called.

Process Steps of the RPG Program

The program processes records from the BICUAG file, validates them against reference files (ARCUST, GSPROD, GSTABL), and writes updated records to BICUAGNW with additional fields (salesman, product class, division). The steps are as follows:

  1. File and Record Initialization (Lines 0004–0058):
  2. Input Files:
    • BICUAG (Primary Input, 256 bytes, disk): Primary file containing sales agreement records.
    • GSTABL (Input, 256 bytes, indexed): General system table for product class and division data.
    • ARCUST (Input, 384 bytes, indexed): Customer master file for salesman data.
    • GSPROD (Input, 512 bytes, indexed): Product master file for product class validation (added in revision JK01).
  3. Output File:
    • BICUAGNW (Output, 263 bytes, disk): Output file with updated records, including new fields.
  4. Input Specifications:

    • BICUAG: Defines fields like BACONO (company, positions 2–3), BACOCU (company/customer, 2–9), BACUST (customer number, 4–9), BAPR01 (product code, 13–16), and BAEND8 (end date in CYMD format, 126–133).
    • GSTABL: Defines fields like TBDESC (table description, 14–43), TBDES2 (alternate description, 22–43), TBPRCL (product class code, 127–129), and TBCSRT (inventory company sort, 178–179).
    • ARCUST: Defines fields like ARDEL (delete code, 1–1) and ARSLS# (salesman number, 263–264).
    • GSPROD: Defines fields like TPDEL (delete flag, 1–1), TPDESC (description, 14–43), TPDES1 (complete description, 14–33), TPPRGP (product group code, 89–90), TPPRCL (product class code, 127–129), TPABDS (short description, 145–154), and TPFLCD (252–252).
    • UDS (User Data Structure): Defines KYDAT8 (system date in CYMD format, 333–340) for date comparison.
  5. Main Processing Loop (Lines 0015–0016, C-specs):

  6. Record Processing (Indicator 01, primary file BICUAG):
    • Reads each record from BICUAG sequentially.
    • Initializes indicator 50 to off (SETOF 50).
  7. End Date Validation (JB01):
    • Checks if BAEND8 (end date in CYMD format) is non-zero.
    • If non-zero and less than KYDAT8 (system date), skips to ENDIT (omits expired agreements).
    • If BAEND8 is zero (no end date), sets indicator 50 on to include the record.
  8. Customer Lookup:
    • Chains to ARCUST using BACOCU (company/customer key, positions 2–9).
    • If found (indicator 99 off), moves ARSLS# (salesman number) to SLSMAN (2-byte field).
  9. Product Class Lookup (JK01):
    • Builds a key KLPROD (6 bytes) by combining BACONO (company) and BAPR01 (product code).
    • Chains to GSPROD using KLPROD to retrieve the product class.
    • If found (indicator 65 off), moves TPPRCL (product class code) to PRCL (3 bytes).
    • If not found, builds a key PRCLKY (12 bytes) by combining 'PRODCL' and KEY5 (company + PRCL), then chains to GSTABL.
    • If found in GSTABL (indicator 65 off), moves TBCSRT (inventory company sort) to DIV (2 bytes) and writes the record (EXCPT PRODCL).
  10. Output:

    • Writes to BICUAGNW using the PRODCL format:
    • RECORD (entire input record, positions 1–256).
    • If indicator 50 is on, writes '791231' to positions 70–75 and '20791231' to positions 128–133 (likely default dates for unexpired agreements).
    • DIV (division, position 258).
    • PRCL (product class, 259–261).
    • SLSMAN (salesman number, 262–263, blank-filled).
  11. End of Processing:

  12. Branches to ENDIT for skipped records (expired agreements).
  13. Continues reading BICUAG until end-of-file, processing each valid record.

Business Rules

The program enforces the following business rules: 1. Include Only Unexpired Agreements (JB01): - Agreements with a non-zero end date (BAEND8) must be greater than or equal to the system date (KYDAT8) to be included. - Agreements with a zero end date (BAEND8 = *ZEROS) are included as unexpired, with default dates '791231' and '20791231' written to the output. 2. Customer Validation: - The customer number (BACOCU) must exist in ARCUST (indicator 99 off) to retrieve the salesman number (ARSLS#). 3. Product Class Validation (JK01): - The product code (BAPR01 + BACONO) is first validated against GSPROD to retrieve the product class (TPPRCL). - If not found in GSPROD, the product class (PRCL) is validated against GSTABL using the PRODCL key to retrieve the division (TBCSRT). 4. Output Record Structure: - The output record includes the original BICUAG record (1–256), division (258), product class (259–261), and salesman number (262–263). - For unexpired agreements with zero end dates, specific date fields are populated with default values.

Tables (Files) Used

The program uses the following files, as defined in the File Specification (F-spec) and Input Specification (I-spec): 1. BICUAG (Primary Input, 256 bytes): - Fields: BACONO (company), BACOCU (company/customer), BACUST (customer number), BAPR01 (product code), BAEND8 (end date). - Usage: Primary input file containing sales agreement records. 2. GSTABL (Input, 256 bytes, indexed): - Fields: TBDESC, TBDES2, TBPRCL (product class code), TBCSRT (division sort code). - Usage: Chained to validate product class and retrieve division. 3. ARCUST (Input, 384 bytes, indexed): - Fields: ARDEL (delete code), ARSLS# (salesman number). - Usage: Chained to retrieve salesman number for the customer. 4. GSPROD (Input, 512 bytes, indexed): - Fields: TPDEL, TPDESC, TPDES1, TPPRGP, TPPRCL, TPABDS, TPFLCD. - Usage: Chained to validate product code and retrieve product class. 5. BICUAGNW (Output, 263 bytes): - Fields: RECORD (1–256), DIV (258), PRCL (259–261), SLSMAN (262–263), and default dates (70–75, 128–133 when indicator 50 is on). - Usage: Output file with updated sales agreement records.

External Programs Called

The RPG program BI9443 does not explicitly call any external programs via CALL operations. It is invoked by the OCL program BI944.ocl36.txt and processes data independently, writing to BICUAGNW for subsequent steps in the OCL workflow (e.g., sorting by #GSORT or further processing by BI9444 and BI944).

Summary

  • Process Steps:
  • Read each record from BICUAG.
  • Validate the end date (BAEND8):
    • Skip if non-zero and less than KYDAT8 (expired).
    • Include if zero, setting indicator 50 and default dates.
  • Chain to ARCUST to retrieve salesman number (ARSLS#).
  • Chain to GSPROD to retrieve product class (TPPRCL); if not found, chain to GSTABL to validate product class and retrieve division (TBCSRT).
  • Write updated record to BICUAGNW with original data, division, product class, salesman, and default dates (if applicable).
  • Continue until all BICUAG records are processed.

  • Business Rules:

  • Include only unexpired agreements (end date ≥ system date or zero).
  • Validate customer number against ARCUST to get salesman number.
  • Validate product code against GSPROD for product class; fall back to GSTABL if needed.
  • Output includes original record plus division, product class, salesman, and default dates for zero-end-date records.

  • Tables Used:

  • BICUAG (primary input)
  • GSTABL (input, indexed)
  • ARCUST (input, indexed)
  • GSPROD (input, indexed)
  • BICUAGNW (output)

  • External Programs Called:

  • None directly called within the RPG program. It is part of the OCL workflow involving BI9444, #GSORT, and BI944.

This program prepares sales agreement data by appending critical fields (salesman, product class, division) and filtering out expired agreements, setting the stage for sorting and final report generation in the OCL process. If you need further analysis of BI9444 or BI944, please provide their source code or additional details.