Skip to content

BB9542 RPG36

The provided document, BB9542.rpg36.txt, is an RPG (Report Program Generator) program for IBM System/3x or AS/400 systems, called by the OCL program BB954P.ocl36.txt. It is responsible for updating the rack pricing files (BBPRCE and PRCTUM) with new pricing data from DAPRCUP and generating a report via PRTDOWN. Below, I’ll explain the process steps, business rules, tables (files) used, and any external programs called.

Process Steps of the RPG Program

The RPG program BB9542 processes pricing updates for "DA Lubricants" by reading new pricing data from DAPRCUP, validating it against existing records in BBPRCEP and PRCTUM, updating the permanent pricing file (BBPRCE), and producing a report. Here’s a detailed breakdown of the process steps:

  1. File and Data Structure Definitions:
  2. Files:
    • DAPRCUP: Input file (69 bytes, sequential) containing new pricing data.
    • BBPRCEP: Input file (128 bytes, indexed) for existing rack pricing data.
    • PRCTUM: Update file (64 bytes, indexed) for customer master data.
    • BICONT: Input file (256 bytes, indexed) for company control data.
    • BBPRCE: Output file (128 bytes, sequential) for updated rack pricing data.
    • PRTDOWN: Output printer file (164 bytes) for generating a report.
  3. Arrays:
    • SEP: Array of 79 two-character separators (likely for formatting the report).
  4. Data Structures:
    • PRCKEY (27 bytes): Composite key for pricing records (DACONO, DALOC, DAPROD, DACNTR, DAUOFM, DADATE, DATIME).
    • CUSKEY (18 bytes): Composite key for customer records (CONO, CUSTNO, PROD, CNTR, UOFM).
    • UDS: User data structure for KYCUST (customer number) and KYPASS (password).
  5. OCL Syntax:

    1
    2
    3
    4
    5
    6
    FDAPRCUP IP  F  69  69            DISK
    FBBPRCEP IF  F 128 128 27AI     2 DISK
    FPRCTUM  UF  F  64  64 18AI     2 DISK                      A
    FBICONT  IF  F 256 256  2AI     2 DISK
    FBBPRCE  O   F 128 128            DISK                      A    U1
    FPRTDOWN O   F 164 164     OG     PRINTER
    

  6. Initialization (ONCE Logic):

  7. Executed once when ONCE is zero (first cycle).
  8. Steps:
    • Increments ONCE to 1 to prevent re-execution.
    • Captures system time (TIMDAT) and splits it into SYSTIM (time) and SYSDAT (date).
    • Initializes SEP with '* ' for report formatting.
    • Sets indicator 38 on (likely for report control).
    • Initializes variables ZERO6, ZERO8, ZERO9, ZERO3, ZERO7 to zero for calculations.
    • Sets CUSTNO to KYCUST (customer number from user input).
  9. OCL Syntax:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    C           ONCE      IFEQ *ZEROS
    C                     ADD  1         ONCE    10
    C                     TIME           TIMDAT 120
    C                     MOVELTIMDAT    SYSTIM  60
    C                     MOVE TIMDAT    SYSDAT  60
    C                     MOVEL'* '      SEP
    C                     SETON                         38
    C                     Z-ADD*ZEROS    ZERO6   60
    C                     Z-ADD*ZEROS    ZERO8   80
    C                     Z-ADD*ZEROS    ZERO9   90
    C                     Z-ADD*ZEROS    ZERO3   30
    C                     Z-ADD*ZEROS    ZERO7   70
    C                     Z-ADDKYCUST    CUSTNO
    C                     END
    

  10. Validate Company Number:

  11. Uses DACONO (company number from DAPRCUP) to perform a CHAIN on BICONT.
  12. If not found (indicator 91 on), clears BCNAME (company name) to blanks.
  13. Sets a default date (DATE) to 20791231 (possibly a placeholder for invalid records).
  14. OCL Syntax:

    1
    2
    3
    C           DACONO    CHAINBICONT               91
    C         91          MOVEL*BLANKS   BCNAME
    C                     MOVE 20791231  DATE
    

  15. Check for Prior Contract Price:

  16. Positions the file pointer in BBPRCEP using PRCKEY (composite key: company, location, product, container, unit of measure, date, time).
  17. Reads the previous record (READP) from BBPRCEP to find a matching prior price:
    • Compares DACONO, DALOC, DAPROD, DACNTR, and DAUOFM with RKCONO, RKLOC, RKPROD, RKCNTR, and RKUNMS.
    • If any field doesn’t match, jumps to NEXT to continue searching.
    • If a match is found, stores the prior price (RKPRCE) in PRVPRC.
  18. OCL Syntax:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    C           PRCKEY    SETLLBBPRCEP
    C           AGNB5     TAG
    C                     READPBBPRCEP                  10
    C  N10      DACONO    IFNE RKCONO
    C                     GOTO NEXT
    C                     END
    C  N10      DALOC     IFNE RKLOC
    C                     GOTO NEXT
    C                     END
    C  N10      DAPROD    IFNE RKPROD
    C                     GOTO NEXT
    C                     END
    C  N10      DACNTR    IFNE RKCNTR
    C                     GOTO NEXT
    C                     END
    C  N10      DAUOFM    IFNE RKUNMS
    C                     GOTO AGNB5
    C                     END
    C           NEXT      TAG
    C                     Z-ADDRKPRCE    PRVPRC  94
    

  19. Update Counters and Totals:

  20. Increments COUNT (record counter).
  21. Adds PRVPRC (prior price) to PRVPTL (prior price total).
  22. Adds DAPRIC (new price) to DAPRTL (new price total).
  23. OCL Syntax:

    1
    2
    3
    C                     ADD  1         COUNT   50
    C                     ADD  PRVPRC    PRVPTL  94
    C                     ADD  DAPRIC    DAPRTL  94
    

  24. Update PRCTUM File:

  25. Uses CUSKEY (company, customer, product, container, unit of measure) to perform a CHAIN on PRCTUM.
  26. If no record exists (indicator 99 on), adds a new record to PRCTUM with:
    • PCDEL = 'A' (active record).
    • DACONO (company number).
    • CUSTNO (customer number).
    • DAPROD (product code).
    • DACNTR (container code).
    • DAUOFM (unit of measure).
  27. OCL Syntax:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    C           CUSKEY    CHAINPRCTUM               99
    C   99                EXCPTADDPCU
    OPRCTUM  EADD             ADDPCU
    O                                    1 'A'
    O                         DACONO     3
    O                         CUSTNO     9
    O                         DAPROD    13
    O                         DACNTR    16
    O                         DAUOFM    19
    

  28. Update BBPRCE File (Conditional on Password):

  29. If the password (KYPASS) is 'CUSTPROD', adds a new record to BBPRCE with:
    • RKDEL = 'A' (active record).
    • DACONO (company number).
    • DALOC (location).
    • DAPROD (product code).
    • DACNTR (container code).
    • DAUOFM (unit of measure).
    • DADATE (date).
    • DATIME (time).
    • DAPRIC (new price).
    • Zero values for additional price fields (RKPR02, RKPR03, RKPR04, RKPR05) and quantity fields (RKMINQ, RKQT01RKQT05).
    • Hard-coded value '9999999' for a quantity field.
  30. OCL Syntax:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    C           KYPASS    IFEQ 'CUSTPROD'
    C                     EXCPTADDPRC
    C                     END
    OBBPRCE  EADD             ADDPRC
    O                                    1 'A'
    O                         DACONO     3
    O                         DALOC      6
    O                         DAPROD    10
    O                         DACNTR    13
    O                         DAUOFM    16
    O                         DADATE    24
    O                         DATIME    28
    O                         DAPRIC    34P
    O                         ZERO9     40P
    O                         ZERO9     46P
    O                         ZERO9     52P
    O                         ZERO9     58P
    O                         ZERO7     65
    O                                   72 '9999999'
    O                         ZERO7     79
    O                         ZERO7     86
    O                         ZERO7     93
    O                         ZERO7    100
    

  31. Generate Report (PRTDOWN):

  32. Outputs a report to PRTDOWN with headers and detail lines:
    • Headers (controlled by level indicators L1):
    • Company name (BCNAME), report title ("DA LUBRICANTS RACK PRICING EDIT/POST"), page number, system date (SYSDAT), time (SYSTIM), and separator (SEP).
    • Column headers: "CO", "LOC", "PROD", "CNTR", "UNIT OF MEASURE", "DATE", "TIME", "QTY RANGE", "NEW PRICE".
    • Detail Lines (indicator 01):
    • Company (DACONO), location (DALOC), product (DAPROD), container (DACNTR), unit of measure (DAUOFM), date (DADATE), time (DATIME), quantity description (DAQTDS), new price (DAPRICJ).
    • Totals (at last record, LR):
    • Total record count (COUNT) and total new price (DAPRTLJ).
  33. OCL Syntax:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    OPRTDOWN D  102   L1
    O       OR        OGNL1
    O                         BCNAME    30
    O                                   86 '* DA LUBRICANTS RACK PRI'
    O                   NU1             97 'CING EDIT *'
    O                    U1             97 'CING POST *'
    O                                  128 'PAGE'
    O                         PAGE  Z  132
    O        D  1     01
    O                         DACONO     3
    O                         DALOC     15
    O                         DAPROD    25
    O                         DACNTR    35
    O                         DAUOFM    45
    O                         DADATE    57 '    /  /  '
    O                         DATIME    65 '0 :  '
    O                         DAQTDS    80
    O                         DAPRICJ   95
    O        T 31     LR
    O                                   26 'TOTAL COUNT:'
    O                         COUNT Z   33
    O                         DAPRTLJ   95
    

  34. End of Processing:

  35. The program processes all records in DAPRCUP (primary file) via the RPG cycle until the end of the file, then terminates at the END tag.
  36. OCL Syntax:
    1
    C           END       TAG
    

Business Rules

The RPG program BB9542 enforces the following business rules:

  1. Company Validation:
  2. The company number (DACONO) must exist in BICONT. If not, BCNAME is cleared, but processing continues with a default date (20791231).

  3. Unique Pricing Records:

  4. Checks for existing pricing records in BBPRCEP using PRCKEY (company, location, product, container, unit of measure, date, time). If a prior record exists, its price (RKPRCE) is captured for reporting or comparison.

  5. Customer Record Creation:

  6. If a customer record does not exist in PRCTUM for the given CUSKEY (company, customer, product, container, unit of measure), a new record is added with PCDEL = 'A', ensuring the customer master file is updated.

  7. Password-Protected Price Updates:

  8. Updates to the permanent pricing file (BBPRCE) are only performed if the password (KYPASS) is 'CUSTPROD'. This restricts unauthorized updates to pricing data.

  9. Active Record Marking:

  10. New records in PRCTUM and BBPRCE are marked with PCDEL = 'A' and RKDEL = 'A', respectively, indicating active records.

  11. Default Values for Pricing Fields:

  12. Additional pricing fields (RKPR02RKPR05) and quantity fields (RKMINQ, RKQT01RKQT05) in BBPRCE are set to zero, with one quantity field hard-coded to '9999999'.

  13. Report Generation:

  14. A detailed report is generated for each pricing record, including company, location, product, container, unit of measure, date, time, quantity description, and new price.
  15. Totals for record count and new prices are included at the end of the report.

  16. Cumulative Totals:

  17. Tracks the total number of records processed (COUNT) and cumulative new (DAPRTL) and prior (PRVPTL) prices for reporting.

Tables (Files) Used

The RPG program uses the following files: 1. DAPRCUP: Input file (69 bytes, sequential) containing new pricing data (company, location, product, container, unit of measure, date, time, price, etc.). 2. BBPRCEP: Input file (128 bytes, indexed) containing existing rack pricing data for comparison. 3. PRCTUM: Update file (64 bytes, indexed) for customer master data, updated with new customer records. 4. BICONT: Input file (256 bytes, indexed) for company control data (e.g., company name). 5. BBPRCE: Output file (128 bytes, sequential) for updated rack pricing data. 6. PRTDOWN: Output printer file (164 bytes) for generating the pricing report.

External Programs Called

The RPG program BB9542 does not explicitly call any external programs. It is invoked by the OCL program BB954P.ocl36.txt as part of the pricing update workflow, following preprocessing by BB9541 and validation by BB954P.

Summary

The RPG program BB9542 is the final step in the rack pricing update process, responsible for: - Validating company numbers against BICONT. - Checking for prior prices in BBPRCEP. - Updating PRCTUM with new customer records if needed. - Updating BBPRCE with new pricing data if the password is 'CUSTPROD'. - Generating a detailed report via PRTDOWN with headers, detail lines, and totals. - Enforcing business rules for data validation, uniqueness, and restricted updates. - Using six files: DAPRCUP, BBPRCEP, PRCTUM, BICONT, BBPRCE, and PRTDOWN. - Not calling external programs but integrating with the OCL-driven workflow.

This program ensures that pricing updates are applied securely and accurately, with comprehensive reporting for auditing purposes.