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:
- Program Initialization (ONCE Block):
- 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 theADDT
exception output (see Outputs section for details). - Sets
ONCE
to 1 to prevent re-execution.
-
The "T" record contains transmitter information (e.g., company name, tax ID, contact details) and is written once at the start of the file.
-
Process Vendor Records (L1 Level Loop):
-
For each vendor record in
AP781
(grouped by vendor using level-breakL1
):- 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.
- Sets
- If
VN1099 = 'I'
(Interest):- Sets
TYPE = '6 '
(1099-INT, FL01). - Sets indicator 32 on.
- Sets
- If
VN1099 = 'M'
(Miscellaneous):- Sets
TYPE = 'A '
(1099-MISC, FL01). - Sets indicator 33 on.
- Sets
- If
VN1099 = 'N'
(Non-Employee Compensation):- Sets
TYPE = 'NE'
(1099-NEC, FL01, added by MG04). - Sets indicator 34 on.
- Sets
- Increments
RECSEQ
by 1 (JB02). - Writes the Payer "A" Record to
AP1099
using theADDA
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) andPYN1
,PYN2
(payee names, 40 characters each). - Sets
NAM4
toVNNMCT
(IRS name control, JK01). - If
VNPYN1
(payee name 1) is blank: - If
NAM4
is blank, setsNAM4
toVNNAM4
(sort abbreviation). - Sets
PYN1
toVNNAME
(vendor name). - If
VNNOVF = 'Y'
(name overflow, JB03):- Sets
PYN2
toVNADD1
(address line 1 as name continuation). - Moves
VNADD2
toVNADD1
, clearsVNADD2
. - Sets indicator 72 on.
- Sets
- If
VNPYN1
is not blank: - If
NAM4
is blank, setsNAM4
toVNNAM4
. - Sets
PYN1
toVNPYN1
, sets indicator 71 on. - If
VNPYN2
is not blank, setsPYN2
toVNPYN2
, sets indicator 72 on.
- Clears
- Checks tax ID type (
VNDASH
, position 119):- If
VNDASH = '-'
(indicator 20 on), indicates a business EIN; otherwise, assumes an individual SSN.
- If
- Accumulates control totals based on form type and box numbers:
- For 1099-DIV (indicator 31):
- Adds
VNAMT1
(first box amount) toTOTGR1
andTOTGR2
. - For 1099-INT (indicator 32):
- Adds
VNAMT1
toTOTGR1
. - For 1099-MISC (indicator 33):
- If
BOX1 = 1
(Rents), sets indicator 41, addsVNAMT1
toTOTGR1
. - If
BOX1 = 3
(Other Income), sets indicator 43, addsVNAMT1
toTOTGR3
. - If
BOX1 = 6
(Medical Payments), sets indicator 46, addsVNAMT1
toTOTGR6
. - If
BOX2 = 1
(Rents), sets indicator 51, addsVNAMT2
toTOTGR1
. - If
BOX2 = 3
(Other Income), sets indicator 53, addsVNAMT2
toTOTGR3
. - If
BOX2 = 6
(Medical Payments), sets indicator 56, addsVNAMT2
toTOTGR6
. - For 1099-NEC (indicator 34):
- If
BOX1 = 1
(Nonemployee Compensation), sets indicator 47, addsVNAMT1
toTOTGR1
. - If
BOX2 = 1
, sets indicator 57, addsVNAMT2
toTOTGR1
.
- Copies
VNAMT1
andVNAMT2
toVXAMT1
andVXAMT2
(12 digits, 2 decimals) for output. - Increments
RECSEQ
by 1 (JB02). - Writes the Payee "B" Record to
AP1099
using theADDB
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 theADDL1
exception output, summarizing the number of payees (COUNT
) and control totals (TOTGR1
,TOTGR3
,TOTGR6
,TOTGR7
).
-
End of Transmission (LR Indicator):
- When the last record is processed (
LR
indicator on):- Increments
RECSEQ
by 1 (JB02). - Writes the End of Transmission "F" Record to
AP1099
using theADDLR
exception output, indicating the total number of Payer "A" records (TOTA
) and closing the file.
- Increments
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.
- Form Type Mapping:
- 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).
-
Supports multiple form types in a single file, with separate "A" and "C" records for each.
-
Payment Amount Allocation:
- Allocates payment amounts (
VNAMT1
,VNAMT2
) to IRS-specified boxes based onBOX1
andBOX2
:- 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).
-
Accumulates control totals (
TOTGR1
,TOTGR3
,TOTGR6
) for specific boxes in the "C" record. -
Tax ID Handling:
- Identifies tax ID type based on
VNDASH
('-'
for EIN, otherwise SSN). - Formats tax ID (
VNID11
,VNID12
,VNID13
for SSN;VNID21
,VNID22
for EIN) in the "B" record. -
Uses transmitter and payer tax IDs (
ID1
,ID2
) fromUDS
for "T" and "A" records. -
Name and Payee Logic:
- Prefers payee names (
VNPYN1
,VNPYN2
) over vendor name (VNNAME
) if provided (JB02). - Uses name overflow (
VNNOVF = 'Y'
) to continue vendor name with address line 1 (VNADD1
) inPYN2
, shiftingVNADD2
toVNADD1
(JB03). -
Uses IRS name control (
VNNMCT
, JK01) or sort abbreviation (VNNAM4
) inNAM4
for "B" records, ensuring IRS compliance. -
Sequence Numbering:
-
Assigns a unique sequence number (
RECSEQ
) to each record ("T", "A", "B", "C", "F"), incremented sequentially (JB02). -
Zero and Blank Padding:
- 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). -
Ensures fixed-length records (750 bytes) with proper padding.
-
IRS Compliance:
- Includes fields like name control, foreign entity indicators, and contact information to meet IRS electronic filing standards.
- 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 inAP780P
). It relies entirely on the input fileAP781
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 fromAP781
and writing toAP1099
.
Outputs¶
- AP1099 File:
- Purpose: The final IRS 1099 file for electronic submission, containing formatted records per IRS specifications.
- Record Length: 750 bytes per record, padded with blanks or zeros.
-
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, fromUDS
). - 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
orVNNAM4
). - Position 11:
'1'
(EIN) or'2'
(SSN) based onVNDASH
. - Positions 12-20:
VNID11
,VNID12
,VNID13
(SSN) orVNID21
,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
orVXAMT2
(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.
- Transmitter "T" Record (
-
TOTB Field (in UDS):
- Purpose: Tracks the total number of payees, used in the "T" record.
- Location: Positions 201-208 in the user data structure (
UDS
), 8 digits, no decimals. - Source: Set by
AP781
and passed throughUDS
.