SA505I RPG36
The provided document, SA505I.rpg36.txt
, is an RPG (Report Program Generator) program for the IBM System/36 environment (or AS/400 in compatibility mode), named SA505I
. It is invoked by the OCL script SA505I.ocl36.txt
within the PRICES.ocl36.txt
workflow, part of the PRICEGEN.clp
pricing generation process for blended lubes. The program processes the detailed sales and pricing data from SA505H
(TMPFILX
), enriches it with customer (ARCUST
), container (GSCNTR
), product (GSPROD
), and unit of measure conversion data, and writes results to the pricing file (PRSABLW
) for the Customer Shipping Analysis Report. It also calls an external program (MBBQTY
) to calculate quantities. Below, I will explain the process steps, business rules, tables used, and external programs called, despite the truncation in the document .
Process Steps of the RPG Program¶
- File Definitions:
- Input Files:
TMPFILX
(Input Primary,IP
, 110 bytes, disk): Detailed sales and pricing data fromSA505H
, mapped to?9?TMPFILX
, shared mode.GSCNTR
(Input,IF
, 512 bytes, indexed with 3-byte key, disk): Container master file, mapped to?9?GSCNTR
, shared mode.ARCUST
(Input,IF
, 384 bytes, indexed with 8-byte key, disk): Customer master file, mapped to?9?ARCUST
, shared mode.GSPROD
(Input,IF
, 512 bytes, indexed with 6-byte key, disk): Product master file, mapped to?9?GSPROD
, shared mode.
-
Output File:
PRSABLW
(Output,O
, 271 bytes, disk): Pricing file for blended lubes, mapped to?9?PRSABLW
, shared mode.
-
Input Specifications:
- TMPFILX (record type
NS 01
):BACONO
(1–2): Company number.BACUST
(3–8): Customer number.BAKEY
(1–8): Key field (company + customer).BAPR01
(9–12): Product code.BACNTR
(13–15): Container code.BAUNMS
(16–18): Unit of measure.BASTD8
(19–26): Start date (CYMD, CCYYMMDD).BASTTM
(29–32): Start time (HHMM).BAPRCE
(33–37, packed, 4 decimals): Price.QTSOLD
(38–42, packed, 4 decimals): Quantity sold (billing gallons).AMTSLD
(43–48, packed, 4 decimals): Sales amount.REC1
(1–110): Entire record for processing.
- ARCUST (record type
NS
):ARDEL
(1): Delete code.ARCO
(2–3): Company number.ARCUST
(4–9): Customer number.ARNAME
(10–39): Customer name.ARADR1
(40–69): Address line 1.ARADR2
(70–99): Address line 2.ARADR3
(100–129): Address line 3.ARADR4
(130–159): Address line 4.ARZIP5
(160–164): ZIP code (5 digits).ARZIP9
(165–168): ZIP + 4.ARZP14
(169–173): ZIP + 4 + 5.
- GSCNTR (record type
NS
):TCDEL
(1): Delete code.TCCNTR
(2–4): Container code.TCDESC
(14–43): Container description.
- GSPROD (record type
NS
):TPDEL
(1): Delete code.TPPROD
(2–5): Product code.TPDES1
(6–25): Product description.
-
User Data Structure (UDS) (inferred from
SA505C.ocl36.txt
and prior programs):KYFRDT
,KYTODT
: Date range filters (CYMD).KYDIV
,KYLOC1
–KYLOC5
,KYPC01
–KYPC10
,KYCT01
–KYCT05
,KYPD01
–KYPD10
: Filters for division, location, product class, container, and product.
-
Calculation Specifications (partially provided due to truncation):
- Initialization (implied, likely in
ONETIM
subroutine, similar toSA505H
):- Sets system date and time (
SYDATE
,TIMEOF
). - Converts
FRDT
,TODT
toKYFRDT
,KYTODT
(CYMD) for date filtering.
- Sets system date and time (
- Main Loop:
- Processes each
TMPFILX
record (01 DO
, implied). - Applies filters (e.g.,
KYFRDT
toKYTODT
,BACONO
,BACUST
,BAPR01
,BACNTR
,BAUNMS
).
- Processes each
- Chaining:
- Chains
ARCUST
usingBAKEY
(company + customer) to retrieveARNAME
, address, and ZIP code. - Chains
GSCNTR
usingBACNTR
to retrieveTCDESC
(container description). - Chains
GSPROD
usingBAPR01
to retrieveTPDES1
(product description).
- Chains
- Quantity Conversion:
- Initializes fields for quantity calculation:
MOVEL*BLANK Q@FLCD
: Clears fluid code.Z-ADD60 Q@TEMP
: Sets temperature to 60°F.Z-ADD*ZERO Q@GRAV
: Clears gravity.MOVEL*BLANK Q@VCF
: Clears volume correction factor.Z-ADD*ZERO Q@SQTY
,Q@GGAL
,Q@NGAL
,Q@6DFA
,Q@APFA
,Q@NLBS
,Q@SLBS
: Clears quantity, gross gallons, net gallons, and weight fields.CALL 'MBBQTY'
: Calls external programMBBQTY
with parameterQTPARM
to calculate quantities (e.g., convertingQTSOLD
to gallons or weights usingGSCTUM
,GSUMCV
,GSCTWT
).
-
Output:
- Writes to
PRSABLW
viaEADD
exception, populating fields with data fromTMPFILX
,ARCUST
,GSPROD
, and calculated values.
- Writes to
-
Output Specifications:
- PRSABLW (
EADD
, 271 bytes):BACONO
(1–2): Company number.- Position 3–5: Hardcoded
'001'
(possibly location or status code). BACUST
(6–11): Customer number.ARNAME
(12–41): Customer name.ARSTAT
(42–43): Customer status (fromARCUST
or derived).- Position 44–62: Hardcoded
'ALL'
(possibly for division or group). BAPR01
(63–66): Product code.TPDES1
(67–76): Product description.BAUNMS
(77–79): Unit of measure.BACNTR
(80–82): Container code.BAPRCE
(83–87, packed): Price.ZERO94
(88–92, packed): Zeroed field (previous price or placeholder).BASTD8
(93–110): Start date (CYMD).- Position 111–118: Hardcoded
'20791231'
(end date, far future). ZERO7
(119–122, packed): Zeroed minimum quantity.ZERO7
(123–126, packed): Zeroed maximum quantity.ZERO94
(127–131, packed): Zeroed offset price.BASTTM
(132–135): Start time (HHMM).- Position 136–139: Hardcoded
'2359'
(end time, 23:59). - Position 140: Hardcoded
'Y'
(PPD flag). - Position 141–172: Hardcoded
'0000000000000000000000000000'
(filler or flags). CAGAPR
(188–192, packed): Calculated price or margin (fromMBBQTY
or prior logic).ZERO5
(193–195, packed): Zeroed route type.ZERO5
(196–198, packed): Zeroed ship type.QTSOLD
(199–203, packed): Quantity sold.AMTSLD
(204–209, packed): Sales amount.- Position 210: Hardcoded
'R'
(record type or status).
Business Rules¶
- Purpose: Processes
TMPFILX
data fromSA505H
, enriches it with customer, container, and product details, performs quantity conversions usingMBBQTY
, and writes results toPRSABLW
for the Customer Shipping Analysis Report. - Data Enrichment:
- Retrieves customer details (
ARNAME
, address, ZIP) fromARCUST
. - Retrieves container description (
TCDESC
) fromGSCNTR
. - Retrieves product description (
TPDES1
) fromGSPROD
. - Uses
GSCTUM
,GSUMCV
, andGSCTWT
(viaMBBQTY
) to convert quantities (QTSOLD
) to gallons or weights. - Filtering:
- Applies date range filters (
KYFRDT
toKYTODT
, compared toBASTD8
). - Uses UDS filters (from
SA505C.ocl36.txt
): division (KYDIV
), locations (KYLOC1
–KYLOC5
), product classes (KYPC01
–KYPC10
), containers (KYCT01
–KYCT05
), products (KYPD01
–KYPD10
). - Output:
- Writes to
PRSABLW
with enriched data, hardcoded defaults (e.g., end date'20791231'
,'Y'
for PPD), and calculated quantities/sales. - Hardcodes
'R'
as record type, indicating a specific report or pricing status. - Quantity Conversion:
- Calls
MBBQTY
to convertQTSOLD
(billing gallons) to other units (e.g., gross/net gallons, pounds) usingQ@TEMP
(60°F), clearing gravity (Q@GRAV
) and volume correction factor (Q@VCF
). - Context: Follows
SA505H
in thePRICES.ocl36.txt
workflow, finalizing data for the Customer Shipping Analysis Report by updatingPRSABLW
, complementing rack pricing (BB953B
) and blended lubes pricing (BI942E
).
Tables (Files) Used¶
- TMPFILX (
?9?TMPFILX
): - Access: Input Primary (
IP
), shared mode. - Purpose: Detailed sales and pricing data from
SA505H
. - GSCNTR (
?9?GSCNTR
): - Access: Input (
IF
), shared mode, indexed. - Purpose: Container descriptions (
TCDESC
). - ARCUST (
?9?ARCUST
): - Access: Input (
IF
), shared mode, indexed. - Purpose: Customer details (
ARNAME
, address, ZIP). - GSPROD (
?9?GSPROD
): - Access: Input (
IF
), shared mode, indexed. - Purpose: Product descriptions (
TPDES1
). - PRSABLW (
?9?PRSABLW
): - Access: Output (
O
), shared mode. - Purpose: Pricing file updated with enriched data.
- GSCTUM (
?9?GSCTUM
): - Access: Input, shared mode (from OCL, not in RPG).
- Purpose: Unit of measure conversion data (used by
MBBQTY
). - GSCTWT (
?9?GSCTWT
): - Access: Input, shared mode (from OCL, not in RPG).
- Purpose: Container weight data (used by
MBBQTY
). - GSUMCV (
?9?GSUMCV
): - Access: Input, shared mode (from OCL, not in RPG).
- Purpose: Unit of measure conversion table (used by
MBBQTY
).
External Programs Called¶
- MBBQTY: External program called to calculate quantities (e.g., converting
QTSOLD
to gallons or weights) usingQTPARM
parameter, leveragingGSCTUM
,GSUMCV
, andGSCTWT
.
Additional Notes¶
- Context: Invoked by
SA505I.ocl36.txt
afterSA505H
, processing?9?TMPFILX
to produce enriched pricing data in?9?PRSABLW
, part of the Customer Shipping Analysis Report workflow. - System/36 Environment: Uses RPG II/III syntax, likely on AS/400.
- Truncation: The document is truncated, but key sections (
F
,I
,C
,O
) provide sufficient detail. Missing calculations likely involve chaining and filtering logic. - Error Handling: Uses chaining indicators (not shown) and relies on System/36 for file errors.
- Output: Updates
PRSABLW
with comprehensive data, suitable for reporting or further processing (e.g., bySA505J
,SA505L
).
If you have the RPG source code for SA505E
, SA505J
, or SA505L
, or need further analysis, please provide those details! Let me know if you have additional questions or files to share.