Skip to content

AP192 RPG

The provided document is an RPG (Report Program Generator) program named AP192 for the IBM System/36 or AS/400, called from the OCL program previously discussed. It is designed to populate an Accounts Payable (A/P) check reconciliation workfile (APCRTR) from data uploaded from PNC (APCHKUP). Below, I’ll explain the process steps, business rules, tables used, and any external programs called.

Process Steps of the RPG Program (AP192)

The RPG program reads records from the input file APCHKUP, processes them, and writes formatted records to the output file APCRTR. Here’s a step-by-step breakdown of the process:

  1. File Definitions:
  2. Input File (APCHKUP):
    • Defined as a primary input file (IP) with a record length of 25 bytes (FAPCHKUP IP F 25 25 DISK).
    • Fields are extracted from positions 1 to 25 of each record.
  3. Output File (APCRTR):

    • Defined as an output file (O) with a record length of 80 bytes (FAPCRTR O F 80 80 16AI 2 DISK).
    • Indexed file (AI) with a key length of 2 bytes starting at position 16.
    • The A indicator suggests append mode, allowing new records to be added.
  4. Input Record Mapping:

  5. The input file APCHKUP is read using a non-sequenced record (NS 01) and fields are mapped as follows:

    • CHECK# (positions 1–6): Check number (likely a numeric or alphanumeric identifier).
    • AMOUNT (positions 7–17): Check amount, including vendor number data (likely a packed or zoned decimal field).
    • YEAR (positions 18–21): Four-digit year of the check date.
    • YEAR2 (positions 20–21): Two-digit year (subset of YEAR, possibly for compatibility).
    • MONTH (positions 22–23): Month of the check date.
    • DAY (positions 24–25): Day of the check date.
    • Comments suggest additional fields like VENDOR NUMBER and VENDOR NAME, but these are not explicitly mapped in the provided code, possibly indicating a partial or simplified program listing.
  6. Processing Logic:

  7. Indicator N09 Check:
    • The program checks if indicator 09 is off (N09).
    • If 09 is off, it sets a field GLNUMB (80 bytes) to a constant value 11000001 using Z-ADD (zero and add operation).
    • It then sets indicator 09 on (SETON 09), ensuring this logic executes only once (likely for the first record or initialization).
  8. This suggests GLNUMB is a General Ledger number or a control field used in the output file, initialized to a default value.

  9. Output Record Writing:

  10. The program writes records to APCRTR using the DADD operation (add a new record) for output specification 01 (OAPCRTR DADD 01).
  11. The output record is formatted as follows:
    • Position 1: A single space (' ') for padding or alignment.
    • Positions 3–4: Hardcoded value '10' (possibly a transaction code or record type).
    • Positions 5–11: GLNUMB (General Ledger number, set to 11000001).
    • Positions 12–17: CHECK# (check number from input).
    • Positions 18–33: AMOUNT (check amount from input).
    • Positions 34–41: MONTH (month of check date).
    • Positions 42–43: DAY (day of check date).
    • Positions 44–45: YEAR2 (two-digit year).
    • Positions 46–49: YEAR (four-digit year).
    • Positions 50–51: MONTH (repeated, possibly for compatibility or formatting).
    • Positions 52–53: DAY (repeated, possibly for compatibility or formatting).
  12. The output record is 80 bytes long, with fields explicitly positioned to match the file’s structure.

  13. Program Flow:

  14. The RPG program operates in a cycle-driven manner (typical of RPG II/III on System/36).
  15. It reads each record from APCHKUP, processes it (assigning GLNUMB for the first record), and writes a formatted record to APCRTR.
  16. The cycle continues until all input records are processed or an end-of-file condition is reached.

Business Rules

The program enforces the following business rules: 1. Data Transformation: - Input data from APCHKUP (check number, amount, and date components) is reformatted into a structured output file (APCRTR) with additional fields like GLNUMB and a hardcoded transaction code ('10'). - This suggests the program prepares data for downstream A/P reconciliation processes, ensuring compatibility with the system’s database structure.

  1. Initialization of General Ledger Number:
  2. The GLNUMB field is initialized to 11000001 for the first record (or when indicator 09 is off), indicating a default or starting General Ledger account number.
  3. The use of indicator 09 ensures this initialization happens only once, preventing overwrites for subsequent records.

  4. Data Validation:

  5. The program assumes input data in APCHKUP is correctly formatted (e.g., check number in positions 1–6, amount in 7–17, etc.).
  6. No explicit validation logic is shown, but the field mappings suggest reliance on the input file’s structure being consistent.

  7. Output File Structure:

  8. The output file APCRTR is indexed with a key starting at position 16 (likely the check number or a related field), facilitating efficient retrieval in subsequent processes (e.g., by AP193).
  9. Repeated fields (MONTH and DAY) in the output suggest compatibility with legacy systems or specific formatting requirements for downstream processing.

Tables (Files) Used

The program interacts with the following files: 1. APCHKUP: - Input file (IP), 25 bytes per record. - Contains check reconciliation data uploaded from PNC, including check number, amount, and date components. 2. APCRTR: - Output file (O), 80 bytes per record, indexed with a 2-byte key starting at position 16. - Stores processed check reconciliation data for further processing by AP193.

External Programs Called

The provided RPG code does not explicitly call any external programs. It is a self-contained program that reads from APCHKUP, processes the data, and writes to APCRTR. However, it is called by the OCL program (as noted in the previous query) and works in conjunction with AP193, which processes the output file APCRTR.

Summary

The AP192 RPG program is responsible for populating the A/P check reconciliation workfile (APCRTR) from PNC upload data (APCHKUP). It: - Reads input records containing check number, amount, and date components. - Initializes a General Ledger number (GLNUMB) for the first record. - Formats and writes output records to APCRTR with additional fields like a transaction code ('10') and repeated date fields for compatibility. - Uses a cycle-driven approach to process all input records.

Business Rules: - Transform and reformat PNC upload data for A/P reconciliation. - Initialize GLNUMB once for the output file. - Ensure output records are structured for downstream processing.

Tables Used: APCHKUP (input), APCRTR (output).
External Programs Called: None directly in the RPG code, but AP192 is part of a workflow with AP193 via the OCL program.

If you need further details, such as field format specifics (e.g., numeric vs. alphanumeric) or clarification on the System/36 environment, let me know!