The call stack consists of the following programs, all part of the Brandford Order Entry / Invoices system on an IBM AS/400 (iSeries) platform:
- BI890.rpg36.txt: An RPG/400 program for ship-to master file maintenance and inquiry, providing an interactive interface for managing ship-to records, including customer details, addresses, product codes, and accessorial/marks data.
- BI907AC.clp.txt: A CLP program that prepares a temporary work file (
QTEMP/BI907W) and callsBI907for customer/ship-to product description and freight terms maintenance. - BI907.rpgle.txt: An RPGLE program for maintaining and inquiring about customer/ship-to product descriptions and freight terms, using a subfile interface.
- BB800E.rpgle.txt: An RPGLE program for customer order instructions inquiry, displaying accessorial and marks instructions for orders or ship-to records.
- BI8903.rpgle.txt: An RPGLE program for copying ship-to records from one customer/ship-to to another, updating related files.
Based on the analysis of these programs, I will identify the use cases implemented in the call stack and then provide a function requirement document for each use case, assuming they are implemented as large functions that process inputs programmatically without screen interaction.
List of Use Cases¶
The call stack implements the following distinct use cases:
- Ship-to Master File Maintenance and Inquiry (
BI890): - Allows users to view, add, update, or delete ship-to master records, including customer details, addresses, product codes, accessorial/marks, and freight terms.
- Validates inputs against customer, company, and product master files.
- Supports inquiry (
INQ) and maintenance (MNT) modes. -
Calls
BB800Efor accessorial/marks inquiry,BI907ACfor product/freight terms maintenance, andBI9002for address maintenance. -
Customer/Ship-to Product Description and Freight Terms Maintenance (
BI907ACandBI907): - Manages customer/ship-to product pricing records (
arcupr), including product codes, gallons to bill, stock numbers, freight codes, and freight terms. - Supports adding, updating, deleting, or reactivating records in inquiry or maintenance modes.
- Validates product and freight codes, with special handling for freight collect scenarios (e.g., non-Bradford locations, service fees).
-
Uses a temporary work file (
BI907W) for intermediate data. -
Customer Order/Ship-to Instructions Inquiry (
BB800E): - Displays accessorial and marks instructions for customer orders (
bbora1) or ship-to master records (bbshsa1) in inquiry mode. - Supports order mode (
p$ship = 0) and ship-to mode (p$ship ≠ 0). -
Validates customer and order/ship-to data, displaying up to 32 records in a subfile.
-
Copy Ship-to Records (
BI8903): - Copies ship-to records and related data (pricing, addresses, accessorial/marks) from a source customer/ship-to to a target customer/ship-to within the same company.
- Ensures the target ship-to does not already exist and clears specific fields in the new
shiptorecord.
Function Requirement Documents¶
Below are concise function requirement documents for each use case, designed as programmatic functions that take inputs and produce outputs without screen interaction. Each document outlines the process steps, business rules, and calculations (if applicable) in a business-focused manner.
Function Requirement Document: ShipToMasterMaintenance¶
Purpose¶
Programmatically maintain or inquire about ship-to master records, including customer details, addresses, product codes, accessorial/marks, and freight terms, for the Brandford Order Entry / Invoices system.
Inputs¶
- Company Number (
cono, 2 digits): Identifies the company. - Customer Number (
cust, 6 digits): Identifies the customer. - Ship-to Number (
ship, 3 digits): Identifies the ship-to (optional for inquiry). - Mode (
mode, 3 characters): 'INQ' for inquiry, 'MNT' for maintenance. - Ship-to Data (
shipData, structure): Includes fields like name (csname, 30 chars), address lines (csadr1-4, 30 chars each), city (csctst, 30 chars), state (csstat, 2 chars), zip (cszip5, 5 digits;cscszp, 15 chars), miles (csmils, 3 digits), product codes (cspr01-24, 4 chars each), backup ship-to (cssbkp, 15 chars), delivery location (csdloc, 3 chars), billing customer (csbcus, 6 digits), billing ship-to (csbcsh, 3 digits), memo customer (csbmcu, 10 chars), rail company (csrrco, 2 digits), country (cscty, 3 chars), export flag (csexpo, 1 char), FOB code (csfob, 1 char), contract owner (cscoon, 1 char), alternate owner (csalto, 1 char), longitude (cslong, 13 chars), latitude (cslatt, 13 chars), order marks (csomk1-4, 60 chars each), invoice marks (csimk1-2, 60 chars each), dispatch info (csdsp1-4, 60 chars each), bill of lading marks (csbmk1-4, 60 chars each), freight bill name (csfrnm, 30 chars), freight bill address (csfra1-3, 30 chars each), note status (csnote, 6 chars), customer ship-to ID (cscsid, 9 chars), max railcar weight (csrcmx, 7 digits), service fee flag (cssvfe, 1 char). - File Group (
fgrp, 1 char): 'G' or 'Z' for file overrides.
Outputs¶
- Status (
status, string): 'SUCCESS', 'ERROR', or specific error message (e.g., 'INVALID CUSTOMER NUMBER'). - Ship-to Data (
shipData, structure): Updated or retrieved ship-to record (if applicable). - Product Data (
productData, array): Product codes (prcd, 4 chars), descriptions (prds, 30 chars), gallons to bill (glcd, 1 char), stock numbers (stno, 20 chars), freight codes (pfrc, 1 char), separate freight (psfr, 1 char), calculate freight (pcaf, 1 char), container type (cnty, 1 char). - Messages (
messages, array): Error or status messages (e.g., 'SHIP TO NOT FOUND').
Process Steps¶
- Validate Inputs:
- Check
conoagainstbicont. If invalid, return 'INVALID COMPANY NUMBER'. - Check
custagainstarcust. If invalid, return 'INVALID CUSTOMER NUMBER'. - If
shipprovided, check againstshiptousingcskey(cono,cust,ship). If not found, return 'SHIP TO NOT FOUND'. - If
ship = '999', return 'SHIPTO # 999 MAY NOT BE USED'. - Inquiry Mode (
mode = 'INQ'): - Retrieve
shiptorecord usingcskey. - If deleted (
csdel = 'D'), return 'THIS SHIP TO WAS PREVIOUSLY DELETED' andshipData. - Retrieve product data from
arcuprforcono,cust,ship. - Retrieve descriptions from
gsprodand freight terms fromarcupr. - Return
shipData,productData, and 'SUCCESS'. - Maintenance Mode (
mode = 'MNT'): - If
shipexists, updateshiptowithshipDatafields, clearingcsdelif reactivating. - If
shipdoes not exist, create newshiptorecord withshipData. - Validate product codes (
cspr01-24) againstgsprod. - Update or add
arcuprrecords with product data. - Write history to
arcuphs. - Return updated
shipData,productData, and 'SUCCESS' or error (e.g., 'INVALID CODE'). - Call External Functions:
- Invoke
CustomerOrderInstructionsInquiryfor accessorial/marks data (viaBB800E). - Invoke
CustomerShipToProductMaintenancefor product/freight terms (viaBI907AC/BI907). - Invoke
CustomerShipToAddressMaintenancefor address details (viaBI9002).
Business Rules¶
- Validation:
- Company, customer, and ship-to must exist in
bicont,arcust, andshipto. - Ship-to number 999 is reserved and cannot be used.
- Product codes must exist in
gsprodwithtpsell = 'Y'. - Modes:
- Inquiry mode retrieves data without modifications.
- Maintenance mode allows add, update, delete, or reactivation of records.
- Data Integrity:
- Deleted records (
csdel = 'D') can be reactivated. - Address fields include city, state, and zip (DC01).
- Maximum 24 product codes per ship-to.
- Freight Terms:
- Gallons to bill (
glcd) is 'G' (gross), 'N' (net), or blank. - Freight codes (
pfrc) and terms (psfr,pcaf) validated againstgstabl.
Calculations¶
- None explicitly required; data is validated and copied without computational transformations.
Function Requirement Document: CustomerShipToProductMaintenance¶
Purpose¶
Programmatically maintain or inquire about customer/ship-to product descriptions and freight terms, including product codes, stock numbers, and freight settings, for the Bradford Order Entry / Invoices system.
Inputs¶
- Company Number (
cono, 2 digits): Identifies the company. - Customer Number (
cust, 6 digits): Identifies the customer. - Ship-to Number (
ship, 3 digits): Identifies the ship-to. - Mode (
mode, 3 characters): 'INQ' for inquiry, 'MNT' for maintenance. - File Group (
fgrp, 1 char): 'G' or 'Z' for file overrides. - Product Data (
productData, array): Product code (cpprod, 4 chars), container type (w$cnty, 1 char), gallons to bill (cpglcd, 1 char), stock number (cpcstk, 20 chars), freight code (cpfrcd, 1 char), separate freight (cpsfrt, 1 char), calculate freight (cpcafr, 1 char).
Outputs¶
- Status (
status, string): 'SUCCESS', 'ERROR', or specific error message (e.g., 'INVALID CODE'). - Product Data (
productData, array): Retrieved or updated product records. - Messages (
messages, array): Error or status messages (e.g., 'Record has been Copied').
Process Steps¶
- Validate Inputs:
- Check
conoagainstbicont. If invalid, return 'INVALID COMPANY NUMBER'. - Check
custagainstarcust. If invalid, return 'INVALID CUSTOMER NUMBER'. - Check
shipagainstshipto. If invalid, return 'INVALID SHIP TO NUMBER'. - Validate
cpprodagainstgsprod. If invalid, return 'Invalid Code, Prompt For Valid Codes'. - Validate
cpglcdas 'G', 'N', or ' '. If invalid, return 'Invalid Code, Valid Code are: "G" " "'. - Validate
cpfrcdagainstgstabl(BBFRCD). If invalid, return 'Invalid Freight Code'. - Prepare Temporary File:
- Clear or create
QTEMP/BI907W(handled byBI907AC). - Inquiry Mode (
mode = 'INQ'): - Retrieve
arcuprrecords forcono,cust,shipusingkls1s1. - Return
productDatawith product codes, descriptions (fromgsprod), and freight terms. - Maintenance Mode (
mode = 'MNT'): - Add: If no
arcuprrecord exists forcpprodandw$cnty, add new record toarcupr. Require at least one product code (err(01)). If record exists or is deleted, return 'Record Already exist, Or Marked as Deleted, Cannot Add Record'. - Update: Update existing
arcuprrecords withproductData. - Delete/Reactivate: Mark records as deleted or reactivate them, updating
bi907w. - Copy: Copy records to
bi907wandarcuphs(history). - Write history to
arcuphs. - Return updated
productDataand 'SUCCESS' or error. - Freight Terms Validation:
- For
cpfrcd = 'C', ensurecpsfrtandcpcafrare ' ', 'Y', or 'N' (err(07),err(08)). - For
cpfrcd = 'A', ensurecpsfrt = 'Y'(freight collect with $100 service fee,err(09)).
Business Rules¶
- Validation:
- Product codes must exist in
gsprod. - Freight codes must exist in
gstabl. - Gallons to bill (
cpglcd) must be 'G', 'N', or ' '. - Freight collect (
cpfrcd = 'C') supports non-Bradford locations (e.g., Anchor, JB01). - Freight code
Arequires separate freight (cpsfrt = 'Y') with a $100 service fee (JB02). - Modes:
- Inquiry mode retrieves data without changes.
- Maintenance mode supports add, update, delete, or reactivation.
- Data Integrity:
- At least one product code required in Add mode.
- Records marked deleted can be reactivated.
- Temporary Storage:
- Uses
QTEMP/BI907Wfor intermediate data andarcuphsfor history.
Calculations¶
- Service Fee (JB02): For
cpfrcd = 'A', apply a fixed $100 service fee for freight collect arranged by ARG but billed by the carrier.
Function Requirement Document: CustomerOrderInstructionsInquiry¶
Purpose¶
Programmatically retrieve accessorial and marks instructions for customer orders or ship-to master records in the Brandford Order Entry / Invoices system.
Inputs¶
- Company Number (
cono, 2 digits): Identifies the company. - Customer/Order Number (
csor, 6 digits): Customer number (ship-to mode) or order number (order mode). - Ship-to Number (
ship, 3 digits): Ship-to number (0 for order mode). - File Group (
fgrp, 1 char): 'G' or 'Z' for file overrides.
Outputs¶
- Status (
status, string): 'SUCCESS', 'ERROR', or specific error message (e.g., 'INVALID CUSTOMER NUMBER'). - Instructions Data (
instructionsData, array): Records containing record ID (barcid, 4 digits), quantity (baqty, numeric), description (badesc, 30 chars), total cost (batcst, numeric), reason code (barccd, 2 chars), pick flag (bapick, 'Y'/'N'), dispatch flag (badsph, 'Y'/'N'), bill of lading flag (babol, 'Y'/'N'), invoice flag (bainv, 'Y'/'N'). - Customer Name (
csnm, 30 chars): Customer name fromarcust. - Ship-to Name (
shnm, 30 chars): Ship-to name fromshipto(ship-to mode only). - Messages (
messages, array): Error or status messages.
Process Steps¶
- Validate Inputs:
- Check
conoagainstbicont. If invalid, return 'INVALID COMPANY NUMBER'. - Check
csoragainstarcust(ship-to mode) orbbordh(order mode). If invalid, return 'INVALID CUSTOMER NUMBER' or 'INVALID ORDER NUMBER'. - If
ship ≠ 0, check againstshipto. If invalid, return 'INVALID SHIP TO NUMBER'. - Retrieve Data:
- Order Mode (
ship = 0):- Retrieve customer name (
arname) fromarcustusingklcus1. - Retrieve order instructions from
bbora1usingklc1r1.
- Retrieve customer name (
- Ship-to Mode (
ship ≠ 0):- Retrieve customer name (
arname) fromarcustusingklcus2. - Retrieve ship-to name (
csname) fromshiptousingklship. - Retrieve ship-to instructions from
bbshsa1usingklc1r2.
- Retrieve customer name (
- Format each record with
barcid,baqty,badesc,batcst,barccd,bapick,badsph,babol,bainv. - Return Results:
- Return
instructionsData,csnm,shnm(if applicable), and 'SUCCESS' or error.
Business Rules¶
- Modes:
- Order mode (
ship = 0): Retrieves instructions for a customer order frombbora1. - Ship-to mode (
ship ≠ 0): Retrieves instructions for a customer ship-to frombbshsa1. - Validation:
- Company, customer, and order/ship-to must exist in respective files.
- Data Limits:
- Retrieves up to 32 records per query.
- Inquiry Only:
- No modifications allowed; read-only access.
Calculations¶
- None required; data is retrieved and formatted without transformations.
Function Requirement Document: CopyShipToRecords¶
Purpose¶
Programmatically copy ship-to records and related data (pricing, addresses, accessorial/marks) from a source customer/ship-to to a target customer/ship-to within the same company in the Brandford Order Entry / Invoices system.
Inputs¶
- Company Number (
cono, 2 digits): Identifies the company. - Source Customer Number (
fcust, 6 digits): Source customer. - Source Ship-to Number (
fshp, 3 digits): Source ship-to. - Target Customer Number (
tcust, 6 digits): Target customer. - Target Ship-to Number (
tshp, 3 digits): Target ship-to. - File Group (
fgrp, 1 char): 'G' or 'Z' for file overrides.
Outputs¶
- Status (
status, string): 'SUCCESS', 'ERROR', or specific error message (e.g., 'TARGET SHIP-TO EXISTS'). - Messages (
messages, array): Status messages (e.g., 'Record has been Copied').
Process Steps¶
- Validate Inputs:
- Check
conoagainstbicont. If invalid, return 'INVALID COMPANY NUMBER'. - Check
fcustandfshpagainstshiptousingklFrmShipto. If not found, return 'SOURCE SHIP-TO NOT FOUND'. - Check
tcustagainstarcust. If invalid, return 'INVALID TARGET CUSTOMER NUMBER'. - Check
tshpagainstshiptousingklToShipto. If exists, return 'TARGET SHIP-TO EXISTS'. - Copy Ship-to Record:
- Retrieve source
shiptorecord usingklFrmShipto. - Create new
shiptorecord withtcustandtshp, clearing fields:cscsid,csadr1-4,cszip5,cszip9,csstat,csmils,csctst,cscszp,cslong,cslatt. - Copy Related Records:
- For each
arcuprrdrecord (pricing) matchingcono,fcust,fshp:- Create new
arcuprrecord withtcust,tshp.
- Create new
- For each
cuadrrdrecord (addresses) matchingcono,fcust,fshp:- Create new
cuadrrecord withtcust,tshp.
- Create new
- For each
bbshsa1rdrecord (accessorial/marks) matchingcono,fcust,fshp:- Create new
bbshsarecord withtcust,tshp, updatingbahkey.
- Create new
- Return Results:
- Return 'SUCCESS' and 'Record has been Copied'.
Business Rules¶
- Validation:
- Source ship-to must exist; target ship-to must not exist.
- Company and target customer must be valid.
- Data Integrity:
- Clears specific
shiptofields to ensure clean data. - Copies all related records (
arcupr,cuadr,bbshsa) without modification except for customer/ship-to fields. - File Overrides:
- Uses
fgrpto selectGorZfiles with no shared access.
Calculations¶
- None required; data is copied without transformations.
Summary¶
The call stack implements four use cases: ship-to master maintenance, customer/ship-to product maintenance, customer order/ship-to instructions inquiry, and ship-to record copying. Each function requirement document describes a programmatic implementation that takes inputs, validates them, processes data according to business rules, and returns outputs without screen interaction. The documents focus on business requirements, including validation, data integrity, and specific freight term rules (e.g., $100 service fee for freight code A), with minimal calculations involved.
If you need further refinements or additional details (e.g., specific subroutine implementations from truncated code), please let me know!