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:
- File and Data Structure Definitions:
- 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.
- Arrays:
SEP
: Array of 79 two-character separators (likely for formatting the report).
- 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 forKYCUST
(customer number) andKYPASS
(password).
-
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
-
Initialization (ONCE Logic):
- Executed once when
ONCE
is zero (first cycle). - Steps:
- Increments
ONCE
to 1 to prevent re-execution. - Captures system time (
TIMDAT
) and splits it intoSYSTIM
(time) andSYSDAT
(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
toKYCUST
(customer number from user input).
- Increments
-
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
-
Validate Company Number:
- Uses
DACONO
(company number fromDAPRCUP
) to perform aCHAIN
onBICONT
. - If not found (indicator 91 on), clears
BCNAME
(company name) to blanks. - Sets a default date (
DATE
) to 20791231 (possibly a placeholder for invalid records). -
OCL Syntax:
1 2 3
C DACONO CHAINBICONT 91 C 91 MOVEL*BLANKS BCNAME C MOVE 20791231 DATE
-
Check for Prior Contract Price:
- Positions the file pointer in
BBPRCEP
usingPRCKEY
(composite key: company, location, product, container, unit of measure, date, time). - Reads the previous record (
READP
) fromBBPRCEP
to find a matching prior price:- Compares
DACONO
,DALOC
,DAPROD
,DACNTR
, andDAUOFM
withRKCONO
,RKLOC
,RKPROD
,RKCNTR
, andRKUNMS
. - If any field doesn’t match, jumps to
NEXT
to continue searching. - If a match is found, stores the prior price (
RKPRCE
) inPRVPRC
.
- Compares
-
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
-
Update Counters and Totals:
- Increments
COUNT
(record counter). - Adds
PRVPRC
(prior price) toPRVPTL
(prior price total). - Adds
DAPRIC
(new price) toDAPRTL
(new price total). -
OCL Syntax:
1 2 3
C ADD 1 COUNT 50 C ADD PRVPRC PRVPTL 94 C ADD DAPRIC DAPRTL 94
-
Update PRCTUM File:
- Uses
CUSKEY
(company, customer, product, container, unit of measure) to perform aCHAIN
onPRCTUM
. - 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).
-
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
-
Update BBPRCE File (Conditional on Password):
- If the password (
KYPASS
) is 'CUSTPROD', adds a new record toBBPRCE
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
,RKQT01
–RKQT05
). - Hard-coded value '9999999' for a quantity field.
-
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
-
Generate Report (PRTDOWN):
- 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
).
- Headers (controlled by level indicators
-
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
-
End of Processing:
- The program processes all records in
DAPRCUP
(primary file) via the RPG cycle until the end of the file, then terminates at theEND
tag. - OCL Syntax:
1
C END TAG
Business Rules¶
The RPG program BB9542
enforces the following business rules:
- Company Validation:
-
The company number (
DACONO
) must exist inBICONT
. If not,BCNAME
is cleared, but processing continues with a default date (20791231
). -
Unique Pricing Records:
-
Checks for existing pricing records in
BBPRCEP
usingPRCKEY
(company, location, product, container, unit of measure, date, time). If a prior record exists, its price (RKPRCE
) is captured for reporting or comparison. -
Customer Record Creation:
-
If a customer record does not exist in
PRCTUM
for the givenCUSKEY
(company, customer, product, container, unit of measure), a new record is added withPCDEL = 'A'
, ensuring the customer master file is updated. -
Password-Protected Price Updates:
-
Updates to the permanent pricing file (
BBPRCE
) are only performed if the password (KYPASS
) is 'CUSTPROD'. This restricts unauthorized updates to pricing data. -
Active Record Marking:
-
New records in
PRCTUM
andBBPRCE
are marked withPCDEL = 'A'
andRKDEL = 'A'
, respectively, indicating active records. -
Default Values for Pricing Fields:
-
Additional pricing fields (
RKPR02
–RKPR05
) and quantity fields (RKMINQ
,RKQT01
–RKQT05
) inBBPRCE
are set to zero, with one quantity field hard-coded to '9999999'. -
Report Generation:
- A detailed report is generated for each pricing record, including company, location, product, container, unit of measure, date, time, quantity description, and new price.
-
Totals for record count and new prices are included at the end of the report.
-
Cumulative Totals:
- 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.