Skip to content

Below, I will first identify the use cases implemented by the BB204.ocl36 OCL script and the BB204.rpgle RPG program, which together form a call stack for automating customer sales agreement pricing. Then, I will provide a concise function requirement document for a large function that encapsulates the primary use case, assuming it processes inputs programmatically rather than through a screen.


Use Cases Implemented by the BB204 Call Stack

The BB204.ocl36 script and BB204.rpgle program work together to automate the posting of customer sales agreement pricing. Based on the provided code, the following use cases are implemented:

  1. Auto-Post Customer Sales Agreement Pricing:
  2. Description: Processes a batch of pricing records from a work file (bb204t), validates the start date, updates existing pricing records in the customer agreement file (bicuag), creates new pricing records, and maintains a history of changes in the history file (bicuagh). Generates a printed report of the changes.
  3. Inputs: Work file (bb204t) containing pricing records, user-entered start date (via display file bb204d), and file group parameter (G or Z).
  4. Outputs: Updated bicuag records, new bicuagh history records, cleared bb204t and PRSABLO files, and a printed report via qsysprt.
  5. Process: Validates the start date, checks for records in bb204t, updates or creates pricing records, increments sequence numbers via bicont, logs history, and prints a report.
  6. Business Rules:

    • Start date must match the start date in bb204t.
    • Existing records are updated only if their expiration date is greater than the new start date or zero.
    • New records are created with incremented sequence numbers.
    • History records are written for both updated and new pricing records.
    • A report is generated with old and new pricing details.
  7. Validate and Prepare Work File Environment:

  8. Description: Prepares the environment by creating a temporary work file (BB204W in QTEMP) from a workstation file, applying file overrides, and clearing output files (bb204t, PRSABLO) after processing.
  9. Inputs: Workstation file (?9?BB204?WS? or ?9?BB204WS), file group parameter (?9? in OCL).
  10. Outputs: Temporary file BB204W, cleared bb204t and PRSABLO, and removed overrides.
  11. Process: Duplicates the workstation file into QTEMP, applies overrides, and cleans up after processing.
  12. Business Rules:

    • The process halts if bb204t has no records.
    • Temporary files and overrides are removed post-processing to maintain a clean environment.
  13. Generate Pricing Change Report:

  14. Description: Produces a printed report detailing the pricing changes, including company, customer, location, old and new prices, sequence numbers, and dates.
  15. Inputs: Data from bb204t and bicuag during processing.
  16. Outputs: Printed report via qsysprt with headers and detail lines.
  17. Process: Writes header and detail lines to qsysprt, handling overflow conditions.
  18. Business Rules:

    • The report includes old and new pricing details, sequence numbers, and dates.
    • Headers are printed on overflow, including job, program, and user information.
  19. Maintain Pricing History:

  20. Description: Logs all pricing changes (both updated and new records) to a history file (bicuagh) for audit purposes.
  21. Inputs: Data from bb204t (new records) and bicuag (existing records).
  22. Outputs: Records in bicuagh with timestamps and user IDs.
  23. Process: Writes records to bicuagh during the postit subroutine for both new and expired records.
  24. Business Rules:
    • History records include all pricing fields, timestamps, and the user ID.
    • Change timestamps reflect the current date and time.

Function Requirement Document

The following function requirement document describes a single, programmatic function that encapsulates the primary use case: Auto-Post Customer Sales Agreement Pricing. It assumes the function receives all necessary inputs programmatically (e.g., start date, file group, and work file data) rather than through a screen interface.

Function Requirement Document: Auto-Post Customer Sales Agreement Pricing

Function Name

AutoPostCustomerPricing

Purpose

Automates the posting of customer sales agreement pricing by processing a batch of pricing records, updating or creating records in the customer agreement file, maintaining a history of changes, and generating a report.

Inputs

  • Start Date (startDate): Date in CCYYMMDD format for the new pricing records.
  • File Group (fileGroup): String ('G' or 'Z') to determine the library for file overrides.
  • Pricing Records (pricingRecords): Array of records containing pricing data (e.g., company number, customer number, location, price, contract number, etc.), equivalent to the bb204t work file.
  • Current Date/Time (currentDateTime): System timestamp in CCYYMMDDHHMMSS format for record creation and updates.

Outputs

  • Updated Customer Agreement File: Records updated or added to the customer agreement file (bicuag).
  • History File Records: Records written to the history file (bicuagh) for audit purposes.
  • Printed Report: Report generated via the printer file (qsysprt) detailing pricing changes.
  • Sequence Number Update: Updated sequence number in the control file (bicont).
  • Cleared Work Files: Cleared bb204t and PRSABLO files.

Process Steps

  1. Validate Inputs:
  2. Verify that startDate is a valid date (1–12 for month, valid days per month, leap year handling).
  3. Confirm that pricingRecords is not empty; if empty, return an error.
  4. Ensure startDate matches the start date in each pricingRecords entry.

  5. Apply File Overrides:

  6. Apply file overrides for bicuag, bicont, bicuagh, and bb204t based on fileGroup ('G' for gbicuag, etc.; 'Z' for zbicuag, etc.).
  7. Configure the printer file (qsysprt) with specified attributes (e.g., 68 lines, 184 characters, 8 LPI, 15 CPI).

  8. Process Pricing Records:

  9. For each record in pricingRecords:

    • Check Existing Record:
    • Query bicuag using company number (bacono) and sequence number (baseqn).
    • If found:
      • If the existing record’s expiration date (baend8) is greater than startDate or zero, update it to startDate - 1 day at 23:59.
      • Update the last updated date (baludt) and time (balutm) with currentDateTime.
      • Write the original record to bicuagh with the current timestamp and user ID.
    • If not found, initialize old values to zero/blank.
    • Create New Record:
    • Retrieve the next sequence number from bicont for the company number, increment it, and update bicont.
    • Create a new bicuag record with fields from pricingRecords (e.g., bacust, baloc, baprce, etc.).
    • Set creation/update timestamps (bacrdt, bacrtm, baludt, balutm) to currentDateTime.
    • Set start date (bastdt, bastd8) to startDate at 00:00.
    • Set expiration date (baendt, baend8) to a default (e.g., 2079/12/31) or as specified.
    • Write the new record to bicuagh.
    • Generate Report Line:
    • Write a detail line to qsysprt with company, customer, location, old/new prices, sequence numbers, and dates.
    • Handle overflow by printing headers as needed.
  10. Clean Up:

  11. Clear bb204t and PRSABLO files.
  12. Remove file overrides.
  13. Close all files.

Business Rules

  1. Start Date Validation:
  2. Must be a valid date (correct month, day, leap year handling).
  3. Must match the start date in each pricingRecords entry; otherwise, return an error.

  4. Expiration Date Calculation:

  5. For existing bicuag records, update the expiration date to startDate - 1 day at 23:59 if the current expiration is greater than startDate or zero.
  6. New records use a default expiration date (e.g., 2079/12/31) unless specified.

  7. Sequence Number Management:

  8. Retrieve the last sequence number from bicont for the company number, increment by 1, and update bicont.

  9. History Logging:

  10. Write both updated (expired) and new records to bicuagh with all pricing fields, currentDateTime as the change timestamp, and the user ID.

  11. Reporting:

  12. Generate a report with headers (company, program, user, date, time, file group) and detail lines (company, customer, location, old/new prices, sequence numbers, dates).
  13. Handle overflow by printing headers when the page limit (62 lines) is reached.

  14. Error Handling:

  15. Return errors for invalid start dates or empty pricingRecords.
  16. Log errors to a message queue for traceability.

Calculations

  • Expiration Date:
  • expirationDate = startDate - 1 day, calculated using a date arithmetic function (e.g., equivalent to GSDTCLC1).
  • Example: If startDate = 20251201, then expirationDate = 20251130.
  • Sequence Number:
  • newSequenceNumber = lastSequenceNumber (from bicont) + 1.
  • Date Formatting:
  • Convert startDate to CCYYMMDD with century indicator (1 for 20xx, 0 for 19xx).
  • Set start time to 00:00 and end time to 23:59 for new records.

Dependencies

  • Files:
  • bicuag: Customer agreement file (update/add).
  • bicont: Control file for sequence numbers (update).
  • bicuagh: History file (output).
  • bb204t: Work file with pricing records (input).
  • PRSABLO: Output file to be cleared.
  • qsysprt: Printer file for reporting.
  • External Function:
  • Date arithmetic function (e.g., GSDTCLC1) to calculate startDate - 1 day.

Error Handling

  • Return error codes/messages for:
  • Invalid or mismatched start date.
  • Empty pricingRecords.
  • File access or override failures.
  • Log errors to a message queue for audit purposes.


Notes

  • The primary use case (Auto-Post Customer Sales Agreement Pricing) is the core functionality, while the other use cases (environment preparation, reporting, and history maintenance) are supporting functions integrated into the main process.
  • The function requirement document assumes a programmatic interface, eliminating the need for the display file (bb204d) and user interaction (e.g., F09 key press). All inputs are provided upfront, making the process fully automated.
  • The document focuses on business requirements (validation, updates, history, reporting) and includes calculations (e.g., expiration date, sequence number) as specified in the RPG program.