The call stack consists of three programs: AR820.ocl36.txt
(OCL program), AR820.rpg36.txt
(RPG program for customer search), and AR822R.rpgle.txt
(RPG program for price lookup). These programs work together to facilitate a customer search and pricing inquiry system on an IBM System/36 or AS/400 environment. Below, I identify the use cases implemented by this call stack and provide a function requirement document for one of the use cases, reimagined as a non-interactive function that processes inputs directly.
Use Cases Implemented by the Call Stack¶
The call stack implements two distinct use cases, each addressing a specific business need:
- Customer Search for Pricing Inquiry:
- Description: Allows a Customer Service Representative (CSR) to search for customers based on company number, customer number, product code, container code, and a partial customer name. The system retrieves and displays customer details (name, address, open balance) to help identify the correct customer for a pricing inquiry.
- Program Involved:
AR820.rpg36.txt
(with setup fromAR820.ocl36.txt
). - Key Features:
- Validates inputs (company, customer, product, container) against
ARCONT
,ARCUST
,GSPROD
, andGSCNTR1
. - Supports partial name search using
ARCUSX
for cross-reference. - Displays up to 15 customer records per screen, with scrolling (roll up/down).
- Shows open balance indicator (
OPENYN
) if total due (ARTOTD
) is non-zero. - Handles function keys: F3 (rekey), F12 (exit), Roll Up/Down (scrolling).
- Validates inputs (company, customer, product, container) against
-
Purpose: Enables CSRs to locate a customer before proceeding to pricing details, ensuring accurate customer selection.
-
Pricing Lookup for Customer Orders:
- Description: Retrieves and displays pricing information (rack pricing and sales agreements) for a specific customer, product, container, and company, including freight terms and purchase order details.
- Program Involved:
AR822R.rpgle.txt
(called byAR820.ocl36.txt
afterAR820.rpg36.txt
). - Key Features:
- Retrieves rack pricing from
BBPRCY
and sales agreements fromBICUA6
. - Validates inputs using
ARCUST
,GSPROD
,GSCNTR1
, andSHIPTO
. - Displays pricing details in subfiles, including price type (standard or percent off), quantities, freight terms, and purchase order fields.
- Handles special freight scenarios: collect (
CNY
), collect with service fee (CYY
, $100 charge), prepaid, third-party, or PPD & ADD. - Supports function keys: F3/F7 (exit), F5 (sales agreement search).
- Skips deleted or expired records and allows zero end date for sales agreements.
- Retrieves rack pricing from
- Purpose: Provides CSRs with accurate pricing and freight terms to quote customers or process orders.
Function Requirement Document: Pricing Lookup Function¶
This document reimagines the Pricing Lookup for Customer Orders use case as a non-interactive function that takes inputs and returns pricing results without screen interaction. The function processes customer, product, container, and company inputs to retrieve rack pricing, sales agreements, and freight terms.
Pricing Lookup Function Requirements¶
Overview¶
The Pricing Lookup Function retrieves rack pricing and sales agreement details for a specified customer, product, container, and company, including freight terms and purchase order information. It returns structured pricing data for use in order processing or customer quoting.
Inputs¶
- Company Number (CO): 2-digit numeric (required).
- Customer Number (CUST): 6-character alphanumeric (required).
- Product Code (PROD): 4-character alphanumeric (required).
- Container Code (CNTR): 3-character alphanumeric (optional, defaults to blank).
- Current Date (DATE): 8-digit numeric (YYYYMMDD, defaults to system date).
Outputs¶
- Status: Success or error code (e.g., "INVALID_COMPANY", "INVALID_CUSTOMER", etc.).
- Customer Name (S1NAME): 30-character customer name.
- Product Description (S1DESC): 30-character product description.
- Container Description (S1CTDS): 30-character container description (if
CNTR
provided). - Rack Pricing Records (array):
- Product Code, Location, Unit of Measure, Minimum Quantity, Quantities (1–4), Prices (1–4).
- Sales Agreement Records (array):
- Product Code, Ship-to Code, Location, Unit of Measure, Price, Price Type ("P" or "O"), Minimum/Maximum Quantity, Start Date, PO Number, Freight Terms.
- Error Message: Description of any validation failure.
Process Steps¶
- Validate Inputs:
- Check
CO
againstARCONT
. If invalid, return error "INVALID COMPANY NUMBER". - Check
CUST
againstARCUST
usingCO + CUST
. If invalid, return error "INVALID CUSTOMER NUMBER". - Check
PROD
againstGSPROD
. If invalid, return error "INVALID PRODUCT CODE". - If
CNTR
non-blank, check againstGSCNTR1
. If invalid, return error "INVALID CONTAINER CODE". -
Retrieve
S1NAME
fromARCUST
,S1DESC
fromGSPROD
, andS1CTDS
fromGSCNTR1
(if applicable). -
Retrieve Rack Pricing:
- Query
BBPRCY
usingCO
,PROD
,CNTR
, and any location (RKLOC
). - Filter out deleted records (
RKDEL = 'D'
) and records withRKDATE > DATE
. -
Collect up to 10 records with fields:
RKPROD
,RKLOC
,RKUNMS
,RKMINQ
,RKQT01–04
,RKPRCE
,RKPR02–05
. -
Retrieve Sales Agreements:
- Query
BICUA6
usingCO
,CUST
,PROD
,CNTR
, and any ship-to (BASHIP
). - Filter out:
- Deleted records (
BADEL = 'D'
). - Non-matching records (
BACONO ≠ CO
,BACUST ≠ CUST
,BAPR01 ≠ PROD
,BACNTR ≠ CNTR
). - Expired records (
BASTD8 > DATE
orBAEND8 < DATE
unlessBAEND8 = 0
).
- Deleted records (
-
For each record:
- Retrieve ship-to city (
S4DESC
) fromSHIPTO
usingCO
,CUST
,BASHIP
. - Set price (
S4PRCE
) toBAPRCE
(if non-zero,S4TYPE = 'P'
) orBAOFFP
(if non-zero,S4TYPE = 'O'
). - Set PO fields:
S4POY = 'PO'
,S4PORD = BAPORD
ifBAPORD
non-blank. - Collect fields:
BAPR01
,BASHIP
,BALOC
,BAUNMS
,S4PRCE
,S4TYPE
,BAMNQY
,BAMXQY
,BASTD8
,S4POY
,S4PORD
.
- Retrieve ship-to city (
-
Determine Freight Terms:
- If
BAFRCD
(fromBICUA6
) is blank:- Query
ARCUPR
usingCO
,CUST
,BASHIP
,PROD
, and container type (TCCNTY
fromGSCNTR1
, or blank/'P'
for non-fluid products). - If not found, query
ARCUSP
usingCO
,CUST
.
- Query
- Set
S4TERM
based on freight code (BAFRCD
,CPFRCD
, orCSFRCD
):'C'
: "COLLECT" (or "COLLECT." ifCPCAFR = 'Y'
for freight collect calculation).'A'
: "PPD & ADD".'P'
: "PREPAID" (ifCPSFRT = 'Y'
orCPCAFR = 'Y'
) or "3RD PARTY".'CYY'
: "COLLECT" with $100 service fee (freight arranged by ARG, billed by carrier).
-
Return up to 100 sales agreement records.
-
Return Results:
- If rack pricing found, return array of rack pricing records.
- If sales agreements found, return array of sales agreement records with freight terms.
- If no pricing found, return empty arrays with appropriate status.
Business Rules¶
- Validation: All inputs must exist in respective master files (
ARCONT
,ARCUST
,GSPROD
,GSCNTR1
). - Rack Pricing: Only include non-deleted records with valid dates. Display quantities and prices for multiple tiers.
- Sales Agreements:
- Include non-deleted, non-expired records (zero end date allowed).
- Display standard price (
BAPRCE
) or percent-off price (BAOFFP
) with type indicator. - Include purchase order number if provided.
- Freight Terms:
- Prioritize
BAFRCD
, thenCPFRCD
, thenCSFRCD
. - Handle special cases:
CNY
(freight collect from non-Bradford location),CYY
(freight collect with $100 service fee). - Container Type: For
ARCUPR
lookups, try container type fromGSCNTR1
, then blank, then'P'
for non-fluid products. - Error Handling: Return specific error messages for invalid inputs.
Calculations¶
- Price Selection: Use
BAPRCE
if non-zero; otherwise, useBAOFFP
(no additional calculation for percent-off price, per JK01). - Freight Service Fee: Add $100 to customer cost for
CYY
freight terms (JB10). - Date Comparison: Convert system date to YYYYMMDD for comparison with
RKDATE
,BASTD8
, andBAEND8
.
Dependencies¶
- Files:
ARCONT
,ARCUST
,GSPROD
,GSCNTR1
,BBPRCY
,BICUA6
,ARCUPR
,ARCUSP
,SHIPTO
. - Assumptions: Input values are trimmed and uppercase. System date is provided or defaults to current date.
Notes¶
- The Customer Search for Pricing Inquiry use case was not converted to a function requirement document, as the pricing lookup is the primary function called by the OCL and builds on the customer search output. However, a similar function could be created for customer search, taking similar inputs and returning customer records.
- The function requirement document focuses on business requirements (validation, data retrieval, freight terms) and concisely describes calculations (price selection, freight fee). It assumes direct input processing to align with the non-interactive requirement.