Skip to content

BI944 RPG36

The RPG program BI944.rpg36 is an RPG/400 program invoked by the OCL program BI944.ocl36.txt to generate the final Customer Sales Agreement Master File Listing. It processes sorted sales agreement records from BICUAGXX, enriches them with data from multiple reference files, and produces printed reports (PRTDOWN, PRTEXCEL) and an optional output file (BICUAGC) for CRM integration. The program includes revisions to handle container codes, freight codes, and other specific requirements. Below, I’ll explain the process steps, business rules, tables used, and any external programs called.

Process Steps of the RPG Program

The program reads records from BICUAGXX, retrieves additional data from reference files, performs validations, and formats output for printing or CRM upload. The steps are as follows:

  1. File and Data Structure Initialization (F-specs and I-specs):
  2. Input Files:
    • BICUAGXX (Primary Input, 263 bytes): Sorted sales agreement records from BI9444.
    • BICONT (Input, 256 bytes, indexed): Control file for company data.
    • BBPRCY (Input, 128 bytes, indexed): Pricing file.
    • ARCUST (Input, 384 bytes, indexed): Customer master file.
    • GSTABL (Input, 256 bytes, indexed): General system table for product class and other data.
    • SHIPTO (Input, 2048 bytes, indexed): Ship-to data.
    • ARCUPR (Input, 80 bytes, indexed): Customer pricing records.
    • ARCUSP (Input, 1344 bytes, indexed): Customer pricing supplemental data.
    • INLOC (Input, 512 bytes, indexed): Location file.
    • BICUA7 (Input, 261 bytes, indexed): Indexed version of sales agreement data for previous price lookup.
    • GSCTWT (Input, 64 bytes, indexed): Weight table for gallon calculations.
    • GSUMCV (Input, 64 bytes, indexed): Unit of measure conversion table.
    • GSCNTR1 (Input, 512 bytes, indexed): Container code table.
    • GSPROD (Input, 512 bytes, indexed): Product master file.
  3. Output Files:
    • BB203W (Output, 327 bytes): Work file for storing new start dates and other data.
    • PRTDOWN (Output, 164 bytes, printer): Standard printed report.
    • PRTEXCEL (Output, 224 bytes, printer): Excel-compatible spreadsheet output.
    • BICUAGC (Output, 271 bytes, disk, conditioned by U3): Output for CRM upload, updated hourly when U3 is on.
  4. Arrays and Data Structures:
    • SEP (79 elements, 2 bytes): Separator lines for report formatting.
    • BAP (10 elements, 4 bytes): Product codes (BAPR01BAPR10).
    • BAD (10 elements, 10 bytes): Product descriptions.
    • FLD (28 elements, 1 byte): Field indicators.
    • CTY (26 elements, 1 byte): City codes.
    • ST (2 elements, 1 byte): State codes.
    • DESC (5 elements, 10 bytes): Freight descriptions (e.g., COLLECT, PPD & ADD).
    • COM (2 elements, 15 bytes): Division descriptions (e.g., REFINERY, BLENDED LUBES).
    • ERR (4 elements, 30 bytes): Error messages (e.g., NO PRODUCT CLASS LISTED).
  5. Input Specifications:

    • BICUAGXX: Defines fields like BADEL (delete code), BACONOL7/CO (company), BACUSTL2/CUST (customer), BALOC (location), BAPR01L3BAPR10 (product codes), BASTDT (start date), BASTTM (start time), BAENDT (end date), BAENTM (end time), BAPRCE (price, packed), BAOFFP (off-price, packed), BAMNQY (minimum quantity), BAMXQY (maximum quantity), BAPPD (prepaid flag), BAALSH (apply to all ship-to), BAPRIM (pricing method), BACNTR (container code), BASTD8 (start date CYMD), BAEND8 (end date CYMD), BADELV (delivery flag), BAFRCD (freight code), BACRDT (creation date), BACRTM (creation time), BALUDT (last update date), BALUTM (last update time), BASHIPL1/SHIP (ship-to number), BACNT# (contract number), BAUNMS (unit of measure), BASEQN (sequence number), BAPORD (bill-to PO), BADIV (division), BAPRCLL4 (product class), BAREC (full record).
    • ARCUST: Defines ARNAME (customer name), ARLSTN (last name abbreviation).
    • BICONT: Defines BCNAME (company name), BCSEQN (sequence number).
    • SHIPTO: Defines CSDEL (delete code), CSCO (company), CSCUST (customer), CSSHIP (ship-to number), CSNAME (ship-to name), CSADR1CSADR3 (address).
  6. Main Processing Loop (C-specs, partially truncated):

  7. Record Processing (Indicator 01, primary file BICUAGXX):
    • Reads each record from BICUAGXX sequentially.
    • Performs lookups and validations to enrich the record with customer, ship-to, product, and pricing data.
  8. Customer Lookup:
    • Chains to ARCUST using BACUSTL2 to retrieve ARNAME (customer name).
  9. Ship-to Lookup:
    • Chains to SHIPTO using CSCO (company) and BASHIPL1 (ship-to number) to retrieve ship-to details (CSNAME, CSADR1CSADR3).
    • If no ship-to record exists, sets an error message (e.g., ERR,3 or ERR,4).
  10. Product Class Lookup:
    • Chains to GSTABL or GSPROD (per JK02) using BAPRCLL4 to retrieve product class description (PRCLDS).
    • If not found, sets error message ERR,1 (NO PRODUCT CLASS LISTED).
  11. Product Description Lookup:
    • For each non-blank product code in BAP (1–10), chains to GSPROD to retrieve product description (BAD array).
    • If not found, sets error message ERR,2 (BAD PRODUCT).
  12. Previous Price Lookup (JB05, MG04):
    • Chains to BICUA7 (indexed sales agreement file) to retrieve previous price, considering container code (BACNTR).
    • Attempts lookup with container type first, then with blank container type, and for non-fluid products, with 'P' container type.
  13. Freight Code Handling (MG09, JB08, JB10):
    • Uses BAFRCD from BICUAGXX for freight code/description (reversing JB08’s ship-to-based logic).
    • Maps BAFRCD to descriptions in DESC array (e.g., C=COLLECT, P=PPD & ADD, D=DELIVERED, A=3RD PARTY).
    • For freight collect (BAFRCD = 'C'), handles special cases for non-Bradford locations (JB10).
  14. Quantity Conversion (JB12):
    • Chains to GSCTWT to retrieve gallons per container if available, bypassing GSUMCV for gallon calculations.
    • If no GSCTWT record, uses GSUMCV for unit of measure conversion.
  15. Container Code Lookup (JK01):
    • Chains to GSCNTR1 for container code (BACNTR) details.
  16. Report Formatting:
    • Writes headers to PRTDOWN and PRTEXCEL with company name (BCNAME), division (DIVNAM), date (SYSDATY), time (SYSTIM), and selection criteria (KYINDC, KYDLCH, KYSTDT).
    • Writes detail lines for each valid record, including product code (BAP,1), description (BAD,1), customer number (BACUSTZ), name (ARNAME), ship-to (BASHIP or 'ALL'), location (BALOC), container code (BACNTR), current price (BAPRCE), previous price (PRVPRC), freight terms (FRTDSC, FRTDIF), start date (STDT), end date (ENDT), minimum/maximum quantities (BAMNQY, BAMXQY), and new price if applicable (PRICE).
  17. Output to BB203W:
    • Writes updated records with new start date (KYSTDT) per JB03.
  18. Output to BICUAGC (MG05):
    • If indicator U3 is on (hourly CRM update), writes records to BICUAGC for CRM upload.
  19. Total Count:

    • Increments COUNT for each record processed and writes it to the report footer (T 31 LR).
  20. Report Output:

  21. PRTDOWN (Standard Report):
    • Includes headers with division, report type (add/update or report-only), date, time, and column headings (e.g., PROD CODE, DESC, CUST NO., NAME, SHIP TO, LOCATION, CNTR, PRICE, PREV PRICE, FREIGHT TERMS, STARTING DATE, ENDING DATE).
    • Detail lines include product, customer, ship-to, pricing, freight, and date information.
    • Footer includes total record count.
  22. PRTEXCEL (Spreadsheet Output):
    • Similar to PRTDOWN but formatted for Excel, with additional fields like off-price (BAOFFP), new price (PRICE), and quantities.
  23. Error Handling:
    • Outputs error messages (ERR array) for missing product classes, products, or ship-to records.

Business Rules

  1. Record Inclusion:
  2. Records with BADEL = 'D' (deleted) are skipped.
  3. Only valid records with matching customer, ship-to, product, and container data are included.

  4. Customer and Ship-to Validation:

  5. Customer number (BACUSTL2) must exist in ARCUST to retrieve ARNAME.
  6. Ship-to number (BASHIPL1) must exist in SHIPTO unless BAALSH = 'Y' (apply to all ship-to), in which case 'ALL' is used.
  7. Missing ship-to records trigger ERR,3 or ERR,4.

  8. Product and Product Class Validation (JK02):

  9. Product codes (BAP,1BAP,10) are validated against GSPROD for descriptions (BAD).
  10. Product class (BAPRCLL4) is validated against GSTABL or GSPROD; missing classes trigger ERR,1.
  11. Invalid products trigger ERR,2.

  12. Previous Price Lookup (JB05, MG04):

  13. Chains to BICUA7 using company, customer, product, and container code (BACNTR).
  14. Tries container type first, then blank, and 'P' for non-fluid products.
  15. Previous price (PRVPRC) is included in the report if available.

  16. Freight Code Handling (MG09, JB08, JB10):

  17. Uses BAFRCD from BICUAGXX (C, P, D, A, or blank) to map to DESC array (COLLECT, PPD & ADD, DELIVERED, 3RD PARTY).
  18. Special handling for freight collect (BAFRCD = 'C') from non-Bradford locations (JB10).
  19. Outputs freight description (FRTDSC) and difference (FRTDIF if applicable).

  20. Quantity Conversion (JB12):

  21. Prefers GSCTWT for gallons per container if available; otherwise, uses GSUMCV for unit of measure conversion (BAUNMS).
  22. Minimum and maximum quantities (BAMNQY, BAMXQY) are reported in gallons.

  23. Container Code Validation (JK01):

  24. Container code (BACNTR) is validated against GSCNTR1.

  25. Report Conditions:

  26. Indicator 74 determines if the report is for add/update (KYADDA = 'Y') or report-only.
  27. Indicator 71 includes new price (KYINDC, KYDLCH) and new start date (KYSTDT) in PRTEXCEL.
  28. Indicator 50 suppresses end date if zero ('00/00/00').

  29. CRM Output (MG05):

  30. If U3 is on, writes to BICUAGC for hourly CRM upload, ensuring BICUA7 is in sync with BICUAGX.

Tables (Files) Used

  1. BICUAGXX (Primary Input, 263 bytes):
  2. Fields: BADEL, BACONOL7, BACUSTL2, BALOC, BAPR01L3BAPR10, BASTDT, BASTTM, BAENDT, BAENTM, BAPRCE, BAOFFP, BAMNQY, BAMXQY, BAPPD, BAALSH, BAPRIM, BACNTR, BASTD8, BAEND8, BADELV, BAFRCD, BACRDT, BACRTM, BALUDT, BALUTM, BASHIPL1, BACNT#, BAUNMS, BASEQN, BAPORD, BADIV, BAPRCLL4, BAREC.
  3. BICONT (Input, 256 bytes, indexed):
  4. Fields: BCNAME, BCSEQN.
  5. BBPRCY (Input, 128 bytes, indexed):
  6. Pricing data.
  7. ARCUST (Input, 384 bytes, indexed):
  8. Fields: ARNAME, ARLSTN.
  9. GSTABL (Input, 256 bytes, indexed):
  10. Product class and other reference data.
  11. SHIPTO (Input, 2048 bytes, indexed):
  12. Fields: CSDEL, CSCO, CSCUST, CSSHIP, CSNAME, CSADR1CSADR3.
  13. ARCUPR (Input, 80 bytes, indexed):
  14. Customer pricing data.
  15. ARCUSP (Input, 1344 bytes, indexed):
  16. Supplemental pricing data.
  17. INLOC (Input, 512 bytes, indexed):
  18. Location data.
  19. BICUA7 (Input, 261 bytes, indexed):
    • Indexed sales agreement data for previous price lookup.
  20. GSCTWT (Input, 64 bytes, indexed):
    • Weight table for gallon calculations.
  21. GSUMCV (Input, 64 bytes, indexed):
    • Unit of measure conversion.
  22. GSCNTR1 (Input, 512 bytes, indexed):
    • Container code data.
  23. GSPROD (Input, 512 bytes, indexed):
    • Product master data.
  24. BB203W (Output, 327 bytes):
    • Work file for new start dates and other data.
  25. PRTDOWN (Output, 164 bytes, printer):
    • Standard report output.
  26. PRTEXCEL (Output, 224 bytes, printer):
    • Excel-compatible report output.
  27. BICUAGC (Output, 271 bytes, disk, U3):
    • CRM upload file.

External Programs Called

The RPG program BI944 does not explicitly call any external programs via CALL operations. It is invoked by the OCL program BI944.ocl36.txt and processes data independently, relying on input from BICUAGXX and reference files, producing outputs for printing and CRM integration.

Summary

  • Process Steps:
  • Read records from BICUAGXX.
  • Chain to ARCUST, SHIPTO, GSPROD, GSTABL, GSCNTR1, BICUA7, GSCTWT, and GSUMCV for data enrichment.
  • Validate customer, ship-to, product, product class, and container code.
  • Retrieve previous price from BICUA7 with container type logic.
  • Map freight codes to descriptions, handling special cases.
  • Convert quantities using GSCTWT or GSUMCV.
  • Write formatted reports to PRTDOWN and PRTEXCEL with headers, details, and totals.
  • Write to BB203W for new start dates and BICUAGC for CRM if U3 is on.
  • Continue until end-of-file.

  • Business Rules:

  • Skip deleted records (BADEL = 'D').
  • Validate customer, ship-to, product, and product class data.
  • Retrieve previous price with container type priority.
  • Use BAFRCD for freight terms; handle non-Bradford freight collect cases.
  • Prefer GSCTWT for gallon calculations, else use GSUMCV.
  • Format reports based on add/update or report-only mode.
  • Output to BICUAGC for CRM if U3 is on.

  • Tables Used:

  • Input: BICUAGXX, BICONT, BBPRCY, ARCUST, GSTABL, SHIPTO, ARCUPR, ARCUSP, INLOC, BICUA7, GSCTWT, GSUMCV, GSCNTR1, GSPROD.
  • Output: BB203W, PRTDOWN, PRTEXCEL, BICUAGC.

  • External Programs Called:

  • None directly called.

This program finalizes the Customer Sales Agreement Master File Listing, producing detailed reports and optional CRM output while enforcing strict validation and formatting rules. If you need further details or have additional files, please provide them.