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:
- File and Data Structure Definitions:
- 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 (replacedGSCNTRper 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.
- 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.
-
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.
-
Date Conversion:
C N09 KYDATE MULT 10000.01 DATYMD 60:- If indicator
09is off (initial run), multipliesKYDATE(6-digit date, e.g., YYMMDD) by 10000.01 to convert it to a 6-digit format (DATYMD).
- If indicator
C N09 MOVEL20 DATE8 80:- Moves 20 (likely century, e.g., 2000s) to the first two digits of
DATE8(8-digit date field).
- Moves 20 (likely century, e.g., 2000s) to the first two digits of
C N09 MOVE DATYMD DATE8:- Appends
DATYMDtoDATE8, creating an 8-digit date (e.g., 20YYMMDD).
- Appends
-
C N09 SETON 09:- Sets indicator
09to prevent reprocessing the date conversion in subsequent cycles.
- Sets indicator
-
Date Validation:
-
C 01 XXDATE IFNE DATE8:- For each
RKPRCErecord (indicator01set by the RPG cycle), compares the record’s date (XXDATE) to the converted date (DATE8). - If they are not equal, jumps to the
ENDtag, skipping the record. - If equal, continues processing.
- For each
-
Key Construction and Validation:
- Constructs keys for chaining:
MOVELXXCONO KEY18 18: Moves company number (XXCONO) toKEY18.MOVELKYCUST KEY10 10: Moves input customer number (KYCUST) toKEY10.MOVE XXPROD KEY10: Appends product code (XXPROD) toKEY10.MOVELXXCNTR KEY6 6: Moves container code (XXCNTR) toKEY6.MOVE XXUNMS KEY6: Appends unit of measure (XXUNMS) toKEY6.MOVELKEY10 KEY16 16: MovesKEY10(customer + product) toKEY16.MOVE KEY6 KEY16: AppendsKEY6(container + unit of measure) toKEY16.MOVE KEY16 KEY18: CombinesKEY16intoKEY18, creating a composite key (company + customer + product + container + unit of measure).
-
C KEY18 CHAINPRCTUM 99:- Chains to
PRCTUMusingKEY18to verify the record exists. - If not found (
99 = 1), proceeds to container validation; otherwise, continues.
- Chains to
-
Container Validation:
C 99 XXCNTR CHAINGSCNTR1 98:- If the
PRCTUMrecord is not found (99 = 1), chains toGSCNTR1usingXXCNTR(container code). - If the container is not found (
98 = 1), skips further processing for the record.
- If the
C 99N98 TCDES2 IFEQ DSC,1:- If the container is found (
98 = 0) and thePRCTUMrecord is not found (99 = 1), checks if the container’s second description (TCDES2) matchesDSC,1("BRAD PENN"). - If true, writes an exception output (
EXCPT) toNEWPRODandPRINTER, and sets indicatorU2.
- If the container is found (
-
C 99N98 TCDES2 IFEQ DSC,2:- Similarly, checks if
TCDES2matchesDSC,2("DA LUBRICANTS"). - If true, writes an exception output (
EXCPT) toNEWPRODandPRINTER, and sets indicatorU2.
- Similarly, checks if
-
Output to Files:
- 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.
-
To
PRINTER(OPRINTER E):- Writes a report line with:
XXCONOat positions 1-5.XXLOCat positions 6-10.XXPRCL(price class) at positions 11-15.XXPRODat positions 16-20.XXDES1(product description) at positions 21-55.XXCNTRat positions 56-60.XXUNMSat positions 61-65.XXDATEat positions 66-78.
-
Program Termination:
- The program continues processing
RKPRCErecords via the RPG cycle until all records are read. - Jumps to the
ENDtag 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.