AP765 RPG36
Explanation of the Process Steps and Business Rules in the RPG Program (AP765.rpg36.txt)¶
The RPG III program AP765.rpg36.txt
is designed to print vendor 1099 forms on an IBM System/36 or AS/400 system. It is called by the OCL program AP765.ocl36.txt
and uses data from the preprocessed file AP766
to generate 1099 forms, printing two forms per page on laser paper. 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 (AP765
) and parameterP016
, likely a control parameter passed from the OCL program.
- 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. - Line
0009
:AP1099
(Output, 80 bytes, Printer): The printer file used to output 1099 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.,M
for Miscellaneous,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:
- Vendor Number Check:
- Lines
C*
: IfVNVEND
equals9384
, setYES
to'YES'
(3 chars). This likely flags a specific vendor for special handling, though its purpose is unclear.
- Lines
-
1099 Type Check:
- If
VN1099
isM
(Miscellaneous), set indicator33
on. - If
VN1099
isN
(Non-Employee Compensation), set indicator34
on. - These indicators control which box amounts are printed (e.g.,
AMT11
for 1099-MISC or 1099-NEC).
- If
-
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
) or second (32
) form on the page is being processed:- If
COUNTP
is zero, set it to1
, set indicator31
on (first form), and set32
off. - Otherwise, increment
COUNTP
, set31
off, and set32
on (second form). - This supports printing two forms per page (revision
MG03
).
- If
-
Clear Work Fields:
-
Lines
JB01
: For each form (indicators31
or32
):- Clear fields for payee names (
PYN11
,PYN12
,PYN21
,PYN22
), tax IDs (VNID#1
,VNID#2
), state amounts (STATE1
,STATE2
), state IDs (STATI1
,STATI2
), vendor numbers (VNVEN1
,VNVEN2
), addresses (ADDR11
,ADDR12
,ADDR21
,ADDR22
,CTSTZ1
,CTSTZ2
), and amounts (AMT11
,AMT12
,AMT31
,AMT32
,AMT61
,AMT62
,AMT71
,AMT72
). - Reset indicators
71
,72
,35
,36
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. -
Address Processing (Non-Overflow,
CONT3
andCONT4
): -
Lines
0045-0069
: For both forms (31N35
and32N36
), assign address fields similarly to ensure proper formatting when no name overflow occurs. -
Amount Assignment for Printing:
-
Lines
0071-0094
: Assign amounts to specific 1099 box fields based onBOX1
andBOX2
:- For
BOX1
(indicators31
and32
): - If
1
, setAMT11
/AMT12
toL1AMT1
(e.g., box 1 for 1099-MISC). - If
3
, setAMT31
/AMT32
toL1AMT1
(e.g., box 3 for 1099-MISC). - If
6
, setAMT61
/AMT62
toL1AMT1
(e.g., box 6 for 1099-MISC). - If
7
, setAMT71
/AMT72
toL1AMT1
(e.g., box 7 for 1099-NEC). - For
BOX2
(indicators31
and32
): - If
1
, setAMT11
/AMT12
toL1AMT2
. - If
3
, setAMT31
/AMT32
toL1AMT2
. - If
6
, setAMT61
/AMT62
toL1AMT2
. - If
7
, setAMT71
/AMT72
toL1AMT2
.
- For
-
Accumulate Totals:
- Lines
0095-0098
: For each form: - Increment
COUNT
(6 numeric, total vendors printed). - Add
AMT11
/AMT12
toLRAMT1
(10,2 numeric, total for box 1). - Add
AMT31
/AMT32
toLRAMT3
(total for box 3). - Add
AMT61
/AMT62
toLRAMT6
(total for box 6). - Add
AMT71
/AMT72
toLRAMT7
(total for box 7).
- Lines
-
Page Break Logic:
- Lines
C*
: IfCOUNTP
equals2
(both forms on the page filled): - Reset
COUNTP
to zero, set31
on, and execute anEXCPT
to print the page. - At end of file (
LR
on): - If data remains for the first form (
31
on, not32
), print a final page with one vendor. - Compute total amount
LRAMT
(11,2 numeric) by summingLRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
. - Set indicator
30
and executeEXCPT
to print 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
), and amounts (AMT11
,AMT31
,AMT61
,AMT71
). - Conditional on
33
(1099-MISC) or34
(1099-NEC) for amount fields.
- 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
.
- Similar fields for the second form, using
- Totals (LR):
- Print
HEAD1-3
,ID#
, totals (LRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
,LRAMT
), and vendor count (COUNT
).
- Print
- Vendor Number (Revision
JB02
):- Print
VNVEN1
/VNVEN2
as the account number for each form.
- Print
- Lines
Business Rules¶
- Threshold Check:
-
Only vendors with a total amount (
TOTAMT
=L1AMT1
+L1AMT2
) greater than or equal toENTAMT
are printed. -
Two Forms per Page:
- The program prints two 1099 forms per page on laser paper (revision
MG03
), managed byCOUNTP
and indicators31
/32
. -
If only one vendor remains at the end of the file, a final page with one form 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
) 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
values, supporting both 1099-MISC and 1099-NEC forms (revisionMG04
). -
1099 Type:
-
Indicator
33
for 1099-MISC (VN1099 = 'M'
) and34
for 1099-NEC (VN1099 = 'N'
) control amount field printing. -
Totals:
-
Accumulate totals for each box (
LRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
) and vendor count (COUNT
) for the final summary. -
Vendor Number as Account Number:
- Print
VNVEND
as the account number (revisionJB02
).
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 forms with form type
1099
, 10 CPI, 6 LPI, two 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
AP765
. It is invoked byAP765.ocl36.txt
and processes data fromAP766.rpg36.txt
, with input prepared by#GSORT
andAP766
.
Outputs¶
- AP1099 Printer File:
- Prints 1099 forms (two per page, revision
MG03
) with:- Company headers (
HEAD1
,HEAD2
,HEAD3
). - Year (
CNYEAR
). - Company Tax ID (
ID#
) and vendor Tax ID (VNID#1
/VNID#2
). - Payee names (
PYN11
/PYN12
,PYN21
/PYN22
) or vendor name (VNNAME
). - Addresses (
VNAD11
/VNAD12
,VNAD21
/VNAD22
,CTSTZ1
/CTSTZ2
). - Amounts for boxes 1, 3, 6, or 7 (
AMT11
/AMT12
,AMT31
/AMT32
,AMT61
/AMT62
,AMT71
/AMT72
). - Vendor number as account number (
VNVEN1
/VNVEN2
, revisionJB02
).
- Company headers (
- Final page includes totals (
LRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
,LRAMT
) and vendor count (COUNT
).
Summary¶
- Purpose: The RPG program
AP765
prints 1099 forms (MISC and NEC) using preprocessed vendor data, formatting two forms per page on laser paper. - Process:
- Reads
AP766
and validates vendor amounts against a threshold (ENTAMT
). - Manages two forms per page with
COUNTP
and indicators31
/32
. - Assigns payee names, addresses, and amounts to appropriate fields.
- Prints forms with company and vendor details, amounts, and totals.
- Business Rules:
- Prints only vendors meeting the amount threshold.
- Supports two forms per page and different 1099 types (MISC, NEC).
- Handles payee names, name overflow, and vendor number as account number.
- Accumulates totals for reporting.
- Files Used:
- Input:
AP766
(preprocessed vendor data). - Output:
AP1099
(printer file for 1099 forms). - External Programs: None called directly; part of a workflow with
#GSORT
,AP766
, andAP765P
.
This program finalizes the 1099 form printing process, producing IRS-compliant output for vendors.