Skip to content

BB9565 RPG36

The provided document is an RPG III (or RPG/36) program, BB9565.rpg36.txt, called conditionally from the OCL program BB9565.ocl36.txt when the condition at ?L'207,1'? is 'Y' in the main OCL program BB956P.ocl36.txt. This program is part of the rack pricing update process and is responsible for adding new pricing records from the NEWPROD file to the PRCTUM customer master file. Below is an explanation of the process steps, business rules, tables (files) used, and any external programs called.


Process Steps of the RPG Program BB9565

The BB9565 program reads records from the NEWPROD file, checks for duplicates in the PRCTUM file, and adds new records to PRCTUM if they do not already exist. Here’s a step-by-step breakdown of the process:

  1. File and Data Structure Definitions:
  2. Files:
    • NEWPROD: Input primary file (IP, 32 bytes, no key specified) containing new product or pricing data.
    • PRCTUM: Update file (UF, 64 bytes, 18-byte key, direct access) containing customer master data, with the ability to add new records (A).
  3. Data Structures:

    • NEWPROD Record Format:
    • XXCONO (positions 1-2): Company number.
    • XXLOC (positions 3-5): Location code.
    • XXPROD (positions 6-9): Product code.
    • XXCNTR (positions 10-12): Container code.
    • XXUNMS (positions 13-15): Unit of measure.
    • XXKEY2 (positions 6-15): Composite key (product + container + unit of measure).
    • PRCTUM Record Format:
    • 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.
    • UDS (User Data Structure):
    • KYDATE (positions 105-110): Date input.
    • KYMO (positions 105-106): Month portion of the date.
    • KYYR (positions 109-110): Year portion of the date.
    • KYCO (positions 114-115): Company number.
    • KYJOBQ (position 120): Job queue code.
    • KYCANC (positions 129-134): Cancel flag.
    • KYCUST (positions 201-206): Customer number.
    • Y2KCEN (positions 509-510): Century for Y2K handling (e.g., 19 for 1900s).
    • Y2KCMP (positions 511-512): Comparison year for Y2K logic (e.g., 80).
  4. Main Processing Logic:

  5. The program operates in the RPG fixed logic cycle for the primary file NEWPROD:
    • Reads each record from NEWPROD automatically when indicator 01 is on.
  6. For each NEWPROD record:

    • MOVELXXCONO KEY18 18: Moves the company number (XXCONO) to KEY18.
    • MOVELKYCUST KEY16 16: Moves the customer number (KYCUST) to KEY16.
    • MOVE XXKEY2 KEY16: Appends the composite key (XXKEY2: product + container + unit of measure) to KEY16.
    • MOVE KEY16 KEY18: Combines KEY16 into KEY18, creating a full key (company + customer + product + container + unit of measure).
    • C KEY18 CHAINPRCTUM 99: Chains to PRCTUM using KEY18 to check if a record with this key exists.
    • C 99 EXCPT: If no matching record is found (99 = 1), executes an exception output to add a new record to PRCTUM.
  7. Output to PRCTUM:

  8. OPRCTUM EADD:

    • Adds a new record to PRCTUM with:
    • Position 1: Hard-coded value 'A' (active/add flag, as opposed to 'D' for delete).
    • Positions 2-3: XXCONO (company number from NEWPROD).
    • Positions 4-9: KYCUST (customer number from UDS).
    • Positions 10-13: XXPROD (product code from NEWPROD).
    • Positions 14-16: XXCNTR (container code from NEWPROD).
    • Positions 17-19: XXUNMS (unit of measure from NEWPROD).
  9. Program Termination:

  10. The RPG cycle continues until all NEWPROD records are processed.
  11. The program ends when no more records are available in NEWPROD, marked by the END tag.

Business Rules

The BB9565 program enforces the following business rules: 1. Duplicate Check: - Checks if a record with the same company number (XXCONO), customer number (KYCUST), product code (XXPROD), container code (XXCNTR), and unit of measure (XXUNMS) already exists in PRCTUM. - If a matching record exists (99 = 0), the record is skipped to avoid duplicates. 2. Record Addition: - If no matching record is found (99 = 1), adds a new record to PRCTUM with an active flag ('A') and the relevant data from NEWPROD and KYCUST. 3. Purpose: - Integrates new pricing data from NEWPROD (generated by earlier programs like BB9563) into the PRCTUM customer master file, ensuring only non-duplicate records are added. 4. No Validation of Other Fields: - Does not explicitly validate KYDATE, KYCO, or other fields from UDS, suggesting these were validated in prior steps (e.g., BB956P).


Tables (Files) Used

The program interacts with the following files: 1. Input File: - NEWPROD: Contains new product or pricing data with fields: - XXCONO (positions 1-2): Company number. - XXLOC (positions 3-5): Location code. - XXPROD (positions 6-9): Product code. - XXCNTR (positions 10-12): Container code. - XXUNMS (positions 13-15): Unit of measure. - XXKEY2 (positions 6-15): Composite key (product + container + unit of measure). 2. Update/Output File: - PRCTUM: Customer master file containing: - PCDEL (position 1): Delete flag. - 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.


External Programs Called

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


Summary

The BB9565 RPG program reads new pricing data from NEWPROD, checks for duplicates in PRCTUM using a composite key (company, customer, product, container, and unit of measure), and adds non-duplicate records to PRCTUM with an active flag ('A'). It ensures that only new, unique pricing records are integrated into the customer master file. The program uses the NEWPROD and PRCTUM files, with no external program calls. It is a critical step in finalizing the rack pricing update process by updating the customer master file with validated pricing data.