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 theQTEMPlibrary 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/BB203Wfile, 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
BB203ACandBB203if 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 byBB203ACand 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.,GBICUAGorZBICUAG). - Work File (
BB203WinQTEMP): 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_bapr01tonew_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
BB203Wexists and contains records. - Ensure
start_datematchesnew_banstdinBB203Wfor all records. -
If invalid or mismatched, return an error message and abort.
-
Clean Up Temporary File:
- Delete any existing
QTEMP/BB203Wfile to ensure a clean slate. -
Create a new
BB203Wfile 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
BICUAGusingnew_baconoandnew_baseqn. - If found and
baend8(expiry date) is greater thanstart_dateor zero:- Calculate expiry date as
start_date - 1 day(using date calculation logic). - Set
baend8to expiry date,baentmto 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
BICONTfornew_bacono. - Chain to
BICUAGwith new sequence number to ensure no conflict. - Populate new
BICUAGrecord withBB203Wfields, setting:bastd8tostart_date,basttmto 00:01.baend8andbaendtto 0 (no expiry).
- Write new record to
BICUAGandBICUAGH. - Generate Report:
- Print a detail line to
QSYSPRTwith old and new pricing data (company, customer, location, prices, dates, sequence numbers). - Handle overflow by printing headers as needed.
-
Update Sequence File:
-
Update
BICONTwith the incremented sequence number for the company. -
Clean Up:
- Delete
QTEMP/BB203Wand remove file overrides.
Business Rules¶
- Data Validation:
start_datemust matchnew_banstdin allBB203Wrecords.BB203Wmust exist and contain records.- Expiry Logic:
- Expire existing
BICUAGrecords only ifbaend8>start_dateorbaend8= 0. - Expiry date is set to
start_date - 1 dayat 23:59. - Sequence Number:
- New records use a unique sequence number, incremented from
BICONTfor the company. - History Logging:
- All new and expired records are logged to
BICUAGHfor audit purposes. - File Overrides:
- Use
p$fgrp('G' or 'Z') to select appropriate database files (e.g.,GBICUAGorZBICUAG). - 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
bcseqnfromBICONTfornew_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.