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:
- File and Data Structure Definitions:
- Files:
AP781
: Input file (320 bytes), containing vendor data.AP1099
: Output file (750 bytes), the final 1099 file for IRS submission.
- 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.
- 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 intoID1
,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.
-
Other Fields:
- Various zero-filled (
ZEROxx
) and blank-filled (BLNKxx
) fields for IRS record padding. RECSEQ
(8, zoned): Record sequence number.TOTGR1
toTOTGR7
(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).
- Various zero-filled (
-
Initialization (ONCE):
-
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.
- Initializes
-
Main Processing Loop (Level 1, L1):
-
For each
AP781
record:- Increments
TOTA
(count of Payer "A" records). - Resets
COUNT
,TOTGR1
,TOTGR2
,TOTGR3
,TOTGR6
,TOTGR7
to zeros. - Sets
TYPE
based onVN1099
: 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
).
- Increments
-
Payee Name and Address Handling:
- Initializes
NAM4
(name control) to blanks, then sets toVNNMCT
(IRS name control). - Clears
PYN1
andPYN2
to blanks, resets indicators 71 and 72. - If
VNPYN1
is blank:- If
NAM4
is blank, setsNAM4
toVNNAM4
. - Sets
PYN1
toVNNAME
. - If
VNNOVF = 'Y'
, setsPYN2
toVNADD1
, movesVNADD2
toVNADD1
, clearsVNADD2
, sets indicator 72.
- If
- If
VNPYN1
is not blank:- If
NAM4
is blank, setsNAM4
toVNNAM4
. - Sets
PYN1
toVNPYN1
, sets indicator 71. - If
VNPYN2
is not blank, setsPYN2
toVNPYN2
, sets indicator 72.
- If
-
This ensures payee names (
VNPYN1
,VNPYN2
) are used if provided; otherwise, vendor name (VNNAME
) is used, with address overflow handling. -
Payment Amount Processing:
- Resets indicators 41, 46, 47, 51, 56, 57.
- Increments
COUNT
(payee count). - Checks if
VNDASH = '-'
to determine EIN (20
) or SSN (N20
) for tax ID. - Accumulates totals based on form type:
- For 1099-DIV (indicator 31): Adds
VNAMT1
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), sets indicator 46, addsVNAMT1
toTOTGR6
. - If
BOX2 = 1
, sets indicator 51, addsVNAMT2
toTOTGR1
. - If
BOX2 = 3
, sets indicator 53, addsVNAMT2
toTOTGR3
. - If
BOX2 = 6
, sets indicator 56, addsVNAMT2
toTOTGR6
. - For 1099-NEC (indicator 34):
- If
BOX1 = 1
, sets indicator 47, addsVNAMT1
toTOTGR1
. - If
BOX2 = 1
, sets indicator 57, addsVNAMT2
toTOTGR1
.
- For 1099-DIV (indicator 31): Adds
- Moves
VNAMT1
toVXAMT1
andVNAMT2
toVXAMT2
for output. -
Increments
RECSEQ
and writes a Payee "B" record (EXCPT ADDB
). -
End of Payer Processing (L1 Indicator):
-
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
). -
End of Transmission (LR Indicator):
-
At last record, increments
RECSEQ
and writes an End of Transmission "F" record (EXCPT ADDLR
) with the count of Payer "A" records (TOTA
). -
Output Records:
- 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).
- Includes
- 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).
- Includes
- Payee "B" Record (
ADDB
):- Includes
YEAR
,NAM4
, tax ID (VNID11
,VNID12
,VNID13
orVNID21
,VNID22
),VNVEND
,PYN1
,PYN2
,VNADD1
,CITY
,STATE
,ZIP5
, payment amounts (VXAMT1
,VXAMT2
), andRECSEQ
.
- Includes
- End of Payer "C" Record (
ADDL1
):- Includes
COUNT
and control totals (TOTGR1
,TOTGR2
,TOTGR3
,TOTGR6
,TOTGR7
).
- Includes
- End of Transmission "F" Record (
ADDLR
):- Includes
TOTA
andRECSEQ
.
- Includes
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.