Skip to content

AP780 RPG36

The AP780.rpg36.txt is an RPG/36 program called by the main OCL program (AP780.ocl36.txt) to create the final IRS 1099 file (AP1099) for Accounts Payable (A/P) processing. It processes vendor data from the AP781 file, generates structured IRS records (Transmitter "T", Payer "A", Payee "B", End of Payer "C", and End of Transmission "F"), and applies specific business rules for 1099-DIV, 1099-INT, 1099-MISC, and 1099-NEC forms. Below, I’ll detail the process steps, business rules, tables used, and external programs called.

Process Steps of the AP780 RPG/36 Program

The program processes the input file AP781, generates the output file AP1099, and creates a structured 1099 file with records formatted according to IRS specifications. Here are the detailed steps:

  1. File and Data Structure Definitions:
  2. Files:
    • AP781: Input file (320 bytes), containing vendor data.
    • AP1099: Output file (750 bytes), the final 1099 file for IRS submission.
  3. Input Record (AP781):
    • VNDEL (1): Delete code.
    • VN1099L1 (2): 1099 code (D for DIV, I for INT, M for MISC, N for NEC).
    • VNVEND (3–7): Vendor number.
    • VNNAME (8–37): Vendor name.
    • VNADD1 (38–67): Address line 1.
    • CITY (68–87): City.
    • STATE (88–89): State.
    • ZIP5 (90–94): 5-digit ZIP code.
    • VNAMT1 (95–103, zoned): First box amount.
    • VNAMT2 (104–112, zoned): Second box amount.
    • BOX1 (113–114, zoned): First box number.
    • BOX2 (115–116, zoned): Second box number.
    • VNID# (117–127): Tax ID number (broken into parts: VNID11, VNID12, VNID13, VNID21, VNID22).
    • VNNAM4 (128–131): Name control (4 characters).
    • VNPYN1 (132–171): Payee name 1.
    • VNPYN2 (172–211): Payee name 2.
    • VNADD2 (212–241): Address line 2.
    • VNNOVF (242): Name overflow indicator (Y if address line 1 continues as name part 2).
    • VNNMCT (243–246): IRS name control (added in revision JK01).
    • VNFNAM, VNMNAM, VNLNAM, VNSUFF (247–320): First, middle, last names, and suffix.
  4. User Data Structure (UDS):
    • HEAD1 (1–30): Transmitter name.
    • HEAD2 (31–60): Transmitter address.
    • HDCITY (61–89): Transmitter city.
    • HDSTAT (90–91): Transmitter state.
    • HDZIP (92–100): Transmitter ZIP.
    • ID# (101–110): Transmitter tax ID (split into ID1, ID2).
    • ENTAMT (111–118, zoned): Entered amount.
    • YEAR (119–122, zoned): 1099 year.
    • CNTACT (124–143): Contact name.
    • CNTPH# (144–153): Contact phone number.
    • FORM (160): Form type.
    • TOTB (201–208, zoned): Total amount for transmitter record.
  5. Other Fields:

    • Various zero-filled (ZEROxx) and blank-filled (BLNKxx) fields for IRS record padding.
    • RECSEQ (8, zoned): Record sequence number.
    • TOTGR1 to TOTGR7 (15, zoned): Control totals for payment amounts.
    • COUNT (8, zoned): Payee count.
    • TOTA (8, zoned): Payer record count.
    • TYPE (2): 1099 form type (1 for DIV, 6 for INT, A for MISC, NE for NEC).
  6. Initialization (ONCE):

  7. If ONCE is zero (first iteration):

    • Initializes RECSEQ, ZERO03, Z1, ZERO04, ZERO06, ZERO12, ZERO15 to zeros.
    • Initializes BLNKxx fields to blanks.
    • Increments RECSEQ and writes the Transmitter "T" record (EXCPT ADDT).
    • Sets ONCE to 1 to prevent re-execution.
  8. Main Processing Loop (Level 1, L1):

  9. For each AP781 record:

    • Increments TOTA (count of Payer "A" records).
    • Resets COUNT, TOTGR1, TOTGR2, TOTGR3, TOTGR6, TOTGR7 to zeros.
    • Sets TYPE based on VN1099:
    • D (Dividend) → TYPE = '1 ', indicator 31.
    • I (Interest) → TYPE = '6 ', indicator 32.
    • M (Miscellaneous) → TYPE = 'A ', indicator 33.
    • N (Non-employee Compensation) → TYPE = 'NE', indicator 34.
    • Increments RECSEQ and writes a Payer "A" record (EXCPT ADDA).
  10. Payee Name and Address Handling:

  11. Initializes NAM4 (name control) to blanks, then sets to VNNMCT (IRS name control).
  12. Clears PYN1 and PYN2 to blanks, resets indicators 71 and 72.
  13. If VNPYN1 is blank:
    • If NAM4 is blank, sets NAM4 to VNNAM4.
    • Sets PYN1 to VNNAME.
    • If VNNOVF = 'Y', sets PYN2 to VNADD1, moves VNADD2 to VNADD1, clears VNADD2, sets indicator 72.
  14. If VNPYN1 is not blank:
    • If NAM4 is blank, sets NAM4 to VNNAM4.
    • Sets PYN1 to VNPYN1, sets indicator 71.
    • If VNPYN2 is not blank, sets PYN2 to VNPYN2, sets indicator 72.
  15. This ensures payee names (VNPYN1, VNPYN2) are used if provided; otherwise, vendor name (VNNAME) is used, with address overflow handling.

  16. Payment Amount Processing:

  17. Resets indicators 41, 46, 47, 51, 56, 57.
  18. Increments COUNT (payee count).
  19. Checks if VNDASH = '-' to determine EIN (20) or SSN (N20) for tax ID.
  20. Accumulates totals based on form type:
    • For 1099-DIV (indicator 31): Adds VNAMT1 to TOTGR1 and TOTGR2.
    • For 1099-INT (indicator 32): Adds VNAMT1 to TOTGR1.
    • For 1099-MISC (indicator 33):
    • If BOX1 = 1 (Rents), sets indicator 41, adds VNAMT1 to TOTGR1.
    • If BOX1 = 3 (Other Income), sets indicator 43, adds VNAMT1 to TOTGR3.
    • If BOX1 = 6 (Medical), sets indicator 46, adds VNAMT1 to TOTGR6.
    • If BOX2 = 1, sets indicator 51, adds VNAMT2 to TOTGR1.
    • If BOX2 = 3, sets indicator 53, adds VNAMT2 to TOTGR3.
    • If BOX2 = 6, sets indicator 56, adds VNAMT2 to TOTGR6.
    • For 1099-NEC (indicator 34):
    • If BOX1 = 1, sets indicator 47, adds VNAMT1 to TOTGR1.
    • If BOX2 = 1, sets indicator 57, adds VNAMT2 to TOTGR1.
  21. Moves VNAMT1 to VXAMT1 and VNAMT2 to VXAMT2 for output.
  22. Increments RECSEQ and writes a Payee "B" record (EXCPT ADDB).

  23. End of Payer Processing (L1 Indicator):

  24. At level 1 break, increments RECSEQ and writes an End of Payer "C" record (EXCPT ADDL1) with payee count (COUNT) and control totals (TOTGR1, TOTGR2, TOTGR3, TOTGR6, TOTGR7).

  25. End of Transmission (LR Indicator):

  26. At last record, increments RECSEQ and writes an End of Transmission "F" record (EXCPT ADDLR) with the count of Payer "A" records (TOTA).

  27. Output Records:

  28. Transmitter "T" Record (ADDT):
    • Includes YEAR, ID1, ID2, HEAD1, HEAD2, HDCITY, HDSTAT, HDZIP, CNTACT, CNTPH#, TOTB, RECSEQ, and fixed codes (e.g., 28Q01, I for in-house software).
  29. Payer "A" Record (ADDA):
    • Includes YEAR, ID1, ID2, TYPE, HEAD1, HEAD2, HDCITY, HDSTAT, HDZIP, CNTPH#, RECSEQ, and form-specific codes (e.g., 12 for DIV, 1 for INT, 13 for MISC, 1 for NEC).
  30. Payee "B" Record (ADDB):
    • Includes YEAR, NAM4, tax ID (VNID11, VNID12, VNID13 or VNID21, VNID22), VNVEND, PYN1, PYN2, VNADD1, CITY, STATE, ZIP5, payment amounts (VXAMT1, VXAMT2), and RECSEQ.
  31. End of Payer "C" Record (ADDL1):
    • Includes COUNT and control totals (TOTGR1, TOTGR2, TOTGR3, TOTGR6, TOTGR7).
  32. End of Transmission "F" Record (ADDLR):
    • Includes TOTA and RECSEQ.

Business Rules

The program enforces the following business rules for IRS 1099 file creation: 1. Form Type Mapping: - VN1099 = 'D' → 1099-DIV (TYPE = '1 '), amounts in TOTGR1 (Ordinary Dividends) and TOTGR2 (Capital Gains). - VN1099 = 'I' → 1099-INT (TYPE = '6 '), amounts in TOTGR1 (Interest Income). - VN1099 = 'M' → 1099-MISC (TYPE = 'A '), amounts in: - TOTGR1 for BOX1 = 1 (Rents) or BOX2 = 1. - TOTGR3 for BOX1 = 3 (Other Income) or BOX2 = 3. - TOTGR6 for BOX1 = 6 (Medical) or BOX2 = 6. - VN1099 = 'N' → 1099-NEC (TYPE = 'NE'), amounts in TOTGR1 for BOX1 = 1 or BOX2 = 1. 2. Name Handling: - Uses VNPYN1 and VNPYN2 if provided; otherwise, uses VNNAME. - If VNNOVF = 'Y', VNADD1 becomes PYN2, and VNADD2 shifts to VNADD1. - NAM4 (name control) uses VNNMCT if available, else VNNAM4, or blanks if payee names are used. 3. Tax ID Handling: - If VNDASH = '-', uses EIN (VNID21, VNID22); otherwise, uses SSN (VNID11, VNID12, VNID13). - VNVEND is used as the account number (revision JB03). 4. Amount Splitting: - VNAMT1 is assigned to the primary box (BOX1) on the 1099 form. - If VNAMT2 exists, it’s assigned to the secondary box (BOX2) for 1099-MISC or 1099-NEC. - Example: If a vendor has $15,000 total, with $10,000 for MISC (BOX1 = 7) and $5,000 for Rents (BOX2 = 1), VNAMT1 = 15,000, VNAMT2 = 5,000, and the program calculates $10,000 for MISC. 5. Record Sequencing: - Each record (T, A, B, C, F) includes a unique RECSEQ incremented for IRS tracking. 6. IRS Format Compliance: - Records are padded with zeros or blanks as per IRS specifications (e.g., positions 376–748 for T and A, 663–750 for B). - Fixed codes (e.g., 28Q01 for T, AMER for A) ensure IRS compatibility. 7. Zero-Filled Fields: - Numeric fields (e.g., payment amounts, control totals) are zero-filled if unused (revision JB02). 8. Form Support: - Supports 1099-DIV, 1099-INT, 1099-MISC, and 1099-NEC (added in revision MG04).

Tables Used

The program uses the following files/tables: 1. AP781: - Input file (320 bytes). - Contains vendor data including 1099 code, vendor number, name, address, tax ID, and payment amounts. 2. AP1099: - Output file (750 bytes). - Stores the IRS 1099 file with T, A, B, C, and F records.

External Programs Called

The AP780 program does not explicitly call any external programs. It is invoked by the main OCL program (AP780.ocl36.txt) and processes data from AP781 to produce AP1099.

Summary

The AP780 RPG/36 program generates an IRS-compliant 1099 file by: - Creating a Transmitter "T" record with company and contact details. - Processing vendor records from AP781 to create Payer "A" and Payee "B" records, handling form types (DIV, INT, MISC, NEC) and payment amounts. - Managing payee names, address overflow, and tax IDs (EIN/SSN). - Accumulating control totals and writing End of Payer "C" and End of Transmission "F" records. - Ensuring IRS format compliance with zero-filled and blank-filled fields, record sequencing, and specific codes.

The program uses AP781 as input and AP1099 as output, with no external program calls, and enforces strict business rules for IRS 1099 compliance.