Skip to content

AP780 RPG36

The provided document, AP780.rpg36.txt, is an RPG (Report Program Generator) program for an IBM System/3x or AS/400 system, called by the main OCL program (AP780.ocl36.txt) to finalize the creation of an IRS 1099 file (AP1099) for electronic submission. This program processes the preprocessed vendor data from the AP781 file to generate IRS-compliant records, including Transmitter ("T"), Payer ("A"), Payee ("B"), End of Payer ("C"), and End of Transmission ("F") records. Below is a detailed explanation of the process steps, business rules, tables used, external programs called, and outputs of the AP780 RPG program.

Process Steps of the AP780 RPG Program

The AP780 program reads the AP781 file, which contains consolidated vendor records, and generates a formatted AP1099 file with IRS-specified record types. Here’s a step-by-step breakdown of the process:

  1. Program Initialization (ONCE Block):
  2. The program checks if the ONCE variable is zero (first execution):
    • Initializes counters and fields:
    • RECSEQ (record sequence number, 8 digits): Set to zero (JB02 revision).
    • ZERO03, ZERO04, ZERO06, ZERO12, ZERO15 (zero-filled fields of various lengths): Set to zero.
    • Z1 (1-digit zero): Set to zero.
    • BLNK04, BLNK05, BLNK06, BLNK07, BLNK08, BLNK10, BLNK11, BLNK15, BLNK20, BLNK40, BLNK45, BLNK48, BLNK60, BLNK76, BLN115 (blank fields of various lengths): Set to blanks.
    • Increments RECSEQ by 1 for the first record.
    • Writes the Transmitter "T" Record to AP1099 using the ADDT exception output (see Outputs section for details).
    • Sets ONCE to 1 to prevent re-execution.
  3. The "T" record contains transmitter information (e.g., company name, tax ID, contact details) and is written once at the start of the file.

  4. Process Vendor Records (L1 Level Loop):

  5. For each vendor record in AP781 (grouped by vendor using level-break L1):

    • Initializes variables:
    • Increments TOTA (count of Payer "A" records, 8 digits) by 1.
    • Resets COUNT (count of Payee "B" records for the current payer, 8 digits) to zero.
    • Resets control totals (TOTGR1, TOTGR2, TOTGR3, TOTGR6, TOTGR7, 15 digits, 2 decimals) to zero.
    • Clears TYPE (2 characters, form type) to blanks (FL01 revision).
    • Turns off indicators 31, 32, 33, 34 (form type indicators), and 41, 46, 47, 51, 56, 57 (box-specific indicators).
    • Determines the 1099 form type based on VN1099 (A/P 1099 code, position 2):
    • If VN1099 = 'D' (Dividend):
      • Sets TYPE = '1 ' (1099-DIV, FL01).
      • Sets indicator 31 on.
    • If VN1099 = 'I' (Interest):
      • Sets TYPE = '6 ' (1099-INT, FL01).
      • Sets indicator 32 on.
    • If VN1099 = 'M' (Miscellaneous):
      • Sets TYPE = 'A ' (1099-MISC, FL01).
      • Sets indicator 33 on.
    • If VN1099 = 'N' (Non-Employee Compensation):
      • Sets TYPE = 'NE' (1099-NEC, FL01, added by MG04).
      • Sets indicator 34 on.
    • Increments RECSEQ by 1 (JB02).
    • Writes the Payer "A" Record to AP1099 using the ADDA exception output, containing payer information (e.g., company name, tax ID, form type).
    • Processes payee data:
    • Handles name and payee logic (JB02, JB03, JK01 revisions):
      • Clears NAM4 (name control, 4 characters) and PYN1, PYN2 (payee names, 40 characters each).
      • Sets NAM4 to VNNMCT (IRS name control, JK01).
      • If VNPYN1 (payee name 1) is blank:
      • If NAM4 is blank, sets NAM4 to VNNAM4 (sort abbreviation).
      • Sets PYN1 to VNNAME (vendor name).
      • If VNNOVF = 'Y' (name overflow, JB03):
        • Sets PYN2 to VNADD1 (address line 1 as name continuation).
        • Moves VNADD2 to VNADD1, clears VNADD2.
        • Sets indicator 72 on.
      • If VNPYN1 is not blank:
      • If NAM4 is blank, sets NAM4 to VNNAM4.
      • Sets PYN1 to VNPYN1, sets indicator 71 on.
      • If VNPYN2 is not blank, sets PYN2 to VNPYN2, sets indicator 72 on.
    • Checks tax ID type (VNDASH, position 119):
      • If VNDASH = '-' (indicator 20 on), indicates a business EIN; otherwise, assumes an individual SSN.
    • Accumulates control totals based on form type and box numbers:
      • For 1099-DIV (indicator 31):
      • Adds VNAMT1 (first box amount) 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 Payments), sets indicator 46, adds VNAMT1 to TOTGR6.
      • If BOX2 = 1 (Rents), sets indicator 51, adds VNAMT2 to TOTGR1.
      • If BOX2 = 3 (Other Income), sets indicator 53, adds VNAMT2 to TOTGR3.
      • If BOX2 = 6 (Medical Payments), sets indicator 56, adds VNAMT2 to TOTGR6.
      • For 1099-NEC (indicator 34):
      • If BOX1 = 1 (Nonemployee Compensation), sets indicator 47, adds VNAMT1 to TOTGR1.
      • If BOX2 = 1, sets indicator 57, adds VNAMT2 to TOTGR1.
    • Copies VNAMT1 and VNAMT2 to VXAMT1 and VXAMT2 (12 digits, 2 decimals) for output.
    • Increments RECSEQ by 1 (JB02).
    • Writes the Payee "B" Record to AP1099 using the ADDB exception output, containing vendor details (e.g., tax ID, name, address, payment amounts).
    • Increments RECSEQ by 1 (JB02).
    • Writes the End of Payer "C" Record to AP1099 using the ADDL1 exception output, summarizing the number of payees (COUNT) and control totals (TOTGR1, TOTGR3, TOTGR6, TOTGR7).
  6. End of Transmission (LR Indicator):

  7. When the last record is processed (LR indicator on):
    • Increments RECSEQ by 1 (JB02).
    • Writes the End of Transmission "F" Record to AP1099 using the ADDLR exception output, indicating the total number of Payer "A" records (TOTA) and closing the file.

Business Rules

The AP780 program enforces the following business rules for IRS 1099 file creation: 1. IRS Record Structure: - Generates a file with five record types per IRS specifications: - T Record: One per file, containing transmitter information (company name, tax ID, contact, etc.). - A Record: One per 1099 form type (DIV, INT, MISC, NEC), containing payer information. - B Record: One per vendor, containing payee details (tax ID, name, address, payment amounts). - C Record: One per Payer "A" record, summarizing payee count and control totals. - F Record: One per file, marking the end of transmission. - Each record is 750 bytes, padded with blanks or zeros as required.

  1. Form Type Mapping:
  2. Maps VN1099 codes to IRS form types:
    • 'D' → 1099-DIV (TYPE = '1 ', indicator 31).
    • 'I' → 1099-INT (TYPE = '6 ', indicator 32).
    • 'M' → 1099-MISC (TYPE = 'A ', indicator 33).
    • 'N' → 1099-NEC (TYPE = 'NE', indicator 34, added by MG04).
  3. Supports multiple form types in a single file, with separate "A" and "C" records for each.

  4. Payment Amount Allocation:

  5. Allocates payment amounts (VNAMT1, VNAMT2) to IRS-specified boxes based on BOX1 and BOX2:
    • 1099-MISC: Box 1 (Rents), Box 3 (Other Income), Box 6 (Medical Payments), Box 7 (Nonemployee Compensation).
    • 1099-NEC: Box 1 (Nonemployee Compensation).
    • 1099-DIV: Box 1 (Ordinary Dividends), Box 2 (Capital Gains).
    • 1099-INT: Box 1 (Interest Income).
  6. Accumulates control totals (TOTGR1, TOTGR3, TOTGR6) for specific boxes in the "C" record.

  7. Tax ID Handling:

  8. Identifies tax ID type based on VNDASH ('-' for EIN, otherwise SSN).
  9. Formats tax ID (VNID11, VNID12, VNID13 for SSN; VNID21, VNID22 for EIN) in the "B" record.
  10. Uses transmitter and payer tax IDs (ID1, ID2) from UDS for "T" and "A" records.

  11. Name and Payee Logic:

  12. Prefers payee names (VNPYN1, VNPYN2) over vendor name (VNNAME) if provided (JB02).
  13. Uses name overflow (VNNOVF = 'Y') to continue vendor name with address line 1 (VNADD1) in PYN2, shifting VNADD2 to VNADD1 (JB03).
  14. Uses IRS name control (VNNMCT, JK01) or sort abbreviation (VNNAM4) in NAM4 for "B" records, ensuring IRS compliance.

  15. Sequence Numbering:

  16. Assigns a unique sequence number (RECSEQ) to each record ("T", "A", "B", "C", "F"), incremented sequentially (JB02).

  17. Zero and Blank Padding:

  18. Fills unused numeric fields with zeros (e.g., ZERO12 for payment amounts) and unused character fields with blanks (e.g., BLNK40) per IRS requirements (JB02).
  19. Ensures fixed-length records (750 bytes) with proper padding.

  20. IRS Compliance:

  21. Includes fields like name control, foreign entity indicators, and contact information to meet IRS electronic filing standards.
  22. Supports 1099-NEC (added by MG04 in 2021) alongside 1099-MISC, 1099-DIV, and 1099-INT.

Tables Used

  • None: The AP780 program does not use any table files (e.g., GSTABL as used in AP780P). It relies entirely on the input file AP781 and user data structure (UDS) for processing.

External Programs Called

  • None: The AP780 program does not call any external RPG or OCL programs. It is invoked by the main OCL program (AP780.ocl36.txt) and performs its tasks independently, reading from AP781 and writing to AP1099.

Outputs

  1. AP1099 File:
  2. Purpose: The final IRS 1099 file for electronic submission, containing formatted records per IRS specifications.
  3. Record Length: 750 bytes per record, padded with blanks or zeros.
  4. Record Types:

    • Transmitter "T" Record (ADDT, written once):
    • Position 1: 'T'.
    • Positions 2-5: YEAR (four-digit year, e.g., 2025).
    • Position 6: Blank (no prior year indicator).
    • Positions 7-8: ID1 (transmitter tax ID part 1).
    • Positions 9-15: ID2 (transmitter tax ID part 2).
    • Positions 16-20: '28Q01' (transmitter code).
    • Positions 21-27: Blanks (replacement file code, test file indicator).
    • Position 28: Blank (foreign entity indicator).
    • Positions 29-58: HEAD1 (transmitter name).
    • Positions 59-258: Blanks, HEAD1, HEAD2, HDCITY, HDSTAT, HDZIP (address fields).
    • Positions 259-303: TOTB (total payees, from UDS).
    • Positions 304-323: CNTACT (contact name).
    • Positions 324-353: CNTPH# (contact phone).
    • Positions 354-507: Blanks, RECSEQ (sequence number, JB02).
    • Position 518: 'I' (inhouse software indicator, JB02).
    • Positions 519-750: Blanks.
    • Payer "A" Record (ADDA, one per form type):
    • Position 1: 'A'.
    • Positions 2-5: YEAR.
    • Position 6: Blank (combined federal/state indicator, FL01).
    • Positions 7-11: Blanks.
    • Positions 12-13: ID1 (payer tax ID part 1).
    • Positions 14-20: ID2 (payer tax ID part 2).
    • Positions 21-24: 'AMER' (payer name control).
    • Position 25: Blank (last filing indicator).
    • Positions 26-27: TYPE (form type: '1 ', '6 ', 'A ', 'NE').
    • Positions 28-43: Form-specific code (e.g., '12 ' for 1099-DIV, '13 ' for 1099-MISC, '1 ' for 1099-NEC).
    • Positions 44-51: Blanks, foreign entity indicator.
    • Positions 52-224: HEAD1, HEAD2, HDCITY, HDSTAT, HDZIP, CNTPH# (payer details).
    • Positions 225-507: Blanks, RECSEQ.
    • Positions 508-750: Blanks.
    • Payee "B" Record (ADDB, one per vendor):
    • Position 1: 'B'.
    • Positions 2-5: YEAR.
    • Position 6: Blank (no corrections).
    • Positions 7-10: NAM4 (name control, VNNMCT or VNNAM4).
    • Position 11: '1' (EIN) or '2' (SSN) based on VNDASH.
    • Positions 12-20: VNID11, VNID12, VNID13 (SSN) or VNID21, VNID22 (EIN).
    • Positions 21-25: VNVEND (vendor number, JB03).
    • Positions 26-54: Blanks.
    • Positions 55-66: VXAMT1 (payment amount 1, based on form/box).
    • Positions 67-78: VXAMT1 or VXAMT2 (payment amount 2, if applicable).
    • Positions 79-258: Zero-filled payment amounts (3 to J), populated based on BOX1, BOX2.
    • Position 287: Blank (foreign entity indicator).
    • Positions 288-327: PYN1 (payee name 1 or vendor name).
    • Positions 328-367: PYN2 (payee name 2 or name continuation).
    • Positions 368-494: VNADD1, CITY, STATE, ZIP5 (payee address).
    • Positions 495-507: Blanks, RECSEQ.
    • Positions 508-750: Form-specific fields (e.g., direct sales indicator for 1099-MISC/NEC), blanks.
    • End of Payer "C" Record (ADDL1, one per "A" record):
    • Position 1: 'C'.
    • Positions 2-9: COUNT (number of "B" records for this payer).
    • Positions 10-15: Blanks.
    • Positions 16-33: TOTGR1 (control total 1, e.g., Rents, Nonemployee Compensation).
    • Positions 34-51: TOTGR2 (control total 2, e.g., Dividends).
    • Positions 52-69: TOTGR3 (control total 3, e.g., Other Income).
    • Positions 70-123: Zeroes, TOTGR6 (control total 6, e.g., Medical Payments).
    • Positions 124-339: Zeroes, TOTGR7 (control total 7, if applicable).
    • Positions 340-507: Blanks, RECSEQ.
    • Positions 508-750: Blanks.
    • End of Transmission "F" Record (ADDLR, written once):
    • Position 1: 'F'.
    • Positions 2-9: TOTA (number of "A" records).
    • Positions 10-30: Zeroes.
    • Positions 31-507: Blanks, RECSEQ.
    • Positions 508-750: Blanks.
  5. TOTB Field (in UDS):

  6. Purpose: Tracks the total number of payees, used in the "T" record.
  7. Location: Positions 201-208 in the user data structure (UDS), 8 digits, no decimals.
  8. Source: Set by AP781 and passed through UDS.