Skip to content

AP765 RPG36

The RPG36 program AP765 is designed to generate Vendor 1099 forms, likely for tax reporting purposes, printing two forms per page on laser paper. It processes vendor data from an input file, validates amounts, formats addresses, and prints the forms with specific fields like payee names, vendor IDs, and amounts. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.

Process Steps

  1. File and Data Structure Definitions:
  2. File Definitions (F-Spec):
    • AP766 (Line 0008): Input file (IP), disk-based, with a record length of 300 bytes, containing vendor data.
    • AP1099 (Line 0009): Output file (O), printer file with a record length of 80 bytes, used for printing the 1099 forms.
    • LAP1099 (Line 0011): Logical file for the printer, specifying 66 lines per page with overflow at line 66.
  3. Input Specifications (I-Spec):
    • AP766 Record Format (NS 01) (Lines 0012–0025):
    • Fields include VNDEL (delete code), VN1099 (1099 code), VNVEND (vendor number), VNNAME (vendor name), VNADD1–VNADD4 (address lines), L1AMT1 and L1AMT2 (amounts for two boxes), BOX1 and BOX2 (box numbers), VNID# (1099 ID), VNPYN1 and VNPYN2 (payee names 1 and 2, added in JB01), VNNOVF (name overflow flag, added in JB02), STATID, and STATED (state-related fields).
    • Data Structure (UDS) (Lines 0026–0032):
    • Fields include HEAD1, HEAD2, HEAD3 (headings), ID# (company ID), ENTAMT (entered amount), CURLST (current/last indicator), CNYEAR, and YEAR (year fields).
  4. Output Specifications (O-Spec) (Lines 0107–0141):

    • Defines output formats for printing two 1099 forms per page (controlled by indicators 31 and 32 for top and bottom forms, respectively).
    • Outputs fields like headings, amounts, vendor/payee names, addresses, and totals, with specific positioning on the form.
  5. Calculation Specifications (C-Spec):

  6. Initial Vendor Checks:
    • If VNVEND equals 9384, set YES to 'YES' (Line 0033).
    • If VN1099 is 'M' (Miscellaneous), set indicator 33; if 'N' (Nonemployee Compensation), set indicator 34 (Lines 0033).
  7. Amount Validation:
    • Line 0034: Add L1AMT1 and L1AMT2 to TOTAMT.
    • Line 0035: Compare TOTAMT with ENTAMT. If they don’t match, set indicator 30 and branch to END (Line 0036).
  8. Form Counter Logic:
    • Lines 0037–0037: COUNTP tracks whether to print the top (31) or bottom (32) form. If COUNTP is zero, set it to 1 and turn on indicator 31. Otherwise, increment COUNTP and toggle between indicators 31 and 32.
  9. Clear Work Fields:
    • Lines JB01: For each form (31 or 32), clear fields like PYN11, PYN12, PYN21, PYN22, VNID#1, VNID#2, STATE1, STATE2, STATI1, STATI2, VNVEN1, VNVEN2, and amount fields (AMT11, AMT31, AMT61, AMT71, etc.).
  10. Payee and Address Processing for Form 1 (Indicator 31):
    • Lines 0038–0069: If VNPYN1 is blank, use VNNAME for PYN11. If VNNOVF is 'Y', set indicators 35 and 71 for name overflow.
    • Address lines (VNADD1–VNADD4) are checked in descending order. The highest non-blank address line is moved to CTSTZ1, with lower lines shifted to VNAD11, VNAD21, or PYN21 as needed.
    • If VNPYN1 is not blank, use VNPYN1 and VNPYN2 for PYN11 and PYN21, respectively, and set indicator 71.
  11. Payee and Address Processing for Form 2 (Indicator 32):
    • Similar logic as above, but for fields like PYN12, PYN22, CTSTZ2, VNAD12, and VNAD22, with indicators 36 and 72.
  12. Additional Address Processing:
    • Lines 0045–0069 (for 31 and 32): Additional checks for non-overflow cases (N35 or N36) to format addresses correctly into CTSTZ1, VNAD11, VNAD21, etc.
  13. Amount Assignment:
    • Lines 0071–0094: Assign L1AMT1 and L1AMT2 to specific amount fields (AMT11, AMT31, AMT61, AMT71 for Form 1; AMT12, AMT32, AMT62, AMT72 for Form 2) based on BOX1 and BOX2 values (1, 3, 6, or 7).
  14. Accumulate Totals:
    • Lines 0095–0098: For each form, increment COUNT and add amounts to running totals (LRAMT1, LRAMT3, LRAMT6, LRAMT7).
  15. Print Logic:
    • Line 0100: If COUNTP equals 2, reset COUNTP, set indicator 31, and execute the EXCPT operation to print both forms.
  16. End-of-File Handling:
    • If the end of file is reached (LR on), check if indicator 31 is on (data for top form). If so, clear fields, accumulate final totals into LRAMT, and print the last form with indicator 30.
  17. Output Execution:

    • The EXCPT operation triggers printing of the forms based on indicators 31 and 32, outputting fields to the printer file.
  18. Output Processing:

  19. Form 1 (Indicator 31):
    • Outputs headings (HEAD1, HEAD2, HEAD3), year (CNYEAR), amounts (AMT11, AMT31, AMT61, AMT71), IDs (ID#, VNID#1), payee names (PYN11, PYN21), addresses (VNAD11, VNAD21, CTSTZ1), and vendor number (VNVEN1).
  20. Form 2 (Indicator 32):
    • Similar to Form 1 but uses fields like AMT12, AMT32, AMT62, AMT72, VNID#2, PYN12, PYN22, VNAD12, VNAD22, CTSTZ2, and VNVEN2.
  21. Totals (LR Indicator):
    • Prints totals (LRAMT1, LRAMT3, LRAMT6, LRAMT7, LRAMT, COUNT) and headings at the end of the job.

Business Rules

  1. Amount Validation:
  2. The sum of L1AMT1 and L1AMT2 must equal ENTAMT. If not, the program skips to the END tag, bypassing further processing for that record.
  3. Form Layout:
  4. Two forms are printed per page (top and bottom), controlled by indicators 31 and 32, respectively. COUNTP toggles between 1 (top) and 2 (bottom).
  5. If only one form remains at the end of the file, it is printed with indicator 30.
  6. Payee Name Handling (JB01, 2013):
  7. If VNPYN1 is blank, use VNNAME. If VNPYN1 and VNPYN2 are provided, use them for printing payee names.
  8. Name Overflow (JB02, 2014):
  9. If VNNOVF is 'Y', set indicators 35/71 (Form 1) or 36/72 (Form 2) to handle name continuation on the second line.
  10. Address Formatting:
  11. Address lines are processed from VNADD4 to VNADD1, using the highest non-blank line for CTSTZ1/CTSTZ2 and shifting lower lines to VNAD11/VNAD21 or VNAD12/VNAD22.
  12. Amount Mapping:
  13. Amounts (L1AMT1, L1AMT2) are assigned to specific boxes (1, 3, 6, or 7) based on BOX1 and BOX2 values, corresponding to IRS 1099 form fields.
  14. Vendor Number as Account (JB02, 2014):
  15. Vendor number (VNVEND) is printed as the account number (VNVEN1, VNVEN2).
  16. Laser Paper Printing (MG03, 2016):
  17. Designed to print on laser paper with two forms per page.
  18. Two Different Forms (MG04, 2021):
  19. Supports printing two distinct 1099 forms per page, with separate fields for each.
  20. 1099 Code Handling:
    • If VN1099 is 'M', set indicator 33 (Miscellaneous Income).
    • If VN1099 is 'N', set indicator 34 (Nonemployee Compensation).

Tables Used

  • AP766:
  • Input disk file containing vendor data: VNDEL, VN1099, VNVEND, VNNAME, VNADD1–VNADD4, L1AMT1, L1AMT2, BOX1, BOX2, VNID#, VNPYN1, VNPYN2, VNNOVF, STATID, STATED.
  • No explicit arrays are defined, but work fields like AMT11, AMT31, LRAMT1, etc., act as temporary storage for calculations and printing.

External Programs Called

  • None:
  • The program does not explicitly call any external programs (no CALL statements).
  • It is invoked from a main OCL script, but no details about the OCL or other programs are provided.

Summary

The AP765 program: - Reads vendor data from the AP766 file and prints 1099 forms to the AP1099 printer file, formatted for laser paper with two forms per page. - Validates that the sum of L1AMT1 and L1AMT2 matches ENTAMT. - Formats payee names, using VNPYN1 and VNPYN2 if provided, or VNNAME otherwise, with overflow handling. - Processes addresses by selecting the highest non-blank line and shifting others accordingly. - Maps amounts to specific 1099 form boxes (1, 3, 6, 7) based on BOX1 and BOX2. - Accumulates totals and prints a summary at the end. - Uses indicators to control printing of top (31) and bottom (32) forms, with special handling for the last form. - Does not call external programs but is part of a larger OCL-driven process.