AR822 RPGLE
The AR822R.rpgle.txt RPG program, written in RPG/36 (or early RPG IV) for the IBM System/36 or AS/400, is designed for Price Lookup for Customer Service Representatives (CSR). It is called by the AR820.ocl36.txt OCL program and retrieves pricing information based on customer, product, container, and company inputs, displaying results in subfiles on a workstation screen. Below is a detailed explanation of the process steps, business rules, tables/files used, and external programs called.
Process Steps of the RPG Program¶
The program operates in a loop, processing user input and displaying pricing data in multiple subfiles (SFLC1, SFLC2, SFLC3, SFLC4) for different pricing scenarios (e.g., sales agreements, rack pricing, or no pricing). It handles input validation, retrieves data from various files, and supports navigation via function keys. The program uses subroutines to modularize logic. Here’s a step-by-step breakdown:
- File and Data Definitions:
- Files:
AR822RD: Workstation file with four subfiles (SFLC1,SFLC2,SFLC3,SFLC4) for displaying pricing data.BBPRCY: Rack pricing file (128 bytes, keyed by company, location, product, container).BICUA6: Sales agreement file (256 bytes, keyed by company, customer, location).GSTABL: General system table (256 bytes, commented out in parts, replaced by other files).GSPROD: Product master file (512 bytes, keyed by product code).ARCUPR: Customer pricing file (80 bytes, keyed by company, customer, ship-to, product, and container type after JB07).ARCUSP: Customer special pricing file (1344 bytes, keyed by company, customer).ARCUST: Customer master file (384 bytes, keyed by company, customer).SHIPTO: Ship-to address file (2048 bytes, keyed by company, customer, ship-to).GSCNTR1: Container master file (512 bytes, keyed by container code).
- Data Structures:
UDS: Local data area (LDA) fields:CO(company, 2 digits),PROD(product, 4 characters),CNTR(container, 3 characters),CUST(customer, 6 characters).PSDS##: Program status data structure for error handling (PS#ERR) and parameter count (PS#PRM).- Input specifications define fields for each file (e.g.,
RKDEL,RKCONO,BADEL,CPDEL, etc.).
-
Entry Parameters (DC02):
- Parameters (
P$CO,P$PROD,P$CNTR,P$CUST) can be passed from a calling program. If none are provided, LDA values are used.
- Parameters (
-
Initialization (DC02,
*INZSRSubroutine): - Checks for passed parameters (company, product, container, customer) via
*ENTRY PLIST. - If parameters are passed (
PS#PRM >= 1), moves them toCO,PROD,CNTR,CUST. Otherwise, uses LDA values. -
Error handling via
*PSSRchecks for invalid parameter counts (PS#ERR = 221) and sets a return code. -
Main Processing Loop (Lines B001–E001):
- The program runs in a
DOloop untilNEXTequals'$EOJ'. -
Uses a
CASEstructure to route control to subroutines based on theNEXTvariable:$XCUTC: Displays customer subfile (SFLC1).$XCUTC2: Displays sales agreement subfile (SFLC2).$XCUTC3: Displays no sales agreement screen (SFLC3).$XCUTC4: Displays no rack pricing screen (SFLC4).$SERCH: Performs rack pricing search.$SERCH2: Performs sales agreement search.- Default: Calls
$ENTRYfor initial setup.
-
$ENTRY Subroutine:
- Initializes screen fields (
S1CUST,S1PROD,S1CNTR) fromCUST,PROD,CNTR. - Clears pricing and unit of measure fields (
RKUNMS1,RKUNMS2,RKUNMS3,RKPRC1,RKPRC2,RKPRC3). - Retrieves customer name from
ARCUSTusingCUSKEY(company + customer); if found, setsS1NAME. - Retrieves product description from
GSPRODusingKLPROD(company + product); if found, setsS1DESC. - Retrieves container description and type from
GSCNTR1usingCNTR; if found, setsS1CTDSandWKCNTY(container type, e.g.,'B','P'). - Writes initial screen (
SCRE1) and sets indicators for subfile control. - Handles function keys:
- F3: Sets
NEXTto'$EOJ'to exit. - F5: Sets
NEXTto'$SERCH2'for sales agreement search. - F7: Sets
NEXTto'$EOJ'andU7indicator.
- F3: Sets
- If
PO#is blank, initializes subfile control (CTLC2) and clears subfile record numbers (RRNC1,RRNC2,RRNC3,RRNC4). -
Sets
NEXTto'$SERCH'for rack pricing search. -
$XCUTC, $XCUTC2, $XCUTC3, $XCUTC4 Subroutines:
- Each subroutine displays a specific subfile (
SFLC1,SFLC2,SFLC3,SFLC4) by writing control records (SCRC1,SCRC2,SCRC3,SCRC4) and formatting the subfile (EXFMT). - Handles function keys:
- F3: Sets
NEXTto'$EOJ'to exit. - F5 (for
$XCUTC,$XCUTC4): SetsNEXTto'$SERCH2'for sales agreement search. - F7: Sets
NEXTto'$EOJ'andU7indicator.
- F3: Sets
-
These subroutines manage the display of customer, sales agreement, no sales agreement, and no rack pricing screens, respectively.
-
$SERCH Subroutine (Truncated, but key logic described):
- Searches for rack pricing in
BBPRCYusing keys (RKCONO,RKLOC,RKPROD,RKCNTR). - Skips deleted records (
RKDEL = 'D') and records whereRKDATEexceeds current date (DATE). - Populates subfile fields (
S2PROD,S2DESC,S2QTY1,S2QTY2,S2QTY3,S2QTY4,S2PRC1,S2PRC2,S2PRC3,S2PRC4,S2MINQ) with pricing data. - Calls
$WRITEto write subfile records. -
If records are found (
RRNC1 > 0), setsNEXTto'$XCUTC'. Otherwise, calls$WRITE4and setsNEXTto'$XCUTC4'(no rack pricing). -
$SERCH2 Subroutine:
- Searches for sales agreements in
BICUA6usingFLD30(company, customer, product, container, date, and time). - Skips deleted records (
BADEL = 'D'), non-matching customer (BACUST), product (BAPR01), container (BACNTR), company (BACONO), or expired records (BASTD8 > DATEorBAEND8 < DATEunlessBAEND8 = 0). - Retrieves ship-to description from
SHIPTOusingBBKEY(company, customer, ship-to). - Determines freight terms (
S4TERM):- If
BAFRCDis blank, chains toARCUPRusingFRTKEY(company, customer, ship-to, product, container type). If not found, tries with blank container type (JB07). - Sets
S4TERMbased on freight codes (CPFRCD,CSFRCD,BAFRCD): 'C': "COLLECT" (or "COLLECT." ifCPCAFR = 'Y', JB09).'A': "PPD & ADD".'P': "3RD PARTY" (ifCPSFRT = 'N'andCPCAFR = 'N') or "PREPAID".
- If
- Populates subfile fields (
S4PRCE,S4UOFM,S4SHIP,S4LOC,S4DESC,S4MNQY,S4MXQY,S4POY,S4PORD) with sales agreement data. - If
BAPRCEis non-zero, uses it forS4PRCEand setsS4TYPEto'P'. Otherwise, usesBAOFFP(percent off price) and setsS4TYPEto'O'with yellow highlighting (JK01). - Calls
$WRITE2to write subfile records. -
If records are found (
RRNC2 > 0), setsNEXTto'$XCUTC2'. Otherwise, calls$WRITE3and setsNEXTto'$XCUTC3'(no sales agreement). -
$CLEAR Subroutine:
-
Clears subfile fields (
S2PROD,S2DESC,S2QTY1,S2QTY2,S2QTY3,S2QTY4,S2PRC1,S2PRC2,S2PRC3,S2PRC4,S2MINQ,S4PRCE,S4UOFM,S4SHIP,S4LOC,S4TERM,S4TYPE,S4MNQY,S4MXQY,SVPROD,SVUNMS,SVSHIP,SVLOC,SVCUST) and resets indicators. -
$WRITE, $WRITE2, $WRITE3, $WRITE4 Subroutines (Truncated):
-
Write records to subfiles
SFLC1,SFLC2,SFLC3, andSFLC4, respectively, based on pricing data retrieved. -
Termination:
- Exits when
NEXT = '$EOJ'or function keys (F3, F7) are pressed, settingLR(last record) indicator.
- Exits when
Business Rules¶
- Input Handling:
- Accepts company (
CO), product (PROD), container (CNTR), and customer (CUST) from parameters or LDA (DC02). -
Validates inputs by retrieving customer name (
ARCUST), product description (GSPROD), and container description/type (GSCNTR1). -
Pricing Lookup:
- Rack Pricing (
BBPRCY):- Retrieves pricing based on company, location, product, and container.
- Skips deleted records (
RKDEL = 'D') and future-dated records (RKDATE > DATE). - Displays quantities and prices (
S2QTY1–4,S2PRC1–4,S2MINQ).
-
Sales Agreements (
BICUA6):- Matches records by company, customer, product, container, and ship-to location.
- Skips deleted records (
BADEL = 'D'), non-matching records, or expired records (BASTD8 > DATEorBAEND8 < DATEunlessBAEND8 = 0, JB03). - Uses
BAPRCE(price) orBAOFFP(percent off price) forS4PRCE, withS4TYPEindicating price type ('P'or'O', JK01). - Displays purchase order fields (
S4POY,S4PORD) ifBAPORDis non-blank (JB03). - Retrieves ship-to city (
S4DESC) fromSHIPTO(DC01).
-
Freight Terms:
- Determines freight terms (
S4TERM) based onBAFRCD(fromBICUA6),CPFRCD(fromARCUPR), orCSFRCD(fromARCUSP):'C': "COLLECT" (or "COLLECT." for freight collect with calculation, JB09).'A': "PPD & ADD".'P': "PREPAID" or "3RD PARTY" (based onCPSFRTandCPCAFR).
- For non-fluid products, tries container type
'P'if initial lookup fails (JB07). -
Special case: Freight collect with service fee (
CYY, JB10) adds $100 to customer billing when arranged by ARG but billed by the carrier. -
Subfile Display:
SFLC1: Customer pricing details (rack pricing).SFLC2: Sales agreement details (price, PO, freight terms).SFLC3: Displayed when no sales agreement is found.SFLC4: Displayed when no rack pricing is found.-
Supports up to 100 records in
SFLC2before setting indicator80. -
Function Key Behavior:
- F3: Exits the program.
- F5: Triggers sales agreement search (
$SERCH2) fromSFLC1orSFLC4. -
F7: Exits with
U7indicator set. -
Historical Modifications:
- DC01 (05/12/2010): Replaced
BBSHSPwithSHIPTOfor ship-to data. - DC02 (11/27/2011): Added parameter passing, falling back to LDA if none provided.
- JB03 (01/09/2013): Added purchase order fields (
BAPORD,S4POY,S4PORD) and allowed zero end date for sales agreements. - JB04 (01/09/2013): Added fields for no rack required and inactive status in display.
- MG05 (04/25/2013): Ignores deleted rack pricing records.
- JB06 (06/05/2013): Ignores deleted sales agreement records.
- JK01 (01/23/2015): Displays
BAOFFPin yellow if non-zero, removes calculated off-price logic. - JB07 (05/18/2015): Added container type to
ARCUPRkey, tries blank or'P'container type if lookup fails. - JK02 (04/13/2016): Replaced
GSTABLcontainer lookup withGSCNTR1. - JB09 (05/19/2020): Added freight collect logic (
CNY) for non-Bradford shipments. - JB10 (01/17/2022): Added freight collect with service fee (
CYY, $100 charge). - JK03 (01/02/2023): Replaced
GSTABLproduct lookup withGSPROD.
Tables/Files Used¶
- AR822RD: Workstation file with subfiles
SFLC1,SFLC2,SFLC3,SFLC4for displaying pricing data. - BBPRCY: Rack pricing file (key: company, location, product, container).
- BICUA6: Sales agreement file (key: company, customer, location).
- GSTABL: General system table (partially commented out, replaced by
GSPRODandGSCNTR1). - GSPROD: Product master file (key: product code).
- ARCUPR: Customer pricing file (key: company, customer, ship-to, product, container type).
- ARCUSP: Customer special pricing file (key: company, customer).
- ARCUST: Customer master file (key: company, customer).
- SHIPTO: Ship-to address file (key: company, customer, ship-to).
- GSCNTR1: Container master file (key: container code).
External Programs Called¶
- None: The
AR822Rprogram does not call any external RPG programs. It relies on internal subroutines ($ENTRY,$XCUTC,$XCUTC2,$XCUTC3,$XCUTC4,$SERCH,$SERCH2,$CLEAR,$WRITE,$WRITE2,$WRITE3,$WRITE4,*PSSR,@PARMS,*INZSR) for its logic.
Summary¶
The AR822R.rpgle.txt program is a pricing lookup tool for CSRs, retrieving rack pricing (BBPRCY) and sales agreement data (BICUA6) based on company, customer, product, and container inputs. It validates inputs using ARCUST, GSPROD, and GSCNTR1, determines freight terms from ARCUPR and ARCUSP, and displays results in subfiles. It supports purchase order fields, freight collect scenarios (including a $100 service fee for CYY), and flexible container type lookups. No external programs are called, and the listed files support the pricing and customer data required.