The call stack provided includes the following RPGLE programs called from the OCL procedure BB943INQ.ocl36.txt: BB943, BB943V, BB9433, BB944, GSDTCLC1, and GB730P. These programs collectively implement a customer sales agreement maintenance system, handling creation, validation, copying/updating, deletion/reactivation, and history inquiry for sales agreements in an IBM System/36 (or AS/400 compatibility mode) environment. Below, I’ll identify the use cases implemented by this call stack and then provide a concise function requirement document for each use case, assuming they are large functions that process inputs programmatically rather than interactively via screens.
List of Use Cases¶
Based on the analysis of the provided programs (BB943, BB943V, BB9433, BB944, GSDTCLC1, GB730P), the following distinct use cases are implemented within the call stack:
- Create or Update Sales Agreement (BB943, BB943V, BB9433):
- Description: Allows creation of new sales agreements or updating existing ones, including copying agreements to other locations, ship-tos, or customer-ship-to combinations.
-
Programs Involved:
BB943: Handles user interaction via display filebb943d, collects input, and callsBB943VandBB9433.BB943V: Validates input data (customer, container, products, dates).BB9433: Processes the creation or update, writes tobicuag, expires original records, and logs tobicuagh.GSDTCLC1: Performs date calculations (e.g., adjusting expiration dates).
-
Delete or Reactivate Sales Agreement (BB944):
- Description: Marks a sales agreement as deleted or reactivates a previously deleted agreement, logging changes to the history file.
-
Programs Involved:
BB944: Handles user interaction via display filebb944d, updatesbicuag(sets/clearsbadel), and writes tobicuagh.GSDTCLC1: May be used for date validation or calculations (if called in truncated logic).
-
View Sales Agreement History (GB730P):
- Description: Displays historical data for sales agreements and related entities (e.g., pricing, freight, orders) for inquiry purposes.
- Programs Involved:
GB730P: Retrieves and displays historical records from multiple files (e.g.,bicuaghx,bbordhsx) via display filegb730pdwith subfileSFL1.GSDTCLC1: May be used for date formatting or calculations (if called in truncated logic).
These three use cases cover the core functionalities of the customer sales agreement maintenance system: creating/updating agreements, deleting/reactivating agreements, and viewing historical changes. Each use case is treated as a large function that accepts inputs programmatically and processes them without screen interaction.
Function Requirement Documents¶
Below are the function requirement documents for each use case, presented concisely with business requirements, process steps, and necessary calculations. Each function assumes programmatic input and output, bypassing interactive screen handling.
Use Case 1: Create or Update Sales Agreement¶
Function Requirement: Create or Update Sales Agreement¶
Purpose¶
Create a new customer sales agreement or update an existing one, including copying to other locations, ship-tos, or customer-ship-to combinations, expiring original records if needed, and logging changes to history.
Inputs¶
- Company Number (
cono, 2.0): Identifies the company. - Sequence Number (
seqn, numeric): Unique identifier for the agreement (0 for new). - Customer Number (
cust, 6.0): Customer ID. - Location (
loc, 3A): Primary location code. - Container Code (
cntr, 3A): Container identifier. - Unit of Measure (
unms, 3A): Unit of measure for the agreement. - All Ship-tos Flag (
alsh, 1A):'Y'to apply to all ship-tos,'N'otherwise. - Ship-to Number (
ship, 3.0): Specific ship-to location. - Product Codes (
pr01–pr10, 4A each): Up to 10 product codes. - Bill-to Purchase Order (
pord, 15A): Purchase order number. - Price (
prce, 9.4 packed): Agreement price. - Off-Price (
offp, 9.4 packed): Discounted price. - Freight Code (
frcd, 1A): Freight terms. - Delivery Code (
delv, 3A): Delivery method. - Prepaid Flag (
ppd, 1A):'P'for prepaid, blank otherwise. - Pricing Type (
prim, 1A):'I'(item) or'M'(miscellaneous). - Minimum Quantity (
mnqy, numeric): Minimum order quantity. - Maximum Quantity (
mxqy, numeric): Maximum order quantity. - Contract Number (
cntn, numeric): Contract identifier. - PO/Order Code (
poor, 15A): Purchase order or order code. - Start Date (
std8, 8.0, CCYYMMDD): Agreement start date. - Start Time (
sttm, 6.0, HHMMSS): Agreement start time. - End Date (
end8, 8.0, CCYYMMDD): Agreement end date (0 if none). - End Time (
entm, 6.0, HHMMSS): Agreement end time. - Add/Update Flag (
addupd, 1A):'A'for add,'U'for update. - Expire Flag (
expr, 1A):'Y'to expire original record,'N'otherwise. - Other Locations (
locs, 30A): Array of up to 10 location codes (3A each). - Other Ship-tos (
shp, 30A): Array of up to 10 ship-to codes (3A each). - Other Customer-Ship-tos (
cshp, 36A): Array of up to 4 customer/ship-to pairs (9A each: 6A customer + 3A ship-to). - Original Key Fields (
o@cono,o@cust,o@loc,o@cntr,o@unms,o@ship,o@pr01–o@pr10,o@pord,o@mnqy,o@mxqy,o@std8,o@sttm): Key for expiring record. - File Group (
fgrp, 1A):'G'or'Z'for file library selection.
Outputs¶
- Return Flag (
flag, 1A):'1'for success,'0'for failure. - Error Messages (array): List of validation errors, if any.
Process Steps¶
- Validate Inputs:
- Verify
conoexists inbicont. - Validate
custinarcusz,locincuadrx,shipinshipto,cntringscntr1,unmsingsctum,pr01–pr10ingsprod,frcdingstabl,delvingstabl. - Ensure
std8andend8(if non-zero) are valid dates usingGSDTCLC1. - Check for duplicate agreements in
bicuag(same key fields andstd8, unlessfrcddiffers). - Validate
locs,shp,cshparrays for non-blank entries and valid codes. - Process Primary Agreement:
- If
addupd = 'A', create new record inbicuagwith input fields (bacono,bacust,baloc,bacntr,baunms,baship,bapr01–bapr10,bapord,baprce,baoffp,bafrcd,badelv,bappd,baprim,bamnqy,bamxqy,bacntn,bapoor,bastd8,basttm,baend8,baentm). - If
addupd = 'U', update existing record inbicuagusingconoandseqn. - Copy to Other Locations/Ship-tos/Customer-Ship-tos:
- For each non-blank
locsentry, create/updatebicuagrecord withbaloc = locs[i]. - For each non-blank
shpentry, create/updatebicuagrecord withbaship = shp[i]. - For each non-blank
cshpentry, create/updatebicuagrecord withbacust = cshp[i].cust,baship = cshp[i].ship. - Expire Original Record:
- If
expr = 'Y', locate original record inbicuagusingo@cono,o@cust,o@loc,o@cntr,o@unms,o@ship,o@pr01–o@pr10,o@pord,o@mnqy,o@mxqy,o@std8,o@sttm. - If original
baend8 > std8orbaend8 = 0, setbaend8 = std8 - 1 minute(usingGSDTCLC1) and updatebicuag. - Write expired record to
bicuaghwith audit fields (hhchd8,hhchtm,hhuser). - Log to History:
- For each new/updated record, write to
bicuaghwith current date (hhchd8), time (hhchtm), and user (hhuser). - Return Status:
- Set
flag = '1'on success,'0'on validation failure with error messages.
Business Rules¶
- Validation: All codes must exist in respective files; dates must be valid; no duplicate agreements unless freight codes differ.
- Add vs. Update:
'A'creates new records with newseqn;'U'updates existing records byconoandseqn. - Copying: Agreements can be copied to multiple locations, ship-tos, or customer-ship-to pairs, creating separate
bicuagrecords. - Expiration: Original record expires only if its end date is greater than the new start date or is zero; expiration sets end date to one minute before new start date.
- History Logging: All created/updated/expired records are logged to
bicuaghwith audit fields. - File Groups: Use
GorZlibraries based onfgrp.
Calculations¶
- Date Validation: Use
GSDTCLC1to validatestd8andend8(YYYYMMDD format). - Expiration Date: If expiring, calculate
baend8 = std8 - 1 minuteusingGSDTCLC1withDifFmt = 'D',Diff = -1.
Use Case 2: Delete or Reactivate Sales Agreement¶
Function Requirement: Delete or Reactivate Sales Agreement¶
Purpose¶
Mark a customer sales agreement as deleted or reactivate a previously deleted agreement, logging changes to the history file.
Inputs¶
- Company Number (
cono, 2.0): Identifies the company. - Sequence Number (
seqn, numeric): Unique identifier for the agreement. - Action (
action, 1A):'D'for delete,'R'for reactivate. - File Group (
fgrp, 1A):'G'or'Z'for file library selection.
Outputs¶
- Return Flag (
flag, 1A):'1'for success,'0'for failure. - Error Messages (array): List of validation errors, if any.
Process Steps¶
- Validate Inputs:
- Verify
conoexists inbicont. - Verify
seqnexists inbicuagusing key (cono,seqn). - Validate
actionas'D'or'R'. - Retrieve Record:
- Chain to
bicuagwithconoandseqnto retrieve the agreement. - Process Action:
- If
action = 'D'andbadel ≠ 'Y', setbadel = 'Y'to mark as deleted. - If
action = 'R'andbadel = 'Y', setbadel = ' 'to reactivate. - Log to History:
- Write updated record to
bicuaghwith audit fields (hhchd8,hhchtm,hhuser). - Update Record:
- Update
bicuagwith modifiedbadel. - Return Status:
- Set
flag = '1'on success,'0'on validation failure with error messages.
Business Rules¶
- Delete: Only active records (
badel ≠ 'Y') can be deleted; setsbadel = 'Y'. - Reactivate: Only deleted records (
badel = 'Y') can be reactivated; clearsbadel. - History Logging: All changes are logged to
bicuaghwith current date, time, and user. - Validation: Agreement must exist;
actionmust be valid. - File Groups: Use
GorZlibraries based onfgrp.
Calculations¶
- None required (no date calculations; audit fields use current date/time).
Use Case 3: View Sales Agreement History¶
Function Requirement: View Sales Agreement History¶
Purpose¶
Retrieve and return historical data for customer sales agreements and related entities (e.g., pricing, freight, orders) based on selection criteria.
Inputs¶
- Company Number (
cono, 2.0): Identifies the company (optional, filters records). - Customer Number (
cust, 6.0): Customer ID (optional, perjk01). - File Type (
filetype, string): Specifies file to query (e.g.,bicuaghx,bbordhsx,bbcfsdhx). - Date Range (
start_date,end_date, 8.0, CCYYMMDD): Filters records by change date (optional). - File Group (
fgrp, 1A):'G'or'Z'for file library selection.
Outputs¶
- Historical Records (array): List of records with fields (e.g.,
hhcono,hhcust,hhloc,hhprce,hhpoor,hhchd8,hhuserforbicuaghx). - Return Flag (
flag, 1A):'1'for success,'0'for failure. - Error Messages (array): List of validation errors, if any.
Process Steps¶
- Validate Inputs:
- If
conoprovided, verify it exists inglcont. - If
custprovided, verify it exists inarcusz. - Validate
filetypeagainst supported files (e.g.,bicuaghx,bbordhsx). - Validate
start_dateandend_dateusingGSDTCLC1(if provided). - Retrieve Records:
- Based on
filetype, read records from the corresponding history file (e.g.,bicuaghxfor sales agreements). - Apply filters:
cono,cust,hhchd8withinstart_dateandend_date. - Format Output:
- Map fields to output structure (e.g., for
bicuaghx:hhcono,hhcust,hhloc,hhcntr,hhpr01–hhpr10,hhprce,hhoffp,hhpoor,hhchd8,hhchtm,hhuser). - Convert dates to display format (CCYYMMDD to MMDDYY) using
GSDTCLC1. - Return Results:
- Return array of records and set
flag = '1'on success,'0'on validation failure with error messages.
Business Rules¶
- File Selection: Supports multiple history files (e.g., sales agreements, orders, freight).
- Filtering: Allows filtering by company, customer, and date range; all optional.
- Validation: Ensures valid company, customer, and dates;
filetypemust be supported. - Field Support: Includes expanded fields (
BAPRCE,BAOFFP,BFTSEQ,BAPOOR,BKFSPC). - File Groups: Uses
GorZlibraries based onfgrp. - Error Handling: Returns error if system and program IDs are both provided.
Calculations¶
- Date Conversion: Uses
GSDTCLC1to converthhchd8(CCYYMMDD) to MMDDYY for output. - Date Validation: Uses
GSDTCLC1to validatestart_dateandend_date.
Notes¶
- Assumptions: Due to the truncation of
BB943,BB944, andGB730P, some process steps (e.g., main loop, subfile handling) were inferred based on context and patterns fromBB9433,BB944, and related files. The function requirements assume programmatic input/output, removing interactive screen logic fromBB943,BB944, andGB730P. - Integration: The programs rely on
GSDTCLC1for date calculations andQCMDEXC/QMHRMVPMfor system operations (file overrides, message handling). - Completeness: If you can provide the full source code for
BB943,BB944, orGB730P, or additional files (e.g., display filesbb943d,bb944d,gb730pd), I can refine the process steps and business rules further. - Artifact IDs: Each use case has a unique UUID (
artifact_id) as required, ensuring no overlap with historical artifacts.
Let me know if you need further clarification, additional details, or modifications to the function requirements!