Skip to content

Based on the provided documents (BI945P.ocl36.txt, BI945P.rpgle.txt, BI9445.ocl36.txt, BI944X.rpg.txt, and BI9445.rpgle.txt), the call stack represents a process for managing and reporting customer sales agreements on an IBM midrange system (e.g., AS/400 or iSeries). The stack involves OCL scripts orchestrating RPG programs to process, validate, and report sales agreement data. Below, I’ll identify the use cases implemented by this call stack and then provide a concise function requirement document for the primary use case, treating it as a large function that processes inputs programmatically.


List of Use Cases

The call stack implements the following use cases, each addressing a distinct business need within the customer sales agreement process:

  1. Prepare Sales Agreement Data for Processing:
  2. Description: Extracts customer and product data from the PRSABLX file and populates the Local Data Area (LDA) with up to 30 unique product codes and a customer number for downstream processing.
  3. Components:
    • BI945P.ocl36.txt: Loads PRSABLX and conditionally calls BI9445 (via job queue or directly).
    • BI945P.rpgle.txt: Processes PRSABLX records, assigns customer number to kycs01, and stores unique product codes in kypd01kypd30.
  4. Purpose: Prepares filtered data (customer and products) to be used by subsequent programs for reporting or updates.

  5. Generate Customer Sales Agreement Price Change Report:

  6. Description: Produces a detailed report of customer sales agreements, including product codes, customer details, pricing, freight terms, and start/end dates, with options for printed and Excel-compatible outputs. Validates data and flags errors.
  7. Components:
    • BI9445.ocl36.txt: Clears files, updates LDA, sorts data, and calls BI944X and BI9445.
    • BI944X.rpg.txt: Updates BICUAG with salesman, product class, and division, filtering out expired agreements.
    • BI9445.rpgle.txt: Processes sorted data, retrieves reference data, computes new prices, and generates reports (prtdown, prtexcel).
  8. Purpose: Provides a comprehensive report for auditing or managing sales agreements, including price changes and validation errors.

  9. Update CRM System with Sales Agreement Data:

  10. Description: Updates the BICUAGC file with sales agreement data for hourly uploads to a CRM system, including customer, product, pricing, and freight details.
  11. Components:
    • BI9445.ocl36.txt: Configures the process and calls BI9445.
    • BI9445.rpgle.txt: Writes to BICUAGC when indicator U3 is on (hourly run).
  12. Purpose: Ensures CRM system has up-to-date sales agreement data for external integration.

  13. Update Work File for New Start Dates:

  14. Description: Writes new start dates and agreement data to the BB204T work file for use in subsequent processes (e.g., agreement table updates).
  15. Components:
    • BI9445.ocl36.txt: Clears BB204T and calls BI9445.
    • BI9445.rpgle.txt: Outputs agreement data to BB204T when kyadda = 'Y'.
  16. Purpose: Supports downstream processes that update agreement tables with new start dates.

Function Requirement Document

The primary use case, Generate Customer Sales Agreement Price Change Report, is the most comprehensive, encompassing data preparation, validation, price calculations, and reporting. Below is a function requirement document for this use case, treated as a large function that accepts inputs programmatically and produces outputs without screen interaction.

Customer Sales Agreement Price Change Report Function

Purpose

Generate a report of customer sales agreements, including product codes, customer details, pricing, freight terms, and start/end dates, while validating data and optionally updating work and CRM files. The function processes input data programmatically and produces printed and Excel-compatible reports.

Inputs

  • Sales Agreement Data (PRSABLX): File with customer number, product codes, start/end dates, prices, and contract details.
  • Reference Files:
  • BICUAG: Raw sales agreement data.
  • ARCUST: Customer master data (name, salesman).
  • GSTABL: Product class and division descriptions.
  • GSCNTR1: Container codes.
  • SHIPTO: Ship-to addresses (city, state).
  • ARCUPR: Previous pricing data.
  • ARCUSP, BBPRCY, INLOC, GSUMCV, BICONT, BICUA7: Additional reference data for validation and enrichment.
  • LDA Parameters:
  • kycs01kycs20: Customer numbers for inclusion/exclusion.
  • kypd01kypd30: Product codes for filtering.
  • kysprd: Special pricing flag ('Y'/'N').
  • kyindc: Price index for adjustments.
  • kydlch: Price delta change (packed decimal).
  • kyadda: Add/update flag ('Y'/'N').
  • kystd8: System date for comparison (CYMD).
  • kydiv, kylosl, kycssl, kypdsl, kyumsl, kydvno, kyjobq: Filtering parameters (division, location, etc.).

Outputs

  • Printed Report (prtdown): 164-byte report with headers, customer/product details, prices, freight terms, dates, and error messages.
  • Excel Report (prtexcel): 224-byte Excel-compatible report with additional fields (e.g., off-price).
  • Work File (BB204T): 327-byte file with new start dates and agreement data (if kyadda = 'Y').
  • CRM File (BICUAGC): 271-byte file for CRM uploads (if U3 is on).
  • Temporary Files: BICUAGX, BICUAG2, BI944S, BI944T (cleared post-process).

Process Steps

  1. Prepare Input Data:
  2. Read PRSABLX and store customer number in kycs01 and up to 30 unique product codes in kypd01kypd30 in LDA.
  3. Clear temporary files (BICUAGX, BICUAG2, BI944S, BI944T, BB204T).
  4. Update Sales Agreement Data:
  5. Process BICUAG to add salesman (ARSLS# from ARCUST), product class (TBPRCL), and division (TBCSRT) from GSTABL.
  6. Filter out agreements with end date (BAEND8) before system date (KYDAT8) unless zero (perpetual).
  7. Write updated records to BICUAGX (263 bytes, includes division, product class, salesman).
  8. Sort Data:
  9. Sort BICUAGX into BI944S by company, customer, container code, location, and contract, using inclusion (kycs01kycs20) or exclusion logic based on LDA (kystyp = 'EXCLUDE').
  10. Copy BI944S to BICUAG2.
  11. Sort BICUAG2 into BI944T by company, division, product class, product code, customer, and ship-to.
  12. Generate Report:
  13. Read BI944T and validate against reference files:
    • Customer name from ARCUST.
    • Ship-to city/state from SHIPTO.
    • Product class description from GSTABL.
    • Container code from GSCNTR1.
    • Previous price from ARCUPR (try container code, then blank, then 'P' for non-fluid).
  14. Compute new price: If kysprd = 'Y', apply kyindc and kydlch to current price (baprce).
  15. Output to prtdown and prtexcel:
    • Headers: Division, report mode, date, time, column titles (Product Code, Description, Customer No., Name, Ship-to, Location, Container, Prices, Freight Terms, Dates).
    • Details: Product code (bapr01), description, customer number, name, ship-to (baship or 'ALL'), city/state, container code, current price (baprce), previous price (prvprc), off-price (baoffp), location, unit of measure, freight terms, start/end dates, new price, quantities (bamnqy, bamxqy).
    • Total: Record count.
  16. Write to BB204T (new start dates) if kyadda = 'Y'.
  17. Write to BICUAGC (CRM data) if U3 is on.
  18. Clean Up:
  19. Delete temporary files (BI944S, BI944T).
  20. Reset LDA and switches.

Business Rules

  1. Data Filtering:
  2. Include only unexpired agreements (baend8 ≥ kystd8 or baend8 = 0).
  3. Filter by customer numbers (kycs01kycs20) and products (kypd01kypd30) based on inclusion/exclusion logic (kystyp).
  4. Apply division (kydiv), location (kylosl), and other LDA filters.
  5. Price Calculation:
  6. Retrieve previous price (prvprc) from ARCUPR using company, customer, product, and container code (priority: exact, blank, 'P' for non-fluid).
  7. If kysprd = 'Y', compute new price: price = baprce + (baprce × kyindc) + kydlch.
  8. Freight Terms:
  9. Use freight code (bafrcd) from BICUAGXX (e.g., COLLECT, PPD & ADD).
  10. Compute freight difference (frtdif) for CNY (freight collect from non-Bradford locations).
  11. Date Handling:
  12. Display '00/00/00' for perpetual agreements (baend8 = 0).
  13. Validate start/end dates against kystd8.
  14. Error Handling:
  15. Flag errors for missing product class, invalid product, or missing ship-to record.
  16. Output Modes:
  17. If kyadda = 'Y', update BB204T and BICUAGC (if U3 is on).
  18. If kyadda = 'N', generate report only.
  19. CRM Integration:
  20. Update BICUAGC only during hourly runs (U3 on).

Calculations

  • New Price:
  • Formula: price = baprce + (baprce × kyindc / 100) + kydlch (if kysprd = 'Y').
  • Example: If baprce = 100.00, kyindc = 5 (5%), kydlch = 2.00, then price = 100 + (100 × 0.05) + 2 = 107.00.
  • Freight Difference:
  • For bafrcd = 'CNY' and non-Bradford location, compute frtdif based on location-specific rules (not detailed in code).

Assumptions

  • Input files are pre-populated (GPRSABLO to PRSABLX).
  • LDA parameters are set by upstream processes or defaults.
  • Output files are accessible for writing.
  • No screen interaction; inputs are file-based or LDA-based.

Constraints

  • File access uses shared read mode for reference files to ensure data integrity.
  • BICUAGC updates require U3 indicator (hourly run).
  • Temporary files are cleared post-process to prevent data overlap.


Notes

  • The Prepare Sales Agreement Data for Processing use case is a prerequisite for the reporting and update use cases, as it populates the LDA with filtered data.
  • The Update CRM System and Update Work File use cases are conditional, depending on U3 and kyadda, respectively, and are executed within the reporting process.
  • The function requirement document focuses on the primary reporting use case, as it integrates all components of the call stack. If separate documents for the other use cases are needed, please specify.