Skip to content

196OCL

The provided files, AP196.ocl36.txt`` and AP196.rpg36 (1).txt, describe an A/P Voucher Status Code Update process within an IBM AS/400 (or IBM i) environment. The first file (AP196.ocl36.txt`) is an OCL (Operation Control Language) script that controls the execution flow, while the second (AP196.rpg36 (1).txt) is an RPG III program that handles the core logic for updating voucher status codes. Below, I’ll explain what these files do, outline the process steps, business rules, tables used, and any external programs called.


Overview of What These Files Do

  • AP196.ocl36.txt` (OCL Script): This script orchestrates the execution of the A/P voucher status code update process. It defines file allocations, conditionally runs the AP196 program to modify voucher status codes, and optionally calls AP197 to generate an edit report if errors are detected. The script ensures that the process terminates if no records are available for processing and manages output queues for reports.

  • AP196.rpg36 (1).txt (RPG III Program): This is the core program (AP196) that provides an interactive interface for users to modify the status codes (e.g., hold codes) of accounts payable (A/P) vouchers. It validates input data (company number, vendor number, voucher number), retrieves related records, allows users to update hold codes and descriptions, and updates or deletes records in the voucher control file (APVCTR). The program uses a workstation display to interact with the user via two screens: one for input validation and another for status code modification.

Together, these files implement a process to: - Allow users to update or delete the hold status of A/P vouchers. - Validate input against master files (company, vendor, open payables). - Generate an edit report (via AP197) if errors occur. - Ensure data integrity by checking for valid records and handling deletions appropriately.


Process Steps

  1. OCL Script Execution (AP196.ocl36.txt):
  2. File Allocation:
    • Allocates files: APVCTR (voucher control), APCONT (company master), APVEND (vendor master), and APOPNH (open payables header).
    • Uses shared disposition (DISP-SHR) to allow concurrent access.
  3. Initial Check:
    • Checks if the APVCTR file (?9?APVC?WS?) is empty (record count = 00000000).
    • If empty, the process jumps to the END tag and terminates.
  4. Run AP196:
    • Loads and executes the AP196 program to handle interactive voucher status updates.
  5. Error Handling and Reporting:
    • If AP196 processes records (i.e., APVCTR is not empty after execution), it loads AP197 to generate an edit report.
    • Overrides the printer file (LIST) to direct output to either QUSRSYS/APSTEDIT or QUSRSYS/TESTOUTQ based on a condition (?9?/G).
    • Copies the report to an output queue (APSTEDIT) with the name “AP STATUS CHG EDIT” and moves it to JUNKOUTQ if necessary.
  6. Termination:

    • If no records remain in APVCTR, the process ends.
  7. RPG Program Execution (AP196.rpg36):

  8. Screen 1 (AP196S1):
    • Displays a screen to accept user input: company number (CONO), vendor number (VEND), and voucher number (VOUCH).
    • Validates input by chaining (looking up) records in:
    • APCONT (company master) to verify the company number.
    • APVEND (vendor master) to verify the vendor number.
    • APVCTR (voucher control) to check if a voucher record exists.
    • APOPNH (open payables header) to retrieve additional voucher details.
    • If any validation fails (e.g., invalid company, vendor, or voucher), an error message is displayed (from the COM array), and the user is prompted to correct the input.
    • If valid, retrieves the current hold code (HOLD) and hold description (HLDDSC) from either APVCTR or APOPNH and proceeds to Screen 2.
  9. Screen 2 (AP196S2):
    • Displays the validated voucher details along with the current hold code and description.
    • Allows the user to modify the hold code (HOLD) and hold description (HLDDSC).
    • Updates the APVCTR file with the new values or deletes the record if requested.
  10. Function Key Handling:
    • KA (Rekey): Clears the screen and redisplays Screen 1 for new input without adding or updating records.
    • KD (Delete): Deletes the voucher record from APVCTR if it exists.
    • KG (End of Job): Terminates the program.
  11. Record Processing:
    • If a record exists in APVCTR, it updates the hold code and description.
    • If no record exists, it may create a new record or display an error.
    • Deletes records from APVCTR when the delete function is invoked.
  12. Error Handling:
    • Sets indicators (e.g., 81, 82, 90, 91) to control screen display and error messages.
    • Clears fields after each operation to prevent data carryover.

Business Rules

  1. Input Validation:
  2. The company number (CONO) must exist in APCONT and not be marked as deleted (ACDEL ≠ 'D').
  3. The vendor number (VEND) must exist in APVEND and not be marked as deleted (VNDEL ≠ 'D').
  4. The voucher number (VOUCH) must correspond to a valid record in either APVCTR or APOPNH. If not found in APVCTR, it checks APOPNH.
  5. Invalid inputs trigger error messages (e.g., “INVALID COMPANY #”, “INVALID VENDOR #”, “INVALID COMBINATION”).

  6. Hold Code and Description:

  7. The hold code (HOLD) and hold description (HLDDSC) can be updated in APVCTR.
  8. If a voucher exists in APOPNH, its hold code (OPHALT) and description (OPHDES) are used as defaults if no APVCTR record exists.
  9. The hold code and description are written to APVCTR when updated or added.

  10. Record Deletion:

  11. A voucher record can be deleted from APVCTR using the KD function key.
  12. Deletion is only performed if the record exists in APVCTR.

  13. Error Reporting:

  14. If errors occur during processing, AP197 is called to generate an edit report listing issues.
  15. The report is sent to a specified output queue for review.

  16. Data Integrity:

  17. The program ensures that only valid vouchers are processed by checking master files.
  18. Fields are cleared after each operation to prevent residual data from affecting subsequent transactions.

Tables Used

The following files (tables) are referenced in the OCL script and RPG program:

  1. APVCTR (Voucher Control File):
  2. Type: Update file (UF in RPG).
  3. Fields:
    • ATKEY (key field, 12 bytes, includes company, vendor, and voucher numbers).
    • ATHOLD (hold code, 1 byte).
    • ATHLDS (hold description, 25 bytes).
    • ATOHLD (open hold code, 1 byte).
    • ATOHDS (open hold description, 25 bytes).
  4. Purpose: Stores voucher status codes and descriptions. Updated or deleted by AP196.

  5. APCONT (Company Master File):

  6. Type: Input file (IF in RPG).
  7. Fields:
    • ACDEL (delete flag, 1 byte, 'D' indicates deleted).
    • ACNAME (company name, 30 bytes).
  8. Purpose: Validates company numbers and retrieves company names for display.

  9. APVEND (Vendor Master File):

  10. Type: Input file (IF in RPG).
  11. Fields:
    • VNDEL (delete flag, 1 byte, 'D' indicates deleted).
    • VNCO (company number, 29 bytes).
    • VNVEND (vendor number, 5 bytes).
    • VNNAME (vendor name, 30 bytes).
  12. Purpose: Validates vendor numbers and retrieves vendor names for display.

  13. APOPNH (Open Payables Header File):

  14. Type: Input file (IF in RPG).
  15. Fields:
    • OPDEL (delete flag, 1 byte, 'D' indicates deleted).
    • OPCONO (company number, 29 bytes).
    • OPVEND (vendor number, 5 bytes).
    • OPVONO (voucher number, 5 bytes).
    • OPHALT (hold code, 1 byte).
    • OPHDES (hold description, 25 bytes).
    • Other fields (e.g., invoice date, due date, gross amount) are defined but not used in this context.
  16. Purpose: Provides voucher details if no record exists in APVCTR. Supplies default hold code and description.

  17. SCREEN (Workstation File):

  18. Type: Combined file (CP in RPG).
  19. Purpose: Defines the interactive display for user input and output. Uses two formats:
    • AP196S1: Input screen for company, vendor, and voucher numbers.
    • AP196S2: Update screen for hold code and description.

External Programs Called

  1. AP197:
  2. Called By: AP196.ocl36.txt (OCL script).
  3. Purpose: Generates an edit report listing errors or changes made during the voucher status update process.
  4. Condition: Executed only if APVCTR contains records after AP196 runs (i.e., not empty).
  5. Files Used: APVCTR, APVEND, APCONT (same as AP196).
  6. Output: Report sent to QUSRSYS/APSTEDIT or QUSRSYS/TESTOUTQ, then copied to JUNKOUTQ withNo other external programs are called by the RPG program itself.

Detailed Summary

  • AP196.ocl36.txt script sets up the environment, runs AP196 program, and conditionally calls AP196 for reporting, ensuring efficient process control.
  • The AP196 program (RPG III)** provides an interactive interface for updating or deleting voucher status codes, with robust validation against master files.
  • Business rules ensure data integrity through validation and deletion checks.
  • Tables include voucher control (APVCTR), company master (APCONT), vendor master (VEND), and open payables (APOPNH).
  • External program AP197 is used for error reporting.

This process is typical of legacy AS/400 applications for managing A/P workflows, focusing on user-driven updates with strong validation to maintain accurate financial records.