AP765N RPG36
Explanation of the Process Steps and Business Rules in the RPG Program (AP765N.rpg36.txt)¶
The RPG III program AP765N.rpg36.txt
is designed to print vendor 1099-NEC (Non-Employee Compensation) forms on an IBM System/36 or AS/400 system. It is called by the OCL program AP765N.ocl36.txt
when ?L'110,1'?
is set to N
in the main OCL (AP765P.ocl36.txt
), indicating a focus on 1099-NEC forms. This program is similar to AP765.rpg36.txt
(used for 1099-MISC forms) but has modifications to handle three forms per page instead of two, reflecting differences in form layout or printing requirements for 1099-NEC. Below is a detailed explanation of the process steps, business rules, tables/files used, and external programs called.
Process Steps¶
- Program Setup and File Definitions:
- Header Specification (H):
- Line
0002
: Defines the program name (AP765N
) and parameterP016
, likely a control parameter passed from the OCL.
- Line
- File Specifications (F):
- Line
0008
:AP766
(Input, Primary, 300 bytes): The preprocessed work file (e.g.,?9?AP766
from the OCL), containing consolidated vendor data fromAP766.rpg36.txt
. - Line
0009
:AP1099
(Output, 80 bytes, Printer): The printer file used to output 1099-NEC forms, configured in the OCL with form type1099
, 10 CPI, and 6 LPI.
- Line
- Line Counter Specification (L):
- Line
0011
: Defines line counter settings forAP1099
with 66 lines per form (FL 66
) and 66 lines of overflow (OL 66
), ensuring proper pagination.
- Line
-
Input Specifications (I):
- Lines
0012-0025
: Define fields in theAP766
file (formatNS 01
): VNDEL
(1 char, position 1): Delete code.VN1099
(1 char, position 2): A/P 1099 code (e.g.,N
for Non-Employee Compensation).VNVEND
(5 chars, positions 3-7): Vendor number.VNNAME
(30 chars, positions 8-37): Vendor name.VNADD1-4
(30 chars each, positions 38-157): Address lines 1-4.L1AMT1
(9,2 numeric, positions 158-166): First box amount.L1AMT2
(9,2 numeric, positions 167-175): Second box amount.BOX1
(2 numeric, positions 176-177): First box number.BOX2
(2 numeric, positions 178-179): Second box number.VNID#
(11 chars, positions 180-190): 1099 ID number (e.g., Tax ID).VNPYN1
(40 chars, positions 191-230, added byJB01
): Payee name 1.VNPYN2
(40 chars, positions 231-270, added byJB01
): Payee name 2.VNNOVF
(1 char, position 271, added byJB02
): Name overflow indicator.STATID
(8 chars, positions 272-279): State ID.STATED
(9,2 numeric, positions 280-288): State amount.- Lines
0026-0032
: Define fields in the User Data Structure (UDS
): HEAD1
(30 chars, positions 1-30): First heading (e.g., company name).HEAD2
(30 chars, positions 31-60): Second heading (e.g., address line 1).HEAD3
(30 chars, positions 61-90): Third heading (e.g., address line 2).ID#
(10 chars, positions 91-100): Company Tax ID.ENTAMT
(8,2 numeric, positions 101-108): Threshold amount for printing.CURLST
(1 char, position 109): Current/Last indicator (C
orL
).CNYEAR
(4 numeric, positions 201-204): Current year.YEAR
(4 numeric, positions 203-204): Year (overlaps withCNYEAR
, possibly a typo or legacy field).
- Lines
-
Initial Vendor Processing:
- Indicator Reset:
- Line
C*
: Set indicator33
off (disabling 1099-MISC logic, as this program is for 1099-NEC).
- Line
- 1099 Type Check:
- Lines
C*
: IfVN1099
isN
, set indicator34
on (for 1099-NEC). - The commented-out logic for
VN1099 = 'M'
(1099-MISC) indicates this program is exclusively for 1099-NEC.
- Lines
-
Vendor Number Check:
- Lines
C*
: IfVNVEND
equals32800
, setYES
to'YES'
(3 chars). This likely flags a specific vendor for special handling, though its purpose is unclear (different from9384
inAP765
).
- Lines
-
Amount Validation:
- Line
0034
: AddL1AMT1
andL1AMT2
to computeTOTAMT
(9,2 numeric), the total vendor payment. - Line
0035
: CompareTOTAMT
withENTAMT
(threshold amount fromUDS
). Set indicator30
ifTOTAMT
is greater than or equal toENTAMT
. -
Line
0036
: If indicator30
is off (N30
), skip to theEND
tag, bypassing the vendor (i.e., only vendors meeting the threshold are printed). -
Form Counter Logic:
-
Lines
C*
: Manage theCOUNTP
(2 numeric) field to track whether the first (31
), second (32
), or third (40
) form on the page is being processed:- If
COUNTP
is2
, increment to3
, set indicator40
on (third form), set32
off, and jump toSKIP
. - If
COUNTP
is zero, set it to1
, set31
on (first form), set32
and40
off. - Otherwise, increment
COUNTP
, set31
and40
off, set32
on (second form). - This supports printing three forms per page, a key difference from
AP765
(which prints two forms per page, revisionMG03
).
- If
-
Clear Work Fields:
-
Lines
JB01
: For each form (indicators31
,32
,40
):- Clear fields for payee names (
PYN11
,PYN12
,PYN13
,PYN21
,PYN22
,PYN23
), tax IDs (VNID#1
,VNID#2
,VNID#3
), state amounts (STATE1
,STATE2
,STATE3
), state IDs (STATI1
,STATI2
,STATI3
), vendor numbers (VNVEN1
,VNVEN2
,VNVEN3
), addresses (ADDR11
,ADDR12
,ADDR13
,ADDR21
,ADDR22
,ADDR23
,CTSTZ1
,CTSTZ2
,CTSTZ3
), and amounts (AMT11
,AMT12
,AMT13
,AMT31
,AMT32
,AMT33
,AMT61
,AMT62
,AMT63
,AMT71
,AMT72
,AMT73
). - Reset indicators
71
,72
,73
,35
,36
,37
to control name and address printing.
- Clear fields for payee names (
-
Payee and Address Processing (First Form, Indicator
31
): - Lines
JB01
: Determine whether to use vendor name or payee names:- If
VNPYN1
is blank, useVNNAME
forPYN11
(vendor name). - If
VNNOVF
isY
(name overflow, revisionJB02
), set indicators35
and71
on. - If
VNPYN1
is not blank, useVNPYN1
forPYN11
and set71
on. IfVNPYN2
is not blank, useVNPYN2
forPYN21
and set71
on.
- If
- Lines
0045-0069
: Assign address fields based on non-blank values:- If
VNADD4
is not blank, setCTSTZ1
(city/state/ZIP) toVNADD4
,VNAD21
toVNADD3
,VNAD11
toVNADD2
, andPYN21
toVNADD1
. - Else if
VNADD3
is not blank, setCTSTZ1
toVNADD3
,VNAD21
toVNADD2
,PYN21
toVNADD1
. - Else if
VNADD2
is not blank, setCTSTZ1
toVNADD2
,PYN21
toVNADD1
. - Else if
VNADD1
is not blank, setCTSTZ1
toVNADD1
. - If none are non-blank, set indicator
73
on (likely to skip address printing). - Jump to
CONT1
tag after address assignment.
- If
-
Lines
0045-0069
(non-overflow case,N35
): Similar address assignment without overflow logic. -
Payee and Address Processing (Second Form, Indicator
32
): -
Identical logic to the first form, but for fields
PYN12
,PYN22
,VNAD12
,CTSTZ2
, with indicators36
and72
, jumping toCONT2
tag. -
Payee and Address Processing (Third Form, Indicator
40
): -
Identical logic to the first form, but for fields
PYN13
,PYN23
,VNAD13
,CTSTZ3
, with indicators37
and73
, jumping toCONT3
tag. -
Address Processing (Non-Overflow,
CONT3
,CONT4
,CONT5
): -
Lines
0045-0069
: For each form (31N35
,32N36
,40N37
), assign address fields similarly to ensure proper formatting when no name overflow occurs, jumping toCONT3
,CONT4
, orCONT5
tags. -
Amount Assignment for Printing:
- Lines
0071-0094
: Assign amounts to specific 1099 box fields based onBOX1
andBOX2
for each form (31
,32
,40
): - For
BOX1
:- If
1
, setAMT11
/AMT12
/AMT13
toL1AMT1
(box 1 for 1099-NEC). - If
3
, setAMT31
/AMT32
/AMT33
toL1AMT1
(box 3, possibly for other forms). - If
6
, setAMT61
/AMT62
/AMT63
toL1AMT1
(box 6, possibly for other forms). - If
7
, setAMT71
/AMT72
/AMT73
toL1AMT1
(box 7, standard for 1099-NEC Non-Employee Compensation).
- If
- For
BOX2
:- If
1
, setAMT11
/AMT12
/AMT13
toL1AMT2
. - If
3
, setAMT31
/AMT32
/AMT33
toL1AMT2
. - If
6
, setAMT61
/AMT62
/AMT63
toL1AMT2
. - If
7
, setAMT71
/AMT72
/AMT73
toL1AMT2
.
- If
- Lines
-
Accumulate Totals:
- Lines
0095-0098
: For each form (31
,32
,40
): - Increment
COUNT
(6 numeric, total vendors printed). - Add
AMT11
/AMT12
/AMT13
toLRAMT1
(10,2 numeric, total for box 1). - Add
AMT31
/AMT32
/AMT33
toLRAMT3
(total for box 3). - Add
AMT61
/AMT62
/AMT63
toLRAMT6
(total for box 6). - Add
AMT71
/AMT72
/AMT73
toLRAMT7
(total for box 7).
- Lines
-
Page Break Logic:
- Lines
C*
: IfCOUNTP
equals3
(all three forms on the page filled): - Reset
COUNTP
to zero, set indicators31
,32
,40
on, and execute anEXCPT
to print the page. - At end of file (
LR
on): - If data remains for the first form (
31
on), set indicator30
on, clearTEST
(11 chars), and executeEXCPT
to print a final page with one vendor. - Unlike
AP765
, this program does not compute a grand total (LRAMT
) across all boxes, focusing only on individual box totals.
- Lines
-
Output to Printer:
- Lines
0107-0140
: Define the output format forAP1099
: - First Form (Indicator
31
):- Lines 5-23: Print company headers (
HEAD1-3
), year (CNYEAR
), tax IDs (ID#
,VNID#1
), payee names (PYN11
,PYN21
), addresses (VNAD11
,VNAD21
,CTSTZ1
), amounts (AMT11
,AMT31
,AMT61
,AMT71
), and vendor number (VNVEN1
, revisionJB02
). - Conditional on
34
(1099-NEC) for primary amount (AMT11
) andN34
for other boxes (AMT31
).
- Lines 5-23: Print company headers (
- Second Form (Indicator
32
):- Similar fields for the second form, using
PYN12
,PYN22
,VNAD12
,CTSTZ2
,AMT12
,AMT32
,AMT62
,AMT72
,VNID#2
,VNVEN2
.
- Similar fields for the second form, using
- Third Form (Indicator
40
):- Similar fields for the third form, using
PYN13
,PYN23
,VNAD13
,CTSTZ3
,AMT13
,AMT33
,AMT63
,AMT73
,VNID#3
,VNVEN3
.
- Similar fields for the third form, using
- Totals (LR):
- Print
HEAD1-3
,ID#
, totals (LRAMT1
,LRAMT6
,LRAMT7
), and vendor count (COUNT
). Notably,LRAMT3
is printed but not accumulated for40
, indicating a possible oversight or specific requirement.
- Print
- Lines
Business Rules¶
- Threshold Check:
-
Only vendors with a total amount (
TOTAMT
=L1AMT1
+L1AMT2
) greater than or equal toENTAMT
are printed. -
Three Forms per Page:
- The program prints three 1099-NEC forms per page on laser paper (revision
MG03
, modified for three forms), managed byCOUNTP
and indicators31
,32
,40
. -
If fewer than three vendors remain at the end, a final page with one or two vendors is printed.
-
Payee Name Handling:
- If
VNPYN1
is blank, useVNNAME
(vendor name). Otherwise, useVNPYN1
andVNPYN2
(payee names, revisionJB01
). -
If
VNNOVF
isY
, use address fields to continue the name on the second line (revisionJB02
). -
Address Formatting:
-
Use the highest non-blank address field (
VNADD4
toVNADD1
) for city/state/ZIP (CTSTZ1
/CTSTZ2
/CTSTZ3
) and shift other fields accordingly to ensure proper formatting. -
Box Amount Assignment:
-
Amounts are assigned to boxes 1, 3, 6, or 7 based on
BOX1
andBOX2
, with a focus on box 7 for 1099-NEC Non-Employee Compensation (revisionMG04
supports multiple form types). -
1099 Type:
-
Indicator
34
is set forVN1099 = 'N'
(1099-NEC). The commented-out logic forM
(1099-MISC) ensures this program is dedicated to 1099-NEC. -
Totals:
-
Accumulate totals for boxes 1, 3, 6, and 7 (
LRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
) and vendor count (COUNT
). UnlikeAP765
, no grand total (LRAMT
) is computed. -
Vendor Number as Account Number:
- Print
VNVEND
as the account number (VNVEN1
/VNVEN2
/VNVEN3
, revisionJB02
).
Comparison with AP765.rpg36.txt¶
- Similarity:
- Both programs read
AP766
, validate amounts againstENTAMT
, handle payee names and addresses, assign amounts to boxes 1, 3, 6, or 7, and print toAP1099
. - Both support revisions
JB01
(payee names),JB02
(name overflow, vendor number as account),MG03
(laser paper), andMG04
(multiple form types). - Differences:
- Forms per Page:
AP765
prints two forms per page (COUNTP
up to 2, indicators31
/32
), whileAP765N
prints three forms per page (COUNTP
up to 3, indicators31
/32
/40
). - 1099 Type:
AP765
handles both 1099-MISC (VN1099 = 'M'
, indicator33
) and 1099-NEC (VN1099 = 'N'
, indicator34
), whileAP765N
is dedicated to 1099-NEC (VN1099 = 'N'
, indicator34
only). - Vendor Number Check:
AP765
checks forVNVEND = 9384
, whileAP765N
checks forVNVEND = 32800
. - Totals:
AP765
computes a grand total (LRAMT
), whileAP765N
does not, though it printsLRAMT3
in the totals section without accumulating it for40
. - Output Lines:
AP765N
has fewer active output lines for amounts (e.g.,AMT61
,AMT71
are commented out), focusing on 1099-NEC fields.
Tables/Files Used¶
- AP766:
- Input file (300 bytes, labeled
?9?AP766
in the OCL, e.g.,XXAP766
). -
Contains preprocessed vendor data from
AP766.rpg36.txt
, including vendor details, amounts, box numbers, and payee names. -
AP1099:
- Output printer file (80 bytes, labeled
AP1099
in the OCL). -
Configured to print 1099-NEC forms with form type
1099
, 10 CPI, 6 LPI, three forms per page. -
PA1099X (Implied):
- Referenced in the OCL (
?9?PA1099X
), likely a cross-reference file, but not used directly in this program.
External Programs Called¶
- None are explicitly called within
AP765N
. It is invoked byAP765N.ocl36.txt
and processes data fromAP766.rpg36.txt
, with input prepared by#GSORT
andAP766
.
Outputs¶
- AP1099 Printer File:
- Prints 1099-NEC forms (three per page) with:
- Company headers (
HEAD1
,HEAD2
,HEAD3
). - Year (
CNYEAR
). - Company Tax ID (
ID#
) and vendor Tax ID (VNID#1
/VNID#2
/VNID#3
). - Payee names (
PYN11
/PYN12
/PYN13
,PYN21
/PYN22
/PYN23
) or vendor name (VNNAME
). - Addresses (
VNAD11
/VNAD12
/VNAD13
,VNAD21
/VNAD22
/VNAD23
,CTSTZ1
/CTSTZ2
/CTSTZ3
). - Amounts for boxes 1, 3, 6, or 7 (
AMT11
/AMT12
/AMT13
,AMT31
/AMT32
/AMT33
,AMT61
/AMT62
/AMT63
,AMT71
/AMT72
/AMT73
), primarily box 7 for 1099-NEC. - Vendor number as account number (
VNVEN1
/VNVEN2
/VNVEN3
, revisionJB02
).
- Company headers (
- Final page includes totals (
LRAMT1
,LRAMT6
,LRAMT7
,LRAMT3
for31
/32
only) and vendor count (COUNT
).
Summary¶
- Purpose: The RPG program
AP765N
prints 1099-NEC forms, formatting three forms per page on laser paper, using preprocessed vendor data fromAP766
. - Process:
- Reads
AP766
and validates vendor amounts againstENTAMT
. - Manages three forms per page with
COUNTP
and indicators31
/32
/40
. - Assigns payee names, addresses, and amounts to appropriate fields, focusing on 1099-NEC.
- Prints forms with company and vendor details, amounts, and totals.
- Business Rules:
- Prints only vendors meeting the amount threshold.
- Supports three forms per page and 1099-NEC exclusively.
- Handles payee names, name overflow, and vendor number as account number.
- Accumulates totals for boxes 1, 3, 6, and 7, but not a grand total.
- Files Used:
- Input:
AP766
(preprocessed vendor data). - Output:
AP1099
(printer file for 1099-NEC forms). - External Programs: None called directly; part of a workflow with
#GSORT
,AP766
, andAP765N.ocl36.txt
.
This program is tailored for 1099-NEC forms, differing from AP765
by supporting three forms per page and focusing exclusively on Non-Employee Compensation, ensuring IRS-compliant output for vendors.