Skip to content

AP300P RPG

The provided RPG program, AP300P.rpg36.txt, is an RPG II program designed for the IBM System/36 environment, used in conjunction with the previously analyzed OCL script (AP300P.ocl36.txt). This program handles the prompting and validation for an Accounts Payable (A/P) monthly or yearly update process, specifically for updating Month-to-Date (MTD) and Year-to-Date (YTD) fields in the vendor master file. Below, I’ll explain the process steps, business rules, tables used, and external programs called, ensuring a clear and concise analysis tailored to the System/36 context.


Process Steps of the RPG Program

The RPG program AP300P is a prompting program that displays a screen to collect user input for the A/P update process, validates the input, and sets parameters for the update. Here’s a step-by-step breakdown of the process:

  1. File and Data Structure Definitions:
  2. Files:
    • SCREEN: A workstation file (display file) with 512-byte records, used to interact with the user via a screen format (AP300PS1).
    • APCONT: A disk file (vendor master file) with 256-byte records, indexed (2AI) with two keys, used for validation and data retrieval.
  3. Arrays and Data Structures:
    • MSG: An array of 8 elements, each 40 characters, holding error messages (defined at the end of the program).
    • CO: An array of 10 elements, each 35 characters, used to store company numbers and names for display.
    • UDS: User Data Structure (Local Data Area) for passing parameters, with fields like KYALCO, KYCO1, KYCO2, KYCO3, KYJOBQ, KYCANC, KYYTDY, and KYCCYY.
  4. Indicators:

    • Indicators 01, 09, 10, 11, 12, 50–55, 81, 90 control program flow, screen display, and error handling.
    • KG is a control-level indicator for cancel operations.
  5. Initialization (Lines 0036–0043):

  6. Clears the MSG40 field (used for error messages) to blanks.
  7. Turns off indicators 50–54 (error indicators), 81 (screen display), and 90 (general error).
  8. If the KG (cancel) indicator is on, sets KYCANC to CANCEL and skips further processing.

  9. One-Time Setup Subroutine (ONETIM, Lines 0050–0077):

  10. Executed once when indicator 09 is on (first cycle, line 0045).
  11. Purpose: Populates the CO array with company numbers and names from APCONT for display on the screen.
  12. Steps:

    • Initializes index X to 1.
    • Sets the file pointer to the first record in APCONT using key 01 (SETLL).
    • Loops through APCONT records (AGNONE loop):
    • Reads a record (READ APCONT).
    • Skips records marked as deleted (ACDEL = 'D').
    • Checks if the company number (ACCO) is not 99 and X is less than 11 (to limit to 10 companies).
    • If valid, formats the company number with a hyphen (COXX) and moves it along with the company name (ACNAME) to the CO array at index X.
    • Increments X and continues until the end of the file or X > 10.
    • Sets defaults:
    • KYALCO = 'ALL': Default to process all companies.
    • KYJOBQ = ' ': Default to no job queue.
    • KYYTDY = ' ': Default to not clearing YTD.
    • KYCCYY = 0: Default year to zero.
  13. Main Screen Processing Subroutine (S1, Lines 0079–0153):

  14. Executed when indicator 01 is on (line 0047), handling user input validation and screen display.
  15. Purpose: Validates user input from the SCREEN file (format AP300PS1) and sets parameters for the update process.
  16. Steps:

    • Validate Company Selection (Lines 0083–0099):
    • Checks if KYALCO is CO (specific companies) or ALL (all companies).
    • If neither, sets error indicators 81, 90, 50, displays message MSG,2 ("SECOND ENTRY MUST BE 'CO' OR 'ALL'"), and jumps to ENDS1.
    • If KYALCO = 'CO', checks if KYCO1, KYCO2, KYCO3 (company numbers) are all zero; if so, sets error indicators 81, 90, 51, displays MSG,3 ("INVALID COMPANY NUMBER"), and jumps to ENDS1.
    • If KYALCO = 'ALL' and any of KYCO1, KYCO2, KYCO3 are non-zero, sets error indicators 81, 90, 51, displays MSG,4 ("IF ALL, THEN DO NOT ENTER COMPANIES"), and jumps to ENDS1.
    • Validate Specific Companies (Lines 0103–0124):
    • If KYALCO = 'CO', validates each non-zero company number (KYCO1, KYCO2, KYCO3) using CHAIN to look up the company in APCONT.
    • If a company number is invalid (not found), sets error indicators (81, 90, and 51, 52, or 53 respectively), displays MSG,5 ("IF CO, THEN ENTER VALID COMPANIES"), and jumps to ENDS1.
    • Validate All Companies (Lines 0128–0136):
    • If KYALCO = 'ALL', sets the file pointer to the first record in APCONT (SETLL '01') and reads records to ensure valid data, but no specific validation is performed here.
    • Validate YTD Selection (Lines 0139–0143):
    • Checks if KYYTDY is Y (clear YTD) or blank (do not clear).
    • If neither, sets error indicators 81, 90, 54, displays MSG,7 ("YTD ENTRY MUST BE 'Y' OR ' '"), and jumps to ENDS1.
    • If KYYTDY = 'Y', checks if KYCCYY (year) is non-zero; if zero, sets error indicators 81, 90, 54, displays MSG,8 ("IF CLEAR YTD=Y, THEN KEY A 4 DIGIT YEAR"), and jumps to ENDS1.
    • Validate Job Queue Selection (Lines 0147–0151):
    • Checks if KYJOBQ is Y (submit to job queue), N, or blank (run immediately).
    • If invalid, sets error indicators 81, 90, 55, displays MSG,6 ("JOB QUEUE ENTRY MUST BE 'Y' OR ' '"), and jumps to ENDS1.
    • Screen Output (Lines 0156–0165):
    • If indicator 81 is on, displays the SCREEN file with format AP300PS1, showing:
      • KYALCO, KYCO1, KYCO2, KYCO3 (company selection fields).
      • CO array (company numbers and names).
      • KYYTDY (YTD clear flag).
      • KYCCYY (year for YTD clear).
      • KYJOBQ (job queue flag).
      • MSG40 (error message).
  17. Program Flow:

  18. The program loops through the S1 subroutine until all validations pass or the user cancels (KYCANC = 'CANCEL').
  19. If validations fail, error messages are displayed, and the screen is redisplayed for user correction.
  20. If validations pass, the program sets the Local Data Area fields (KYALCO, KYCO1, etc.) and returns control to the OCL script, which uses these to execute the update (via AP300 or job queue).

Business Rules

The program enforces the following business rules for the A/P update process:

  1. Company Selection:
  2. Users must select either ALL companies or specific companies (CO).
  3. If ALL is selected, no specific company numbers (KYCO1, KYCO2, KYCO3) should be entered.
  4. If CO is selected, at least one valid company number must be entered, and each must exist in the APCONT file.
  5. Invalid company selections trigger error messages (MSG,2, MSG,3, MSG,4, MSG,5).

  6. YTD Processing:

  7. Users can choose to clear YTD fields (KYYTDY = 'Y') or not (KYYTDY = ' ').
  8. If YTD is to be cleared, a valid 4-digit year (KYCCYY) must be provided (non-zero).
  9. Invalid YTD selections trigger error messages (MSG,7, MSG,8).
  10. Note: Clearing YTD is noted to involve saving the vendor file for 1099 processing, indicating a tax-related requirement.

  11. Job Queue Option:

  12. Users can choose to submit the update job to a queue (KYJOBQ = 'Y') or run it immediately (KYJOBQ = ' ' or N).
  13. Invalid job queue entries trigger error message MSG,6.

  14. Cancel Option:

  15. The program allows cancellation by setting KYCANC to CANCEL, which is checked in the OCL script to terminate processing.

  16. Data Validation:

  17. Only non-deleted records (ACDEL ≠ 'D') and company numbers not equal to 99 are considered valid for display in the CO array.
  18. Up to 10 companies are displayed on the screen for selection.

  19. Error Handling:

  20. The program uses indicators (50–55, 81, 90) to flag errors and display appropriate messages from the MSG array.
  21. Errors prevent further processing until corrected, ensuring data integrity.

Tables (Files) Used

The program uses the following files:

  1. SCREEN:
  2. Type: Workstation file (display file).
  3. Purpose: Displays the AP300PS1 screen format for user input and output, including company selection, YTD options, job queue choice, and error messages.
  4. Fields: KYALCO, KYCO1, KYCO2, KYCO3, CO (array), KYYTDY, KYCCYY, KYJOBQ, MSG40.

  5. APCONT:

  6. Type: Indexed disk file (256 bytes, 2 keys).
  7. Purpose: Vendor master file containing company data for validation and display.
  8. Fields:
    • ACDEL (1 byte): Deletion flag ('D' for deleted).
    • ACCO (2 bytes): Company number.
    • ACNAME (30 bytes): Company name.
  9. Operations: SETLL, READ, CHAIN for accessing records.

External Programs Called

The RPG program does not directly call external programs via RPG operations (e.g., CALL). However, it interacts with the OCL script (AP300P.ocl36.txt), which may call:

  1. AP300:
  2. Referenced in the OCL script as either a direct execution (AP300 ,,,,,,,,?9?) or job queue submission (JOBQ ?CLIB?,AP300).
  3. Likely the program that performs the actual MTD/YTD update using parameters set by AP300P.
  4. The RPG program sets up the Local Data Area (UDS) fields (KYALCO, KYCO1, etc.) that AP300 uses.

No other programs are explicitly called within the RPG code.


Summary

Process Overview: - AP300P is a prompting and validation program for the A/P monthly/yearly update process. - It displays a screen (AP300PS1) to collect user input for company selection (ALL or specific companies), YTD clearing (Y or blank), year (if YTD is cleared), and job queue option (Y, N, or blank). - It validates input against the APCONT file and business rules, displaying error messages if invalid. - The validated parameters are stored in the Local Data Area for use by the OCL script and subsequent programs (e.g., AP300). - The program ensures data integrity by enforcing strict validation and providing user feedback.

Business Rules: - Company selection must be ALL or valid company numbers (CO). - YTD clearing requires a valid 4-digit year if selected. - Job queue option must be Y, N, or blank. - Errors are flagged and displayed to prevent incorrect updates. - Cancellation is supported via the KYCANC field.

Tables Used: - SCREEN: Workstation file for user interaction. - APCONT: Vendor master file for company data.

External Programs: - AP300: Likely called by the OCL script to perform the update, using parameters set by AP300P.

This program acts as the user interface and validation layer, ensuring the A/P update process is configured correctly before execution. If you need further details (e.g., the AP300 program logic or screen format details), please provide additional context or files!