BI9413 RPG36
The provided RPG program, BI9413.rpg36.txt, is an RPG III program for IBM System/36 or AS/400, invoked by the BI941.ocl36 OCL program. Its primary purpose is to preprocess the customer sales agreement work file (BICUAG) by updating records with zero ending dates to a default date (123179, i.e., December 31, 1979) and filtering records based on user-specified criteria, such as brand name, product class, group, inventory group, and bill-to PO. The processed records are written to an output file (BICUAGO). Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the BI9413 RPG Program¶
The program reads records from the BICUAG file, applies filtering logic based on user inputs, updates ending dates if necessary, and writes valid records to the BICUAGO file. Here’s a detailed breakdown of the process steps:
- File and Data Structure Definitions (Lines 0002–0037):
- Header (H) Specification:
064: Likely a program option or parameter.- Program name:
BI9413.
- File Specifications (F):
BICUAG: Primary input file (256 bytes, disk) containing customer agreement data.GSCNTR1: Input file (512 bytes, indexed, 3-byte key, 5 access paths) for container data (replacedGSCNTRper comment).GSPROD: Input file (512 bytes, indexed, 6-byte key, 8 access paths) for product data.BICUAGO: Update file (256 bytes, indexed, 11-byte key, external key) for outputting processed records.
- Input Specifications (I):
BICUAG:- Fields:
BACONO(company number),BACUST(customer number),BAPR01(product code),BAENDT(end date, YMD),BAEND8(end date, CYMD),BASEQN(sequence number),BACNTR(container code),BAPORD(bill-to PO),RECORD(entire 256-byte record). GSCNTR1:- Fields:
TCDEL(deletion flag),TCCNTR(container code),TCCNTA(alpha container code),TCDESC(description),TCDSCS(short description),TCDSCL(long description),TCCNTY(container type),TCFRTB(freight table code),TCDES2(second description),TCCTRS(container source),TCIUM(IMS unit of measure). GSPROD:- Fields:
TPDEL(deletion flag),TPCONO(company number),TPPROD(product code),TPDESC(description),TPDES1(complete description),TPDES2(abbreviated description),TPPRCL(product class code),TPPRGP(product group code),TPINGP(inventory group code), and others (e.g., STCC code, price list group). UDS(User Data Structure):- Fields:
KYCO1(company number),KYBRND(brand name),KYENDT(ending date),KYPORD(exclude PO pricing flag),KYCLCD(product class),KYGRCD(product group),KYIVGR(inventory group).
-
Comment:
JK01(02/24/16): Indicates a modification to useGSCNTR1instead ofGSCNTRfor alpha key support.
-
Calculation Specifications (C) (Lines 0013–0015):
- Initialization:
SETOF 509899andSETOF 9896: Clear indicators 50, 98, 99, and 96 to reset program state.
- Processing Loop (for each
BICUAGrecord, record format01):- End Date Check:
- If
BAENDT(YMD end date) is zero:- Set indicator 50 to flag the record for date update.
- Brand Name Filtering:
- If
KYBRND(brand name) is non-blank:- Chain
BACNTR(container code) toGSCNTR1. - If not found (indicator 98 on), skip to
END. - If
TCDES2(second description inGSCNTR1) does not matchKYBRND, skip toEND.
- Chain
- Bill-to PO Filtering:
- If
KYPORDisY(exclude PO pricing):- If
BAPORD(bill-to PO) is non-blank, skip toEND.
- If
- End Date Validation:
- If
BAEND8(CYMD end date) andKYENDT(user-specified end date) are non-zero:- Convert
KYENDTto YMD format (KYYMD = KYENDT * 10000.01). - Set
KYEND8to century20plusKYYMD. - If
BAEND8is less than or equal toKYEND8, skip toEND.
- Convert
- Product Validation:
- Chain
BACONO(company) andBAPR01(product code) toGSPRODusingKEY6. - If not found (indicator 96 on), proceed to checks; otherwise, use
GSPRODdata. - Product Class Check:
- If
KYCLCDis non-blank and does not matchTPPRCL(product class inGSPROD), skip toEND.
- If
- Product Group Check:
- If
KYGRCDis non-blank and does not matchTPPRGP(product group inGSPROD), skip toEND.
- If
- Inventory Group Check:
- If
KYIVGRis non-blank and does not matchTPINGP(inventory group inGSPROD), skip toEND.
- If
- Write to Output File:
- Chain
BACONOandBASEQNtoBICUAGOusingBAKEY(11-byte key) to check for existing records. - If not found (indicator 99 on), write the record to
BICUAGO:- Write the entire
RECORD(256 bytes). - If indicator 50 is on (zero end date), set
BAENDTto791231(December 31, 1979) andBAEND8to20791231(CYMD equivalent).
- Write the entire
-
End Processing:
- Jump to
ENDtag if any filtering condition fails. - Loop continues for the next
BICUAGrecord.
- Jump to
-
Output Specifications (O) (Lines 0016–0017):
-
Output to
BICUAGO:- Record format
DADD(add record) is used when indicator 99 is on (record not found inBICUAGO). - Outputs the entire
RECORD(256 bytes). - If indicator 50 is on, updates:
- Position 70 (6 bytes) to
791231(YMD end date). - Position 133 (8 bytes) to
20791231(CYMD end date).
- Record format
-
Program Termination:
- The program ends after processing all
BICUAGrecords, with valid records written toBICUAGO.
Business Rules¶
- Zero Ending Date Handling:
- Records with
BAENDT(YMD end date) of000000are updated to791231(December 31, 1979). -
Corresponding
BAEND8(CYMD end date) is set to20791231. -
Brand Name Filtering:
-
If a brand name (
KYBRND) is specified, only include records where the container code (BACNTR) exists inGSCNTR1and its second description (TCDES2) matchesKYBRND. -
Bill-to PO Filtering:
-
If
KYPORDisY(exclude PO pricing), exclude records with a non-blank bill-to PO (BAPORD). -
End Date Filtering:
-
If both
BAEND8(record end date) andKYENDT(user-specified end date) are non-zero, compare them:- Convert
KYENDTto CYMD format (KYEND8) with century20. - Exclude records where
BAEND8is less than or equal toKYEND8(i.e., expired agreements).
- Convert
-
Product Filtering:
- Validate product code (
BAPR01) againstGSPRODusing company number (BACONO). - If product class (
KYCLCD), product group (KYGRCD), or inventory group (KYIVGR) is specified, ensure they matchTPPRCL,TPPRGP, orTPINGPinGSPROD, respectively. -
Exclude records that do not match specified product criteria.
-
Output Record Writing:
- Only write records to
BICUAGOif they pass all filtering conditions and do not already exist (based onBACONOandBASEQN).
Tables Used¶
The program uses the following files/tables:
1. BICUAG:
- Primary input file containing customer agreement data.
- Fields: BACONO (company), BACUST (customer), BAPR01 (product code), BAENDT (end date YMD), BAEND8 (end date CYMD), BASEQN (sequence number), BACNTR (container code), BAPORD (bill-to PO).
2. BICUAGO:
- Output file for processed and filtered agreement records.
- Same structure as BICUAG, with updates to BAENDT and BAEND8 for zero dates.
3. GSCNTR1:
- Container file used to validate brand names.
- Fields: TCDEL (deletion flag), TCCNTR (container code), TCCNTA (alpha container code), TCDES2 (second description for brand name).
4. GSPROD:
- Product file used to validate product class, group, and inventory group.
- Fields: TPDEL (deletion flag), TPCONO (company), TPPROD (product code), TPPRCL (product class), TPPRGP (product group), TPINGP (inventory group).
External Programs Called¶
- None:
- The
BI9413program does not call any external programs. It performs all processing internally, reading fromBICUAG,GSCNTR1, andGSPROD, and writing toBICUAGO.
Summary¶
- Process Steps:
- Define input files (
BICUAG,GSCNTR1,GSPROD) and output file (BICUAGO). - For each
BICUAGrecord:- Check if
BAENDTis zero and flag for date update (indicator 50). - Filter by brand name (
KYBRND) usingGSCNTR1. - Filter by bill-to PO (
KYPORDandBAPORD). - Filter by end date (
BAEND8vs.KYENDT). - Validate product class (
KYCLCD), group (KYGRCD), and inventory group (KYIVGR) usingGSPROD. - Write valid records to
BICUAGO, updating zero end dates to791231/20791231.
- Check if
-
Terminate after processing all records.
-
Business Rules:
- Update zero end dates to
791231/20791231. - Filter records by brand name, bill-to PO, end date, product class, product group, and inventory group.
-
Only write non-duplicate records to
BICUAGO. -
Tables Used:
-
BICUAG,BICUAGO,GSCNTR1,GSPROD. -
External Programs Called:
- None.
This program serves as a preprocessing step to clean and filter customer agreement data before further sorting and reporting in the BI941 workflow.