BB9433 RPGLE
The provided document is an RPGLE program named BB9433, called from the OCL procedure BB943INQ.ocl36.txt and referenced by the BB943 program in the IBM System/36 (or AS/400 compatibility mode) environment. This program, titled "Copy/Update Sales Agreements," is designed to copy or update customer sales agreement records in the bicuag file, including handling expiration of original records and logging to the history file (bicuagh). Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code, the OCL context, and its integration with BB943, BB943P, and BB943V.
Process Steps of the RPGLE Program¶
The BB9433 program is a backend module that processes the addition or updating of customer sales agreement records, including copying agreements to other locations, ship-tos, or customer-ship-to combinations, and managing expiration of original records. It receives a comprehensive parameter list from BB943 and operates in either add or update mode. Due to the truncation of the source code (7,596 characters), some logic is incomplete, but I’ll reconstruct the process steps based on the available code and context.
- Initialization (
*inzsrSubroutine): - Receive Parameters: The program accepts three parameters via the
*ENTRYplist:parmlist: A data structure containing fields for the sales agreement, including:p$cono(company number).p$cust(customer number).p$loc(location).p$cntr(container code).p$unms(unit of measure).p$alsh(all ship-tos flag,'Y'or'N').p$ship(ship-to number).p$pr01–p$pr10(product codes, up to 10).p$pord(bill-to purchase order).p$expr(expire flag,'Y'for expiring original record).p$prce(price, 9.4 packed, perjk05).p$offp(off-price, 9.4 packed, perjk05).p$frcd(freight code).p$delv(delivery code).p$ppd(prepaid flag,'P'or blank).p$prim(pricing type,'I'or'M').p$mnqy(minimum quantity).p$mxqy(maximum quantity).p$locs(array of other locations, 30 bytes).p$shp(array of other ship-tos, 30 bytes).p$cshp(array of other customer-ship-to combinations, 36 bytes).p$seqn(sequence number).p$std8(start date, CCYYMMDD).p$sttm(start time).p$end8(end date, CCYYMMDD).p$entm(end time).p$addupd(add or update flag).p$dateflag(date flag, 2 bytes).o@cono,o@cust,o@loc,o@cntr,o@unms,o@ship,o@pr01–o@pr10,o@pord,o@std8,o@sttm,o@mnqy,o@mxqy(original key fields for expiring records).p$cntn(contract number, perjk04).p$poor(PO/order code, perjk04).p$fgrp: File group ('G'or'Z') for file overrides.p$flag: Return flag (1 character, e.g.,'1'for success,'0'for failure).
- Set System Information: Retrieves system data via the
psda##program status data structure (e.g.,pgmq##for program name,jbuserfor user,jbdt##for job date). - Set Current Date/Time: Uses the
TIMEoperation to populatet#timeand converts it tot#cymd(CCYYMMDD) andt#hms(HHMMSS) for history record timestamps. - Move Arrays: Transfers
p$locs,p$shp, andp$cshpto work arraysloc,shp, andcshpfor processing other locations, ship-tos, and customer-ship-to combinations. - Open Database Tables: Calls
opntblto apply file overrides and open files. -
Define Key Lists:
klcuag: For accessingbicuagwithp$conoandp$seqn.newkey: For new records withp$conoandw$sq(work sequence number).klcua3: For checking existing agreements inbicua3with original key fields (o@cono,w$cust,w$loc,o@cntr,o@unms,w$ship,o@pr01–o@pr10,o@pord,o@mnqy,o@mxqy,o@std8,o@sttm,p$frcd).
-
Open Database Tables (
opntblSubroutine): - File Overrides: Applies overrides based on
p$fgrp('G'or'Z') usingovgorovzarrays (e.g.,ovrdbf file(bicuag) tofile(*libl/gbicuag)for'G'). Executes overrides withQCMDEXC. - Open Files: Opens the following files with
usropn:bicont(company file, update/input, keyed).bicuag(sales agreement file, update/add/input, keyed).bicua3(sales agreement logical file, update/input, keyed, renamed record formatbicuagpftobicuagf3, perjk03).bicuagh(sales agreement history file, output-only, keyed).
-
Purpose: Ensures access to the correct file library (
GorZ) for data operations. -
Process Other Locations (
locArray): - Check
locArray: Ifchkloc(overlay oflocarray) is not blank, sets*IN60to*ONto indicate data in the location array. - Loop Through
loc: For each non-blank entry inloc(up to 10 elements):- Sets
w@locto the current location (loc(z)). - Sets
w@custtop$custandw@shiptop$ship. - Calls
writercdto write or update a sales agreement record for the location.
- Sets
-
Clear Indicator: Resets
*IN60to*OFFafter processing. -
Process Other Ship-tos (
shpArray): - Check
shpArray: Ifchkshp(overlay ofshparray) is not blank, sets*IN61to*ON. - Loop Through
shp: For each non-blank entry inshp(up to 10 elements):- Sets
w@shipto the current ship-to (shp(y)). - Sets
w@custtop$custandw@loctop$loc. - Calls
writercdto write or update a sales agreement record for the ship-to.
- Sets
-
Clear Indicator: Resets
*IN61to*OFFafter processing. -
Process Other Customer-Ship-to Combinations (
cshpArray): - Check
cshpArray: Ifchkcshp(overlay ofcshparray) is not blank, sets*IN62to*ON. - Loop Through
cshp: For each non-blank entry incshp(up to 4 elements):- Extracts customer (
dscust) and ship-to (dsship) fromdscstshp. - Sets
w@custtodscust,w@shiptodsship, andw@loctop$loc. - Calls
writercdto write or update a sales agreement record for the customer-ship-to combination.
- Extracts customer (
-
Clear Indicator: Resets
*IN62to*OFFafter processing. -
Write/Update Record (
writercdSubroutine): - Populate
bicuagFields: Maps input parameters tobicuagrecord fields:bacono = p$cono,bacust = p$cust,baloc = w@loc,bacntr = p$cntr,baunms = p$unms,baship = w@ship.- Product codes:
bapr01–bapr10=p$pr01–p$pr10. - Dates:
bastd8 = p$std8,bastdt = p$std8(with flag'1'),basttm = p$sttm,baend8 = p$end8,baendt = p$end8(with flag'1'),baentm = p$entm. - Other fields:
bapord = p$pord,baalsh = p$alsh,baprce = p$prce,baoffp = p$offp,bafrcd = p$frcd,badelv = p$delv,bappd = p$ppd,baprim = p$prim,bamnqy = p$mnqy,bamxqy = p$mxqy,bacntn = p$cntn,bapoor = p$poor.
-
Write/Update Logic (Truncated):
- Likely checks if the record exists using
klcuagornewkeyand updates (UPDATE) or writes (WRITE) tobicuag. - If
p$expr = 'Y', expires the original record usingklcua3by setting its end date/time and writing tobicuagh(perjk04). - Uses
wkcuag(external data structure) andsvcuag(256-byte save data structure) to hold record data during processing.
- Likely checks if the record exists using
-
Write to History File (
writehistSubroutine): - Clear History Record: Clears the
bicuaghpfrecord format. - Populate History Fields: Maps
bicuagfields tobicuaghfields (e.g.,hhcono = bacono,hhdel = badelperjk02,hhcust = bacust, etc.). - Add Audit Fields:
- Sets
hhchd8 = t#cymd(current date) andhhchtm = t#hms(current time). - Sets
hhuser = jbuser8(user ID, 8 characters).
- Sets
-
Write Record: Writes to
bicuaghusingWRITE bicuaghpf. -
Program Termination (Truncated):
- Likely closes all files (
close *all) and sets*inlr = *onto terminate. - Returns
p$flagto indicate success ('1') or failure ('0') toBB943.
Business Rules¶
The program enforces the following business rules for copying or updating sales agreements:
- Add vs. Update Mode:
- Controlled by
p$addupd:'A'(add): Creates new records inbicuagfor the primary key and any additional locations (p$locs), ship-tos (p$shp), or customer-ship-to combinations (p$cshp).'U'(update): Updates existing records based onp$seqn.
-
Indicators
*IN60,*IN61, and*IN62track whetherloc,shp, orcshparrays contain data. -
Copy to Other Locations/Ship-tos/Customer-Ship-tos:
- Processes
p$locs(other locations),p$shp(other ship-tos), andp$cshp(other customer-ship-to combinations) to create multiple agreement records with varyingbaloc,baship, orbacust/bashipcombinations. -
Ensures no duplicate agreements exist (validated by
BB943Vbefore callingBB9433). -
Expiration Handling (per
jk04): - If
p$expr = 'Y', expires the original record (identified byo@cono,o@cust,o@loc,o@cntr,o@unms,o@ship,o@pr01–o@pr10,o@pord,o@std8,o@sttm,o@mnqy,o@mxqy) only if:- Its expiration date (
baend8) is greater than the new record’s start date (p$std8) or is zero.
- Its expiration date (
-
Writes expired records to
bicuaghwith audit fields (hhchd8,hhchtm,hhuser). -
Duplicate Start Dates (per
jk01): -
Allows identical start dates (
p$std8,p$sttm) if freight codes (p$frcd) differ. -
Price and Quantity Fields (per
jk05): p$prceandp$offpare stored as 9.4 packed decimal inbaprceandbaoffp.-
p$mnqyandp$mxqyare stored inbamnqyandbamxqy(added perjk03). -
Contract Number and PO/Order Code (per
jk04): - Stores
p$cntninbacntn(contract number). -
Stores
p$poorinbapoor(PO or order code). -
History Logging:
- Writes expired or modified records to
bicuaghwith current date/time (hhchd8,hhchtm) and user (hhuser). -
Transfers deletion flag (
badeltohhdel, perjk02). -
Validation:
- Relies on
BB943Vfor input validation before processing. Ensures fields likep$cono,p$cust,p$loc,p$cntr,p$pr01–p$pr10, etc., are valid.
Tables Used¶
The program uses the following files, as defined in the File Specification (F-spec) section:
- bicuag: Primary sales agreement file, update/add/input, keyed.
- bicont: Company file, update/input, keyed.
- bicua3: Sales agreement logical file (replaced
bicua2perjk03), update/input, keyed, with renamed record format (bicuagpftobicuagf3). - bicuagh: Sales agreement history file, output-only, keyed.
File Overrides:
- The ovg and ovz arrays specify overrides for file groups 'G' and 'Z', mapping files to libraries (e.g., gbicuag, zbicuagh).
External Programs Called¶
The program explicitly calls one external program:
- QCMDEXC:
- Called in the
opntblsubroutine to execute file override commands. - Parameters:
dbov##(override command string, 80 bytes),dbol##(length, 15.5).
Implied Program:
- GSDTCLC1: Implied by the pldtclc1 PLIST for date addition/subtraction, used for date calculations (e.g., expiration date adjustments). Parameters: p#dat1, p#dat2, p#fmt, p#diff, p#err.
Summary¶
- Process Steps:
- Initialize by receiving
parmlist,p$fgrp, andp$flag, setting date/time, and moving arrays (loc,shp,cshp). - Apply file overrides and open files (
opntbl). - Process
locarray to create/update agreements for other locations (*IN60). - Process
shparray for other ship-tos (*IN61). - Process
cshparray for other customer-ship-to combinations (*IN62). - Write/update records in
bicuagusingwritercd, mapping parameters to file fields. - Write expired records to
bicuaghwith audit fields (writehist). -
Terminate, returning
p$flag(success/failure). -
Business Rules:
- Supports add (
'A') and update ('U') modes viap$addupd. - Copies agreements to other locations, ship-tos, or customer-ship-to combinations.
- Expires original records if
p$expr = 'Y'and expiration conditions are met (perjk04). - Allows identical start dates if freight codes differ (per
jk01). - Logs expired/modified records to
bicuaghwith audit fields. - Uses expanded price fields (
baprce,baoffp, perjk05) and quantity fields (bamnqy,bamxqy, perjk03). -
Stores contract number (
bacntn) and PO/order code (bapoor, perjk04). -
Tables Used:
-
bicuag,bicont,bicua3,bicuagh. -
External Programs Called:
QCMDEXC(for file overrides).GSDTCLC1(implied for date calculations).
Due to the truncation of the source code, details of the main processing loop and parts of the writercd subroutine are incomplete. If you can provide the complete BB9433.rpgle code or specific sections (e.g., full writercd logic), I can refine the process steps and business rules further. Additionally, if you have related files (e.g., BB943 full source, display file bb943d, or GSDTCLC1), I can provide more context. Let me know how you’d like to proceed!