Skip to content

BB9563 RPG36

The provided document is an RPG III (or RPG/36) program, BB9563.rpg36.txt, called conditionally from the OCL program BB9563.ocl36.txt when SWITCH1 is set to 1 in the main OCL program BB956P.ocl36.txt. Despite the header in the RPG source listing it as BB9543, this appears to be a typo, as the OCL program refers to BB9563, and the context aligns with the rack pricing update process. This program compares data from pricing and customer files, validates against a container file, and generates output for new pricing records and a printed report. Below is an explanation of the process steps, business rules, tables (files) used, and any external programs called.


Process Steps of the RPG Program BB9563

The BB9563 program processes rack pricing data by validating records against customer and container data, writing valid records to an output file, and producing a printed report. Here’s a step-by-step breakdown of the process:

  1. File and Data Structure Definitions:
  2. Files:
    • RKPRCE: Input primary file (IP, 121 bytes, no key specified) containing rack pricing data.
    • GSCNTR1: Input file (IF, 512 bytes, 3-byte key, direct access) containing container data (replaced GSCNTR per revision note on 02/24/16).
    • PRCTUM: Input file (IF, 64 bytes, 18-byte key, direct access) containing customer data.
    • NEWPROD: Output file (O, 32 bytes, no key) for storing new pricing records.
    • PRINTER: Output file (O, 132 bytes) for generating a printed report.
  3. Data Structures:
    • DSC: Array of 2 elements, each 15 characters, containing descriptions ("BRAD PENN" and "DA LUBRICANTS") for comparison.
    • UDS (User Data Structure):
    • KYDATE (positions 105-110): Date input.
    • KYCUST (positions 201-206): Customer number input.
  4. Record Formats:

    • RKPRCE:
    • XXCONO (positions 1-2): Company number.
    • XXLOC (positions 3-5): Location code.
    • XXPRCL (positions 6-8): Price class.
    • XXPROD (positions 9-12): Product code.
    • XXDES1 (positions 13-32): Product description.
    • XXCNTR (positions 33-35): Container code.
    • XXUNMS (positions 36-38): Unit of measure.
    • XXDATE (positions 39-46): Date.
    • XXTIME (positions 47-52): Time.
    • PRCTUM:
    • PCDEL (position 1): Delete flag ('D' for delete).
    • PCCONO (positions 2-3): Company number.
    • PCCUST (positions 4-9): Customer number.
    • PCKEY (positions 2-9): Composite key (company + customer).
    • PCPROD (positions 10-13): Product code.
    • PCCNTR (positions 14-16): Container code.
    • PCUNMS (positions 17-19): Unit of measure.
    • GSCNTR1:
    • TCDEL (position 1): Delete flag ('D' for delete).
    • TCCNTR (positions 2-4): Container code.
    • TCCNTA (positions 5-7): Alpha container code.
    • TCFIL1 (positions 8-13): Filler.
    • TCDESC (positions 14-43): Table description.
    • TCDSCS (positions 44-51): Short description.
    • TCDSCL (positions 52-73): Long description.
    • TCFIL2 (positions 74-179): Filler.
    • TCCNTY (position 180): Container type (B or P).
    • TCFRTB (positions 181-182): Freight table code.
    • TCFIL3 (positions 183-210): Filler.
    • TCDES2 (positions 211-240): Second description.
    • TCFIL4 (positions 241-256): Filler.
    • TCCTRS (position 257): Container source.
    • TCIUM (positions 258-260): IMS unit of measure.
    • TCFIL5 (positions 261-512): Filler.
  5. Date Conversion:

  6. C N09 KYDATE MULT 10000.01 DATYMD 60:
    • If indicator 09 is off (initial run), multiplies KYDATE (6-digit date, e.g., YYMMDD) by 10000.01 to convert it to a 6-digit format (DATYMD).
  7. C N09 MOVEL20 DATE8 80:
    • Moves 20 (likely century, e.g., 2000s) to the first two digits of DATE8 (8-digit date field).
  8. C N09 MOVE DATYMD DATE8:
    • Appends DATYMD to DATE8, creating an 8-digit date (e.g., 20YYMMDD).
  9. C N09 SETON 09:

    • Sets indicator 09 to prevent reprocessing the date conversion in subsequent cycles.
  10. Date Validation:

  11. C 01 XXDATE IFNE DATE8:

    • For each RKPRCE record (indicator 01 set by the RPG cycle), compares the record’s date (XXDATE) to the converted date (DATE8).
    • If they are not equal, jumps to the END tag, skipping the record.
    • If equal, continues processing.
  12. Key Construction and Validation:

  13. Constructs keys for chaining:
    • MOVELXXCONO KEY18 18: Moves company number (XXCONO) to KEY18.
    • MOVELKYCUST KEY10 10: Moves input customer number (KYCUST) to KEY10.
    • MOVE XXPROD KEY10: Appends product code (XXPROD) to KEY10.
    • MOVELXXCNTR KEY6 6: Moves container code (XXCNTR) to KEY6.
    • MOVE XXUNMS KEY6: Appends unit of measure (XXUNMS) to KEY6.
    • MOVELKEY10 KEY16 16: Moves KEY10 (customer + product) to KEY16.
    • MOVE KEY6 KEY16: Appends KEY6 (container + unit of measure) to KEY16.
    • MOVE KEY16 KEY18: Combines KEY16 into KEY18, creating a composite key (company + customer + product + container + unit of measure).
  14. C KEY18 CHAINPRCTUM 99:

    • Chains to PRCTUM using KEY18 to verify the record exists.
    • If not found (99 = 1), proceeds to container validation; otherwise, continues.
  15. Container Validation:

  16. C 99 XXCNTR CHAINGSCNTR1 98:
    • If the PRCTUM record is not found (99 = 1), chains to GSCNTR1 using XXCNTR (container code).
    • If the container is not found (98 = 1), skips further processing for the record.
  17. C 99N98 TCDES2 IFEQ DSC,1:
    • If the container is found (98 = 0) and the PRCTUM record is not found (99 = 1), checks if the container’s second description (TCDES2) matches DSC,1 ("BRAD PENN").
    • If true, writes an exception output (EXCPT) to NEWPROD and PRINTER, and sets indicator U2.
  18. C 99N98 TCDES2 IFEQ DSC,2:

    • Similarly, checks if TCDES2 matches DSC,2 ("DA LUBRICANTS").
    • If true, writes an exception output (EXCPT) to NEWPROD and PRINTER, and sets indicator U2.
  19. Output to Files:

  20. To NEWPROD (ONEWPROD EADD):
    • Writes a new record with:
    • XXCONO (company number) at positions 1-2.
    • XXLOC (location code) at positions 3-5.
    • XXPROD (product code) at positions 6-9.
    • XXCNTR (container code) at positions 10-12.
    • XXUNMS (unit of measure) at positions 13-15.
  21. To PRINTER (OPRINTER E):

    • Writes a report line with:
    • XXCONO at positions 1-5.
    • XXLOC at positions 6-10.
    • XXPRCL (price class) at positions 11-15.
    • XXPROD at positions 16-20.
    • XXDES1 (product description) at positions 21-55.
    • XXCNTR at positions 56-60.
    • XXUNMS at positions 61-65.
    • XXDATE at positions 66-78.
  22. Program Termination:

  23. The program continues processing RKPRCE records via the RPG cycle until all records are read.
  24. Jumps to the END tag for records that fail date validation or when processing completes.

Business Rules

The BB9563 program enforces the following business rules: 1. Date Validation: - Only processes RKPRCE records where the date (XXDATE) matches the user-provided date (KYDATE) converted to an 8-digit format (e.g., 20YYMMDD). 2. Customer and Product Validation: - Validates that the combination of company (XXCONO), customer (KYCUST), product (XXPROD), container (XXCNTR), and unit of measure (XXUNMS) does not exist in PRCTUM. If it exists (99 = 0), the record is skipped. 3. Container Validation: - For records not found in PRCTUM (99 = 1), validates the container code (XXCNTR) against GSCNTR1. - Only processes records where the container’s second description (TCDES2) matches either "BRAD PENN" or "DA LUBRICANTS" (from the DSC array). 4. Output Generation: - Writes valid records (those passing all validations) to NEWPROD with company, location, product, container, and unit of measure. - Generates a printed report (PRINTER) with additional details (price class, product description, and date). 5. Purpose: - Filters and validates rack pricing records to create a new pricing file (NEWPROD) and a report, ensuring only relevant records (non-existing in PRCTUM and matching specific container descriptions) are included.


Tables (Files) Used

The program interacts with the following files: 1. Input Files: - RKPRCE: Rack pricing file containing company number, location, price class, product code, description, container code, unit of measure, date, and time. - GSCNTR1: Container file containing container code, descriptions, type, freight table code, and unit of measure (replaced GSCNTR per revision). - PRCTUM: Customer master file containing company number, customer number, product code, container code, unit of measure, and delete flag. 2. Output Files: - NEWPROD: New pricing file containing company number, location, product code, container code, and unit of measure. - PRINTER: Printer file for generating a report with pricing details.


External Programs Called

The BB9563 program does not call any external programs. It performs all processing within its own logic using file I/O operations.


Summary

The BB9563 RPG program processes rack pricing data from RKPRCE, validates records against a user-provided date (KYDATE) and ensures the company/customer/product/container/unit of measure combination does not exist in PRCTUM. It further validates container codes against GSCNTR1, checking for specific descriptions ("BRAD PENN" or "DA LUBRICANTS"). Valid records are written to NEWPROD and a printed report is generated via PRINTER. The program uses files RKPRCE, GSCNTR1, PRCTUM, NEWPROD, and PRINTER, with no external program calls.