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 theAP196
program to modify voucher status codes, and optionally callsAP197
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¶
- OCL Script Execution (
AP196.ocl36.txt
): - File Allocation:
- Allocates files:
APVCTR
(voucher control),APCONT
(company master),APVEND
(vendor master), andAPOPNH
(open payables header). - Uses shared disposition (
DISP-SHR
) to allow concurrent access.
- Allocates files:
- 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.
- Checks if the
- Run
AP196
:- Loads and executes the
AP196
program to handle interactive voucher status updates.
- Loads and executes the
- Error Handling and Reporting:
- If
AP196
processes records (i.e.,APVCTR
is not empty after execution), it loadsAP197
to generate an edit report. - Overrides the printer file (
LIST
) to direct output to eitherQUSRSYS/APSTEDIT
orQUSRSYS/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 toJUNKOUTQ
if necessary.
- If
-
Termination:
- If no records remain in
APVCTR
, the process ends.
- If no records remain in
-
RPG Program Execution (
AP196.rpg36
): - 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 eitherAPVCTR
orAPOPNH
and proceeds to Screen 2.
- Displays a screen to accept user input: company number (
- 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.
- 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.
- 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.
- If a record exists in
- 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¶
- Input Validation:
- The company number (
CONO
) must exist inAPCONT
and not be marked as deleted (ACDEL ≠ 'D'
). - The vendor number (
VEND
) must exist inAPVEND
and not be marked as deleted (VNDEL ≠ 'D'
). - The voucher number (
VOUCH
) must correspond to a valid record in eitherAPVCTR
orAPOPNH
. If not found inAPVCTR
, it checksAPOPNH
. -
Invalid inputs trigger error messages (e.g., “INVALID COMPANY #”, “INVALID VENDOR #”, “INVALID COMBINATION”).
-
Hold Code and Description:
- The hold code (
HOLD
) and hold description (HLDDSC
) can be updated inAPVCTR
. - If a voucher exists in
APOPNH
, its hold code (OPHALT
) and description (OPHDES
) are used as defaults if noAPVCTR
record exists. -
The hold code and description are written to
APVCTR
when updated or added. -
Record Deletion:
- A voucher record can be deleted from
APVCTR
using the KD function key. -
Deletion is only performed if the record exists in
APVCTR
. -
Error Reporting:
- If errors occur during processing,
AP197
is called to generate an edit report listing issues. -
The report is sent to a specified output queue for review.
-
Data Integrity:
- The program ensures that only valid vouchers are processed by checking master files.
- 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:
APVCTR
(Voucher Control File):- Type: Update file (
UF
in RPG). - 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).
-
Purpose: Stores voucher status codes and descriptions. Updated or deleted by
AP196
. -
APCONT
(Company Master File): - Type: Input file (
IF
in RPG). - Fields:
ACDEL
(delete flag, 1 byte, 'D' indicates deleted).ACNAME
(company name, 30 bytes).
-
Purpose: Validates company numbers and retrieves company names for display.
-
APVEND
(Vendor Master File): - Type: Input file (
IF
in RPG). - Fields:
VNDEL
(delete flag, 1 byte, 'D' indicates deleted).VNCO
(company number, 29 bytes).VNVEND
(vendor number, 5 bytes).VNNAME
(vendor name, 30 bytes).
-
Purpose: Validates vendor numbers and retrieves vendor names for display.
-
APOPNH
(Open Payables Header File): - Type: Input file (
IF
in RPG). - 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.
-
Purpose: Provides voucher details if no record exists in
APVCTR
. Supplies default hold code and description. -
SCREEN
(Workstation File): - Type: Combined file (
CP
in RPG). - 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¶
AP197
:- Called By:
AP196.ocl36.txt
(OCL script). - Purpose: Generates an edit report listing errors or changes made during the voucher status update process.
- Condition: Executed only if
APVCTR
contains records afterAP196
runs (i.e., not empty). - Files Used:
APVCTR
,APVEND
,APCONT
(same asAP196
). - Output: Report sent to
QUSRSYS/APSTEDIT
orQUSRSYS/TESTOUTQ
, then copied toJUNKOUTQ
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 callsAP196
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.