The call stack consists of three components: the OCL script (BB203.ocl36.txt
), the CLP program (BB203AC.clp.txt
), and the RPGLE program (BB203.rpgle.txt
). These work together to automate the posting of customer sales agreement pricing in an IBM System i (AS/400) environment. Below, I’ll identify the use cases implemented by this call stack and then provide a function requirement document for a non-interactive version of the primary use case.
Use Cases Implemented in the Call Stack¶
The call stack implements the following use cases:
- Cleanup of Temporary Work File:
- Description: Ensures that any existing temporary work file (
BB203W
) in theQTEMP
library is deleted before processing to prevent data conflicts from previous runs. - Component: Handled by
BB203AC.clp.txt
. - Input: A 1-character file group parameter (
&P$FGRP
). - Process: Deletes the
QTEMP/BB203W
file, ignoring errors if the file does not exist. - Output: None (clean slate for subsequent processing).
-
Business Rule: Ensures a clean environment by removing residual temporary files.
-
Validation and Preparation of Input Data:
- Description: Validates the existence and content of the input workstation file (
?9?BB203?WS?
) to ensure it contains records for posting. - Component: Handled by the OCL script (
BB203.ocl36.txt
). - Input: Workstation file (
?9?BB203?WS?
) and a file group parameter (?9?
). - Process:
- Checks if the file exists; if not, pauses with a message prompting the user to run "Option 15" and cancels.
- Verifies the file has records; if empty, pauses, deletes the file, and cancels.
- Output: None (proceeds to call
BB203AC
andBB203
if valid). -
Business Rule: Ensures only valid, non-empty input data proceeds to processing.
-
Automated Posting of Customer Sales Agreement Pricing:
- Description: Processes records from the temporary work file to update or expire existing pricing records, create new pricing records, log history, and generate a report.
- Component: Handled by
BB203.rpgle.txt
, with preprocessing byBB203AC
and setup by the OCL script. - Input:
- Temporary work file (
BB203W
) containing pricing records. - User-entered start date (via display file
BB203D
). - File group parameter (
p$fgrp
, 'G' or 'Z') for file overrides.
- Temporary work file (
- Process:
- Validates the user-entered start date against the work file’s start date.
- Expires existing pricing records if their expiry date is greater than the new start date or zero.
- Creates new pricing records with incremented sequence numbers.
- Logs new and expired records to a history file.
- Generates a printed report of old and new pricing details.
- Output:
- Updated pricing records in
BICUAG
. - History records in
BICUAGH
. - Updated sequence numbers in
BICONT
. - Printed report via
QSYSPRT
.
- Updated pricing records in
- Business Rules:
- Start date must match the work file’s start date.
- Existing records are expired only if their expiry date is greater than the new start date or zero.
- New records use unique sequence numbers.
- All changes are logged to the history file.
Function Requirement Document for Non-Interactive Automated Posting¶
Assuming the primary use case (Automated Posting of Customer Sales Agreement Pricing) is implemented as a non-interactive function that receives all inputs programmatically, below is a concise function requirement document. The document focuses on business requirements, process steps, and necessary calculations, omitting the interactive screen components.
Function Requirement Document: Automated Customer Sales Agreement Pricing Posting¶
Purpose¶
Automate the posting of customer sales agreement pricing by processing records from a temporary work file, updating or expiring existing pricing records, creating new pricing records, logging history, and generating a report, without user interaction.
Inputs¶
- File Group Parameter (
p$fgrp
): 1-character code ('G' or 'Z') to determine database file overrides (e.g.,GBICUAG
orZBICUAG
). - Work File (
BB203W
inQTEMP
): Contains pricing records with fields: new_bacono
: Company number.new_baseqn
: Sequence number.new_bacust
: Customer number.new_baloc
: Location.new_banprc
: New price.new_baoffp
: New off-price.new_banstd
: Start date (CCYYMMDD).- Other pricing fields (e.g.,
new_bapr01
tonew_bapr10
,new_bamnqy
,new_bamxqy
, etc.). - Start Date (
start_date
): CCYYMMDD format, provided programmatically (replacing user input via screen).
Outputs¶
- Updated Pricing File (
BICUAG
): Updated with expired records and new pricing records. - History File (
BICUAGH
): Logs new and expired pricing records. - Sequence File (
BICONT
): Updated with incremented sequence numbers. - Printed Report (
QSYSPRT
): Details old and new pricing information (company, customer, location, prices, dates, sequence numbers).
Process Steps¶
- Validate Input Data:
- Verify
BB203W
exists and contains records. - Ensure
start_date
matchesnew_banstd
inBB203W
for all records. -
If invalid or mismatched, return an error message and abort.
-
Clean Up Temporary File:
- Delete any existing
QTEMP/BB203W
file to ensure a clean slate. -
Create a new
BB203W
file by copying input data (replacing OCL’sCRTDUPOBJ
). -
Process Each Work File Record:
- Read all records from
BB203W
. -
For each record:
- Expire Existing Record:
- Chain to
BICUAG
usingnew_bacono
andnew_baseqn
. - If found and
baend8
(expiry date) is greater thanstart_date
or zero:- Calculate expiry date as
start_date - 1 day
(using date calculation logic). - Set
baend8
to expiry date,baentm
to 23:59, and updateBICUAG
. - Write expired record to
BICUAGH
.
- Calculate expiry date as
- If not found, note for reporting.
- Create New Record:
- Retrieve and increment sequence number from
BICONT
fornew_bacono
. - Chain to
BICUAG
with new sequence number to ensure no conflict. - Populate new
BICUAG
record withBB203W
fields, setting:bastd8
tostart_date
,basttm
to 00:01.baend8
andbaendt
to 0 (no expiry).
- Write new record to
BICUAG
andBICUAGH
. - Generate Report:
- Print a detail line to
QSYSPRT
with old and new pricing data (company, customer, location, prices, dates, sequence numbers). - Handle overflow by printing headers as needed.
-
Update Sequence File:
-
Update
BICONT
with the incremented sequence number for the company. -
Clean Up:
- Delete
QTEMP/BB203W
and remove file overrides.
Business Rules¶
- Data Validation:
start_date
must matchnew_banstd
in allBB203W
records.BB203W
must exist and contain records.- Expiry Logic:
- Expire existing
BICUAG
records only ifbaend8
>start_date
orbaend8
= 0. - Expiry date is set to
start_date - 1 day
at 23:59. - Sequence Number:
- New records use a unique sequence number, incremented from
BICONT
for the company. - History Logging:
- All new and expired records are logged to
BICUAGH
for audit purposes. - File Overrides:
- Use
p$fgrp
('G' or 'Z') to select appropriate database files (e.g.,GBICUAG
orZBICUAG
). - Error Handling:
- Abort with an error message if validation fails (e.g., missing file, mismatched start date).
- Reporting:
- Generate a report with headers and detail lines, including old/new prices, dates, and sequence numbers.
Calculations¶
- Expiry Date Calculation:
- Input:
start_date
(CCYYMMDD). - Output: Expiry date =
start_date - 1 day
(CCYYMMDD). - Logic: Use a date calculation routine (e.g., equivalent to
GSDTCLC1
) to subtract 1 day, handling month/year boundaries and leap years. - Example: If
start_date = 20250115
, expiry date =20250114
. - Sequence Number Increment:
- Retrieve
bcseqn
fromBICONT
fornew_bacono
. - Increment by 1 and update
BICONT
. - Example: If
bcseqn = 100
, new sequence number =101
.
Dependencies¶
- Files:
BICUAG
: Pricing records (update).BB203W
: Temporary work file (input).BICONT
: Sequence numbers (update).BICUAGH
: History records (output).QSYSPRT
: Printer file (output).- External Program:
- Date calculation routine (equivalent to
GSDTCLC1
) for expiry date computation.
Notes¶
- The function requirement document assumes a non-interactive process, replacing the interactive screen (
BB203D
) with a programmatically providedstart_date
. This simplifies the process by removing user interaction while preserving all business logic. - The cleanup use case (
BB203AC
) is integrated into the process steps to ensure a clean slate. - The validation use case from the OCL script is incorporated into the initial validation step.
- The document focuses on business requirements and calculations, ensuring clarity and conciseness for implementation.