Skip to content

197RPG

The AP197.rpg36.txt file is an RPG III program (AP197) designed to generate an edit report for the A/P Voucher Status Code Update process, complementing the functionality of AP196 described previously. Below, I provide a detailed explanation of what this program does, including its process steps, business rules, tables used, and any external programs called, formatted consistently with the prior response.


Overview of What AP197 Does

The AP197 program is responsible for producing a printed report that lists the details of voucher status code changes made by the AP196 program. It reads records from the voucher control file (APVCTR), retrieves associated company and vendor information, and formats a report to display vendor details, voucher numbers, current status codes, and their descriptions. The report serves as an audit trail or error-checking mechanism to verify the modifications made to voucher status codes, highlighting whether prior hold codes existed.

This program is called by the OCL script (AP196.ocl36.txt) when records remain in APVCTR after AP196 execution, ensuring that any changes are documented for review.


Process Steps

  1. Initialization:
  2. Retrieves the system time and date (TIMDAT) and formats them into SYSTIM (time) and SYSDAT (date) for inclusion in the report header.
  3. Initializes the page counter (PAGE) to zero.
  4. Sets a separator line (SEP) to "* " for formatting the report.

  5. Processing by Company (Level Break L2):

  6. Loops through records in APVCTR grouped by company number (ATCONO), using the level break indicator L2.
  7. For each company:

    • Chains (looks up) the company number in APCONT to retrieve the company name (ACNAME).
    • If the company is not found (indicator 92 on), the company name is not printed in the report header.
    • Initializes a field L2CLAM (likely a claim amount, but unused in output) to zero.
  8. Detail Record Processing:

  9. For each record in APVCTR:

    • Checks if the open hold code (ATOHLD) and open hold description (ATOHDS) are blank.
    • If both are blank, sets indicator 50 to indicate "NO PRIOR HOLD CODE" in the report.
    • Constructs a vendor key (VENKEY) by combining the company number (ATCONO) and vendor number (ATVEND).
    • Chains the vendor key to APVEND to retrieve the vendor name (VNAME).
    • If the vendor is not found (indicator 99 on), clears the vendor name (VENDNM) to blanks.
    • Writes a detail line to the report (LIST), including:
    • Vendor number (ATVEND).
    • Vendor name (VENDNM).
    • Voucher number (ATVOUC).
    • Current hold code (ATHOLD).
    • Current hold description (ATHLDS).
    • Open hold code (ATOHLD) and description (ATOHDS), if present; otherwise, "NO PRIOR HOLD CODE" is printed.
  10. Report Formatting:

  11. Outputs a report header for each company (on L2 break or overflow):
    • Includes the company name (ACNAME), page number (PAGE), and system date (SYSDAT).
    • Prints a title: "A/P VOUCHER STATUS CODE MODIFY EDIT" with the system time (SYSTIM).
  12. Outputs column headings:
    • "VENDOR", "NAME", "VOUCHER NUMBER", "STATUS CODE", "CODE DESCRIPTION", "CURRENT VALUES".
  13. Uses separator lines (SEP) to visually separate sections.
  14. Handles overflow (OF) to ensure proper pagination.

  15. Output Generation:

  16. Writes the formatted report to the printer file (LIST), which is directed to an output queue (e.g., QUSRSYS/APSTEDIT or QUSRSYS/TESTOUTQ) as specified in the OCL script.

Business Rules

  1. Data Validation:
  2. The program assumes that records in APVCTR are valid, as they are pre-processed by AP196.
  3. Company numbers (ATCONO) are validated against APCONT. If not found, the company name is omitted from the report header.
  4. Vendor numbers (ATVEND) are validated against APVEND. If not found, the vendor name is set to blanks in the report.

  5. Hold Code Reporting:

  6. If the open hold code (ATOHLD) and description (ATOHDS) are both blank, the report indicates "NO PRIOR HOLD CODE".
  7. Otherwise, the open hold code and description are printed to show the prior status.

  8. Report Structure:

  9. The report is grouped by company number (ATCONO), with a header printed for each company.
  10. Detail lines list each voucher's status, including current and prior hold codes.
  11. Page breaks are managed using the overflow indicator (OF) and level break (L2).

  12. Error Handling:

  13. Missing company or vendor records do not halt the program; instead, blank values are used in the report.
  14. The program does not modify any files, ensuring it is read-only and safe for audit purposes.

  15. Output Destination:

  16. The report is sent to the printer file (LIST), with the output queue controlled by the OCL script (AP196.ocl36.txt).

Tables Used

The following files (tables) are referenced in the AP197 program:

  1. APVCTR (Voucher Control File):
  2. Type: Input primary file (IP in RPG).
  3. Fields:
    • ATDEL (delete flag, 1 byte, not used in output).
    • ATCONO (company number, 2 bytes, used for level break and lookup).
    • ATVEND (vendor number, 5 bytes).
    • ATVOUC (voucher number, 5 bytes).
    • ATHOLD (current hold code, 1 byte).
    • ATHLDS (current hold description, 25 bytes).
    • ATOHLD (open hold code, 1 byte).
    • ATOHDS (open hold description, 25 bytes).
  4. Purpose: Primary input file containing voucher status records to be reported.

  5. APCONT (Company Master File):

  6. Type: Input chained file (IC in RPG).
  7. Fields:
    • ACNAME (company name, 30 bytes).
  8. Purpose: Provides company names for the report header, looked up by company number (ATCONO).

  9. APVEND (Vendor Master File):

  10. Type: Input file (IF in RPG).
  11. Fields:
    • VNDEL (delete flag, 1 byte, not used in output).
    • VNCO (company number, 29 bytes, not used in output).
    • VNVEND (vendor number, 5 bytes).
    • VNAME (vendor name, 30 bytes).
    • VNADD1 (address line 1, 30 bytes, not used in output).
  12. Purpose: Provides vendor names for the report, looked up by a composite key of company and vendor numbers.

  13. LIST (Printer File):

  14. Type: Output file (O in RPG).
  15. Purpose: Defines the report output format, with a line length of 132 characters. Used to print the edit report.

External Programs Called

  • None: The AP197 program does not call any external programs. It is a standalone report generator invoked by the OCL script (AP196.ocl36.txt) when needed.

Detailed Summary

  • Purpose: The AP197 program generates an edit report to document changes to voucher status codes made by AP196, serving as an audit or verification tool.
  • Process: Reads APVCTR records, retrieves company and vendor details, and formats a report with headers, column headings, and detail lines showing voucher status codes and descriptions.
  • Business Rules: Validates company and vendor data, handles missing records gracefully, and flags vouchers with no prior hold codes.
  • Tables: Uses APVCTR (primary input), APCONT (company lookup), APVEND (vendor lookup), and LIST (report output).
  • External Programs: None; operates independently under the control of the OCL script.

This program is a typical AS/400 reporting application, designed to provide a clear, structured output for financial oversight in an accounts payable context.