BI944 RPG36
The RPG program BI944.rpg36
is an RPG/400 program invoked by the OCL program BI944.ocl36.txt
to generate the final Customer Sales Agreement Master File Listing. It processes sorted sales agreement records from BICUAGXX
, enriches them with data from multiple reference files, and produces printed reports (PRTDOWN
, PRTEXCEL
) and an optional output file (BICUAGC
) for CRM integration. The program includes revisions to handle container codes, freight codes, and other specific requirements. Below, I’ll explain the process steps, business rules, tables used, and any external programs called.
Process Steps of the RPG Program¶
The program reads records from BICUAGXX
, retrieves additional data from reference files, performs validations, and formats output for printing or CRM upload. The steps are as follows:
- File and Data Structure Initialization (F-specs and I-specs):
- Input Files:
BICUAGXX
(Primary Input, 263 bytes): Sorted sales agreement records fromBI9444
.BICONT
(Input, 256 bytes, indexed): Control file for company data.BBPRCY
(Input, 128 bytes, indexed): Pricing file.ARCUST
(Input, 384 bytes, indexed): Customer master file.GSTABL
(Input, 256 bytes, indexed): General system table for product class and other data.SHIPTO
(Input, 2048 bytes, indexed): Ship-to data.ARCUPR
(Input, 80 bytes, indexed): Customer pricing records.ARCUSP
(Input, 1344 bytes, indexed): Customer pricing supplemental data.INLOC
(Input, 512 bytes, indexed): Location file.BICUA7
(Input, 261 bytes, indexed): Indexed version of sales agreement data for previous price lookup.GSCTWT
(Input, 64 bytes, indexed): Weight table for gallon calculations.GSUMCV
(Input, 64 bytes, indexed): Unit of measure conversion table.GSCNTR1
(Input, 512 bytes, indexed): Container code table.GSPROD
(Input, 512 bytes, indexed): Product master file.
- Output Files:
BB203W
(Output, 327 bytes): Work file for storing new start dates and other data.PRTDOWN
(Output, 164 bytes, printer): Standard printed report.PRTEXCEL
(Output, 224 bytes, printer): Excel-compatible spreadsheet output.BICUAGC
(Output, 271 bytes, disk, conditioned byU3
): Output for CRM upload, updated hourly whenU3
is on.
- Arrays and Data Structures:
SEP
(79 elements, 2 bytes): Separator lines for report formatting.BAP
(10 elements, 4 bytes): Product codes (BAPR01
–BAPR10
).BAD
(10 elements, 10 bytes): Product descriptions.FLD
(28 elements, 1 byte): Field indicators.CTY
(26 elements, 1 byte): City codes.ST
(2 elements, 1 byte): State codes.DESC
(5 elements, 10 bytes): Freight descriptions (e.g., COLLECT, PPD & ADD).COM
(2 elements, 15 bytes): Division descriptions (e.g., REFINERY, BLENDED LUBES).ERR
(4 elements, 30 bytes): Error messages (e.g., NO PRODUCT CLASS LISTED).
-
Input Specifications:
BICUAGXX
: Defines fields likeBADEL
(delete code),BACONOL7
/CO
(company),BACUSTL2
/CUST
(customer),BALOC
(location),BAPR01L3
–BAPR10
(product codes),BASTDT
(start date),BASTTM
(start time),BAENDT
(end date),BAENTM
(end time),BAPRCE
(price, packed),BAOFFP
(off-price, packed),BAMNQY
(minimum quantity),BAMXQY
(maximum quantity),BAPPD
(prepaid flag),BAALSH
(apply to all ship-to),BAPRIM
(pricing method),BACNTR
(container code),BASTD8
(start date CYMD),BAEND8
(end date CYMD),BADELV
(delivery flag),BAFRCD
(freight code),BACRDT
(creation date),BACRTM
(creation time),BALUDT
(last update date),BALUTM
(last update time),BASHIPL1
/SHIP
(ship-to number),BACNT#
(contract number),BAUNMS
(unit of measure),BASEQN
(sequence number),BAPORD
(bill-to PO),BADIV
(division),BAPRCLL4
(product class),BAREC
(full record).ARCUST
: DefinesARNAME
(customer name),ARLSTN
(last name abbreviation).BICONT
: DefinesBCNAME
(company name),BCSEQN
(sequence number).SHIPTO
: DefinesCSDEL
(delete code),CSCO
(company),CSCUST
(customer),CSSHIP
(ship-to number),CSNAME
(ship-to name),CSADR1
–CSADR3
(address).
-
Main Processing Loop (C-specs, partially truncated):
- Record Processing (Indicator 01, primary file
BICUAGXX
):- Reads each record from
BICUAGXX
sequentially. - Performs lookups and validations to enrich the record with customer, ship-to, product, and pricing data.
- Reads each record from
- Customer Lookup:
- Chains to
ARCUST
usingBACUSTL2
to retrieveARNAME
(customer name).
- Chains to
- Ship-to Lookup:
- Chains to
SHIPTO
usingCSCO
(company) andBASHIPL1
(ship-to number) to retrieve ship-to details (CSNAME
,CSADR1
–CSADR3
). - If no ship-to record exists, sets an error message (e.g.,
ERR,3
orERR,4
).
- Chains to
- Product Class Lookup:
- Chains to
GSTABL
orGSPROD
(per JK02) usingBAPRCLL4
to retrieve product class description (PRCLDS
). - If not found, sets error message
ERR,1
(NO PRODUCT CLASS LISTED).
- Chains to
- Product Description Lookup:
- For each non-blank product code in
BAP
(1–10), chains toGSPROD
to retrieve product description (BAD
array). - If not found, sets error message
ERR,2
(BAD PRODUCT).
- For each non-blank product code in
- Previous Price Lookup (JB05, MG04):
- Chains to
BICUA7
(indexed sales agreement file) to retrieve previous price, considering container code (BACNTR
). - Attempts lookup with container type first, then with blank container type, and for non-fluid products, with
'P'
container type.
- Chains to
- Freight Code Handling (MG09, JB08, JB10):
- Uses
BAFRCD
fromBICUAGXX
for freight code/description (reversing JB08’s ship-to-based logic). - Maps
BAFRCD
to descriptions inDESC
array (e.g., C=COLLECT, P=PPD & ADD, D=DELIVERED, A=3RD PARTY). - For freight collect (
BAFRCD = 'C'
), handles special cases for non-Bradford locations (JB10).
- Uses
- Quantity Conversion (JB12):
- Chains to
GSCTWT
to retrieve gallons per container if available, bypassingGSUMCV
for gallon calculations. - If no
GSCTWT
record, usesGSUMCV
for unit of measure conversion.
- Chains to
- Container Code Lookup (JK01):
- Chains to
GSCNTR1
for container code (BACNTR
) details.
- Chains to
- Report Formatting:
- Writes headers to
PRTDOWN
andPRTEXCEL
with company name (BCNAME
), division (DIVNAM
), date (SYSDATY
), time (SYSTIM
), and selection criteria (KYINDC
,KYDLCH
,KYSTDT
). - Writes detail lines for each valid record, including product code (
BAP,1
), description (BAD,1
), customer number (BACUSTZ
), name (ARNAME
), ship-to (BASHIP
or'ALL'
), location (BALOC
), container code (BACNTR
), current price (BAPRCE
), previous price (PRVPRC
), freight terms (FRTDSC
,FRTDIF
), start date (STDT
), end date (ENDT
), minimum/maximum quantities (BAMNQY
,BAMXQY
), and new price if applicable (PRICE
).
- Writes headers to
- Output to
BB203W
:- Writes updated records with new start date (
KYSTDT
) per JB03.
- Writes updated records with new start date (
- Output to
BICUAGC
(MG05):- If indicator
U3
is on (hourly CRM update), writes records toBICUAGC
for CRM upload.
- If indicator
-
Total Count:
- Increments
COUNT
for each record processed and writes it to the report footer (T 31 LR
).
- Increments
-
Report Output:
- PRTDOWN (Standard Report):
- Includes headers with division, report type (add/update or report-only), date, time, and column headings (e.g., PROD CODE, DESC, CUST NO., NAME, SHIP TO, LOCATION, CNTR, PRICE, PREV PRICE, FREIGHT TERMS, STARTING DATE, ENDING DATE).
- Detail lines include product, customer, ship-to, pricing, freight, and date information.
- Footer includes total record count.
- PRTEXCEL (Spreadsheet Output):
- Similar to
PRTDOWN
but formatted for Excel, with additional fields like off-price (BAOFFP
), new price (PRICE
), and quantities.
- Similar to
- Error Handling:
- Outputs error messages (
ERR
array) for missing product classes, products, or ship-to records.
- Outputs error messages (
Business Rules¶
- Record Inclusion:
- Records with
BADEL = 'D'
(deleted) are skipped. -
Only valid records with matching customer, ship-to, product, and container data are included.
-
Customer and Ship-to Validation:
- Customer number (
BACUSTL2
) must exist inARCUST
to retrieveARNAME
. - Ship-to number (
BASHIPL1
) must exist inSHIPTO
unlessBAALSH = 'Y'
(apply to all ship-to), in which case'ALL'
is used. -
Missing ship-to records trigger
ERR,3
orERR,4
. -
Product and Product Class Validation (JK02):
- Product codes (
BAP,1
–BAP,10
) are validated againstGSPROD
for descriptions (BAD
). - Product class (
BAPRCLL4
) is validated againstGSTABL
orGSPROD
; missing classes triggerERR,1
. -
Invalid products trigger
ERR,2
. -
Previous Price Lookup (JB05, MG04):
- Chains to
BICUA7
using company, customer, product, and container code (BACNTR
). - Tries container type first, then blank, and
'P'
for non-fluid products. -
Previous price (
PRVPRC
) is included in the report if available. -
Freight Code Handling (MG09, JB08, JB10):
- Uses
BAFRCD
fromBICUAGXX
(C, P, D, A, or blank) to map toDESC
array (COLLECT, PPD & ADD, DELIVERED, 3RD PARTY). - Special handling for freight collect (
BAFRCD = 'C'
) from non-Bradford locations (JB10). -
Outputs freight description (
FRTDSC
) and difference (FRTDIF
if applicable). -
Quantity Conversion (JB12):
- Prefers
GSCTWT
for gallons per container if available; otherwise, usesGSUMCV
for unit of measure conversion (BAUNMS
). -
Minimum and maximum quantities (
BAMNQY
,BAMXQY
) are reported in gallons. -
Container Code Validation (JK01):
-
Container code (
BACNTR
) is validated againstGSCNTR1
. -
Report Conditions:
- Indicator 74 determines if the report is for add/update (
KYADDA = 'Y'
) or report-only. - Indicator 71 includes new price (
KYINDC
,KYDLCH
) and new start date (KYSTDT
) inPRTEXCEL
. -
Indicator 50 suppresses end date if zero (
'00/00/00'
). -
CRM Output (MG05):
- If
U3
is on, writes toBICUAGC
for hourly CRM upload, ensuringBICUA7
is in sync withBICUAGX
.
Tables (Files) Used¶
- BICUAGXX (Primary Input, 263 bytes):
- Fields:
BADEL
,BACONOL7
,BACUSTL2
,BALOC
,BAPR01L3
–BAPR10
,BASTDT
,BASTTM
,BAENDT
,BAENTM
,BAPRCE
,BAOFFP
,BAMNQY
,BAMXQY
,BAPPD
,BAALSH
,BAPRIM
,BACNTR
,BASTD8
,BAEND8
,BADELV
,BAFRCD
,BACRDT
,BACRTM
,BALUDT
,BALUTM
,BASHIPL1
,BACNT#
,BAUNMS
,BASEQN
,BAPORD
,BADIV
,BAPRCLL4
,BAREC
. - BICONT (Input, 256 bytes, indexed):
- Fields:
BCNAME
,BCSEQN
. - BBPRCY (Input, 128 bytes, indexed):
- Pricing data.
- ARCUST (Input, 384 bytes, indexed):
- Fields:
ARNAME
,ARLSTN
. - GSTABL (Input, 256 bytes, indexed):
- Product class and other reference data.
- SHIPTO (Input, 2048 bytes, indexed):
- Fields:
CSDEL
,CSCO
,CSCUST
,CSSHIP
,CSNAME
,CSADR1
–CSADR3
. - ARCUPR (Input, 80 bytes, indexed):
- Customer pricing data.
- ARCUSP (Input, 1344 bytes, indexed):
- Supplemental pricing data.
- INLOC (Input, 512 bytes, indexed):
- Location data.
- BICUA7 (Input, 261 bytes, indexed):
- Indexed sales agreement data for previous price lookup.
- GSCTWT (Input, 64 bytes, indexed):
- Weight table for gallon calculations.
- GSUMCV (Input, 64 bytes, indexed):
- Unit of measure conversion.
- GSCNTR1 (Input, 512 bytes, indexed):
- Container code data.
- GSPROD (Input, 512 bytes, indexed):
- Product master data.
- BB203W (Output, 327 bytes):
- Work file for new start dates and other data.
- PRTDOWN (Output, 164 bytes, printer):
- Standard report output.
- PRTEXCEL (Output, 224 bytes, printer):
- Excel-compatible report output.
- BICUAGC (Output, 271 bytes, disk,
U3
):- CRM upload file.
External Programs Called¶
The RPG program BI944
does not explicitly call any external programs via CALL
operations. It is invoked by the OCL program BI944.ocl36.txt
and processes data independently, relying on input from BICUAGXX
and reference files, producing outputs for printing and CRM integration.
Summary¶
- Process Steps:
- Read records from
BICUAGXX
. - Chain to
ARCUST
,SHIPTO
,GSPROD
,GSTABL
,GSCNTR1
,BICUA7
,GSCTWT
, andGSUMCV
for data enrichment. - Validate customer, ship-to, product, product class, and container code.
- Retrieve previous price from
BICUA7
with container type logic. - Map freight codes to descriptions, handling special cases.
- Convert quantities using
GSCTWT
orGSUMCV
. - Write formatted reports to
PRTDOWN
andPRTEXCEL
with headers, details, and totals. - Write to
BB203W
for new start dates andBICUAGC
for CRM ifU3
is on. -
Continue until end-of-file.
-
Business Rules:
- Skip deleted records (
BADEL = 'D'
). - Validate customer, ship-to, product, and product class data.
- Retrieve previous price with container type priority.
- Use
BAFRCD
for freight terms; handle non-Bradford freight collect cases. - Prefer
GSCTWT
for gallon calculations, else useGSUMCV
. - Format reports based on add/update or report-only mode.
-
Output to
BICUAGC
for CRM ifU3
is on. -
Tables Used:
- Input:
BICUAGXX
,BICONT
,BBPRCY
,ARCUST
,GSTABL
,SHIPTO
,ARCUPR
,ARCUSP
,INLOC
,BICUA7
,GSCTWT
,GSUMCV
,GSCNTR1
,GSPROD
. -
Output:
BB203W
,PRTDOWN
,PRTEXCEL
,BICUAGC
. -
External Programs Called:
- None directly called.
This program finalizes the Customer Sales Agreement Master File Listing, producing detailed reports and optional CRM output while enforcing strict validation and formatting rules. If you need further details or have additional files, please provide them.