The provided call stack consists of the following programs in the Bradford Order Entry/Invoices system:
- BI907P (Main RPGLE program, assumed as the entry point based on context).
- BI907C (CLP program, prepares temporary work file and calls BI907).
- BI907 (RPGLE program, handles customer/ship-to file maintenance and inquiry).
- BI9078 (RPGLE program, copies customer/ship-to product descriptions).
- GB730P (RPGLE program, provides history inquiry for various files).
- BI907C2 (CLP program, clears temporary work file).
These programs collectively support a system for managing customer and ship-to product descriptions, freight terms, and related historical data. Below, I will identify the use cases implemented by this call stack and then provide a function requirement document for one of the primary use cases, reimagined as a non-interactive function that processes inputs programmatically.
Use Cases Implemented by the Call Stack¶
Based on the analysis of the programs, the call stack implements the following use cases:
- Maintain Customer/Ship-To Product Descriptions and Freight Terms:
- Description: Allows users to add, update, or delete customer/ship-to-specific product descriptions and freight terms, including freight codes, container types, and related flags (e.g., separate freight, calculate freight).
- Programs Involved:
BI907P
,BI907C
,BI907
,BI907C2
. -
Details:
BI907P
(assumed) provides the main user interface for entering company, customer, ship-to, mode (MNT
orINQ
), and file group (Z
orG
).BI907C
prepares the temporary work fileBI907W
inQTEMP
by clearing or creating it and callsBI907
.BI907
uses a subfile-based interface to display and manage records inarcupr
, validate inputs (e.g., freight codes, container types), and log changes toarcuphs
.BI907C2
clearsBI907W
to reset the temporary file for new operations.- Supports modes: Maintenance (
MNT
) for editing and Inquiry (INQ
) for viewing. - Validates freight codes (e.g.,
C
requiress1sfrt
ands1cafr
to beY
,N
, or blank;A
requiress1sfrt = 'Y'
;CYY
indicates freight collect with a $100 service fee). - Provides options to prompt for valid codes (e.g., customer, ship-to, product, freight code, container type) and toggle between Add, Update, and All modes.
-
Copy Customer/Ship-To Product Descriptions:
- Description: Copies product descriptions from one customer/ship-to pair to another within the same company, updating existing records or adding new ones, and generates a printed report.
- Programs Involved:
BI907P
,BI907C
,BI9078
. -
Details:
- Initiated from
BI907P
(via F8 key inBI907
) with source and target customer/ship-to parameters. BI907C
sets upBI907W
inQTEMP
for temporary processing.BI9078
reads source records fromarcup3
, updates or adds records toarcupr
, logs changes toarcuphs
, and prints a report toqsysprt
.- The report includes details like company, customer, ship-to, product, container type, product description, and whether the record is new or updated.
- Supports file groups
Z
andG
for different data environments.
- Initiated from
-
View Historical Changes for Customer/Ship-To Data:
- Description: Displays historical changes for customer/ship-to data and other related files, allowing users to review past modifications (e.g., additions, updates, deletions).
- Programs Involved:
BI907P
,BI907C
,BI907
,GB730P
. -
Details:
- Initiated from
BI907
(via F9 key for history inquiry) with parameters for the file to query (e.g.,ARCUPR
) and key fields (e.g., company, customer, ship-to, product, container type). BI907C
ensuresBI907W
is available inQTEMP
.GB730P
uses a subfile-based interface to display history records from the corresponding history file (e.g.,arcuphx
forARCUPR
).- Supports multiple files (e.g.,
SHIPTO
,CUADR
,ARCUST
,BICUAG
,BBPRCE
,BBORDH
, etc.) with specific headers and key fields. - Enforces file group flexibility (
Z
orG
) and proprietary security restrictions.
- Initiated from
-
Reset Temporary Work File:
- Description: Clears the temporary work file
BI907W
to ensure no residual data affects subsequent operations. - Programs Involved:
BI907P
,BI907C2
. - Details:
BI907C2
is called fromBI907P
to execute theCLRPFM
command onBI907W
inQTEMP
.- Ensures a clean slate for temporary data used by
BI907
orBI9078
.
Function Requirement Document: Maintain Customer/Ship-To Product Descriptions and Freight Terms¶
Below is a function requirement document for the primary use case, "Maintain Customer/Ship-To Product Descriptions and Freight Terms," reimagined as a non-interactive function that processes inputs programmatically rather than through a screen-based interface. The document focuses on business requirements, process steps, and calculations concisely.
Function Requirement Document: Maintain Customer/Ship-To Product Descriptions and Freight Terms¶
Purpose¶
To programmatically add, update, or delete customer/ship-to-specific product descriptions and freight terms in the Bradford Order Entry/Invoices system, ensuring data integrity and logging changes for audit purposes.
Inputs¶
- Company Number (
cono
, 2-digit numeric): Identifies the company. - Customer Number (
cust
, 6-digit numeric): Identifies the customer. - Ship-To Number (
ship
, 3-digit numeric): Identifies the ship-to location. - File Group (
fgrp
, 1-character): Specifies the data environment (Z
orG
). - Action (
action
, string): Specifies the operation (ADD
,UPDATE
,DELETE
). - Records (array of records, each containing):
product
(4-character): Product code.container_type
(1-character): Container type code.product_description
(20-character): Customer-specific product description.freight_code
(2-character): Freight code (e.g.,C
,A
,CYY
).separate_freight
(1-character): Separate freight flag (Y
,N
, or blank).calculate_freight
(1-character): Calculate freight flag (Y
,N
, or blank).gl_code
(10-character): General ledger code (optional for updates).- User ID (
user
, 8-character): User performing the action for audit logging. - Timestamp (
timestamp
, 14-digit numeric, formatCCYYMMDDHHMMSS
): Date and time of the operation.
Outputs¶
- Status (string):
SUCCESS
,ERROR
, orPARTIAL_SUCCESS
(if some records fail). - Messages (array of strings): Error or informational messages for each record processed.
- Processed Records (array of records): Returns the input records with updated status (e.g., added, updated, deleted, or failed).
Process Steps¶
- Validate Inputs:
- Ensure
cono
,cust
,ship
, andfgrp
are non-empty and valid. - Verify
fgrp
isZ
orG
. -
For each record, validate:
product
exists ingsprod
(file group adjusted).container_type
exists ingstabl
(table typeCNTRTY
).freight_code
exists ingstabl
(table typeBBFRCD
).separate_freight
andcalculate_freight
areY
,N
, or blank iffreight_code
isC
orCYY
.separate_freight
isY
iffreight_code
isA
.product_description
is non-empty forADD
andUPDATE
.
-
Clear Temporary Work File:
-
Clear
BI907W
inQTEMP
to ensure no residual data. -
Apply File Overrides:
-
Override
arcupr
,arcuphs
,gstabl
,bicont
,gsprod
,arcust
,shipto
tog*
orz*
files based onfgrp
. -
Process Each Record:
- For ADD:
- Check if a record exists in
arcupr
forcono
,cust
,ship
,product
,container_type
. - If exists and not marked deleted, return error ("Record Already Exists").
- If marked deleted, reactivate by updating
cpdel = 'A'
. - If not exists, create new record with input fields.
- Write to
arcupr
and log toarcuphs
withuser
,timestamp
, and fields.
- Check if a record exists in
- For UPDATE:
- Check if record exists in
arcupr
. - If not exists, return error ("Record Not Found").
- Update
product_description
,freight_code
,separate_freight
,calculate_freight
,gl_code
. - Write to
arcupr
and log toarcuphs
.
- Check if record exists in
-
For DELETE:
- Check if record exists in
arcupr
. - If not exists, return error ("Record Not Found").
- Set
cpdel = 'D'
inarcupr
and log toarcuphs
.
- Check if record exists in
-
Log History:
-
For each successful operation, write a history record to
arcuphs
with:ahcono
,ahcust
,ahship
,ahprod
,ahcnty
,ahcpds
,ahfrcd
,ahsfrt
,ahcafr
,ahglcd
,ahdel
,ahchd8
(date),ahchtm
(time),ahuser
.
-
Return Results:
- Compile status and messages for each record.
- Return overall status and processed records.
Business Rules¶
- Data Integrity:
- Product codes must exist in
gsprod
. - Container types and freight codes must exist in
gstabl
(CNTRTY
andBBFRCD
). - Customer and ship-to must exist in
arcust
andshipto
. - Freight Code Rules:
- For
freight_code = 'C'
(freight collect) orCYY
(freight collect with $100 service fee):separate_freight
andcalculate_freight
must beY
,N
, or blank.
- For
freight_code = 'A'
(non-Bradford location, e.g., Anchor):separate_freight
must beY
.
CYY
indicates shipping arranged by ARG but billed to customer by carrier with a $100 fee.- Record Status:
- Records marked deleted (
cpdel = 'D'
) cannot be added unless reactivated. - New records are marked active (
cpdel = 'A'
). - History Logging:
- All changes (add, update, delete) are logged to
arcuphs
with user and timestamp. - File Group:
fgrp
(Z
orG
) determines the database file set (g*
orz*
).
Calculations¶
- Freight Service Fee (for
freight_code = 'CYY'
): - A fixed $100 fee is applied to the customer for freight arranged by ARG but billed by the carrier.
- This is not programmatically calculated but is a business rule enforced during validation.
- Timestamp Formatting:
- Input
timestamp
(14-digitCCYYMMDDHHMMSS
) is split intoahchd8
(8-digitCCYYMMDD
) andahchtm
(6-digitHHMMSS
) for history logging.
Error Handling¶
- Return specific error messages for:
- Invalid
product
,container_type
, orfreight_code
. - Non-existent customer or ship-to.
- Invalid
separate_freight
orcalculate_freight
for specific freight codes. - Record already exists (for
ADD
) or not found (forUPDATE
,DELETE
). - Log errors in the output messages array.
Notes¶
- The function requirement document focuses on the primary use case of maintaining customer/ship-to data, as it is the core functionality of the call stack (
BI907P
,BI907C
,BI907
,BI907C2
). The other use cases (copying records, viewing history) could also be converted to non-interactive functions but are secondary in scope. - The document assumes a programmatic interface, eliminating screen-based interactions and focusing on batch processing of input records.
- The business rules and validations are derived from the
BI907
program, with freight code rules (C
,A
,CYY
) explicitly documented, including the $100 service fee forCYY
. - The temporary work file (
BI907W
) is included as a step to maintain consistency with the original call stack, though its use in a non-interactive function may be optional depending on implementation.