AP765 RPG36
The RPG36 program AP765
is designed to generate Vendor 1099 forms, likely for tax reporting purposes, printing two forms per page on laser paper. It processes vendor data from an input file, validates amounts, formats addresses, and prints the forms with specific fields like payee names, vendor IDs, and amounts. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps¶
- File and Data Structure Definitions:
- File Definitions (F-Spec):
AP766
(Line 0008): Input file (IP
), disk-based, with a record length of 300 bytes, containing vendor data.AP1099
(Line 0009): Output file (O
), printer file with a record length of 80 bytes, used for printing the 1099 forms.LAP1099
(Line 0011): Logical file for the printer, specifying 66 lines per page with overflow at line 66.
- Input Specifications (I-Spec):
- AP766 Record Format (NS 01) (Lines 0012–0025):
- Fields include
VNDEL
(delete code),VN1099
(1099 code),VNVEND
(vendor number),VNNAME
(vendor name),VNADD1–VNADD4
(address lines),L1AMT1
andL1AMT2
(amounts for two boxes),BOX1
andBOX2
(box numbers),VNID#
(1099 ID),VNPYN1
andVNPYN2
(payee names 1 and 2, added in JB01),VNNOVF
(name overflow flag, added in JB02),STATID
, andSTATED
(state-related fields). - Data Structure (UDS) (Lines 0026–0032):
- Fields include
HEAD1
,HEAD2
,HEAD3
(headings),ID#
(company ID),ENTAMT
(entered amount),CURLST
(current/last indicator),CNYEAR
, andYEAR
(year fields).
-
Output Specifications (O-Spec) (Lines 0107–0141):
- Defines output formats for printing two 1099 forms per page (controlled by indicators 31 and 32 for top and bottom forms, respectively).
- Outputs fields like headings, amounts, vendor/payee names, addresses, and totals, with specific positioning on the form.
-
Calculation Specifications (C-Spec):
- Initial Vendor Checks:
- If
VNVEND
equals 9384, setYES
to 'YES' (Line 0033). - If
VN1099
is 'M' (Miscellaneous), set indicator 33; if 'N' (Nonemployee Compensation), set indicator 34 (Lines 0033).
- If
- Amount Validation:
- Line 0034: Add
L1AMT1
andL1AMT2
toTOTAMT
. - Line 0035: Compare
TOTAMT
withENTAMT
. If they don’t match, set indicator 30 and branch toEND
(Line 0036).
- Line 0034: Add
- Form Counter Logic:
- Lines 0037–0037:
COUNTP
tracks whether to print the top (31) or bottom (32) form. IfCOUNTP
is zero, set it to 1 and turn on indicator 31. Otherwise, incrementCOUNTP
and toggle between indicators 31 and 32.
- Lines 0037–0037:
- Clear Work Fields:
- Lines JB01: For each form (31 or 32), clear fields like
PYN11
,PYN12
,PYN21
,PYN22
,VNID#1
,VNID#2
,STATE1
,STATE2
,STATI1
,STATI2
,VNVEN1
,VNVEN2
, and amount fields (AMT11
,AMT31
,AMT61
,AMT71
, etc.).
- Lines JB01: For each form (31 or 32), clear fields like
- Payee and Address Processing for Form 1 (Indicator 31):
- Lines 0038–0069: If
VNPYN1
is blank, useVNNAME
forPYN11
. IfVNNOVF
is 'Y', set indicators 35 and 71 for name overflow. - Address lines (
VNADD1–VNADD4
) are checked in descending order. The highest non-blank address line is moved toCTSTZ1
, with lower lines shifted toVNAD11
,VNAD21
, orPYN21
as needed. - If
VNPYN1
is not blank, useVNPYN1
andVNPYN2
forPYN11
andPYN21
, respectively, and set indicator 71.
- Lines 0038–0069: If
- Payee and Address Processing for Form 2 (Indicator 32):
- Similar logic as above, but for fields like
PYN12
,PYN22
,CTSTZ2
,VNAD12
, andVNAD22
, with indicators 36 and 72.
- Similar logic as above, but for fields like
- Additional Address Processing:
- Lines 0045–0069 (for 31 and 32): Additional checks for non-overflow cases (
N35
orN36
) to format addresses correctly intoCTSTZ1
,VNAD11
,VNAD21
, etc.
- Lines 0045–0069 (for 31 and 32): Additional checks for non-overflow cases (
- Amount Assignment:
- Lines 0071–0094: Assign
L1AMT1
andL1AMT2
to specific amount fields (AMT11
,AMT31
,AMT61
,AMT71
for Form 1;AMT12
,AMT32
,AMT62
,AMT72
for Form 2) based onBOX1
andBOX2
values (1, 3, 6, or 7).
- Lines 0071–0094: Assign
- Accumulate Totals:
- Lines 0095–0098: For each form, increment
COUNT
and add amounts to running totals (LRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
).
- Lines 0095–0098: For each form, increment
- Print Logic:
- Line 0100: If
COUNTP
equals 2, resetCOUNTP
, set indicator 31, and execute theEXCPT
operation to print both forms.
- Line 0100: If
- End-of-File Handling:
- If the end of file is reached (
LR
on), check if indicator 31 is on (data for top form). If so, clear fields, accumulate final totals intoLRAMT
, and print the last form with indicator 30.
- If the end of file is reached (
-
Output Execution:
- The
EXCPT
operation triggers printing of the forms based on indicators 31 and 32, outputting fields to the printer file.
- The
-
Output Processing:
- Form 1 (Indicator 31):
- Outputs headings (
HEAD1
,HEAD2
,HEAD3
), year (CNYEAR
), amounts (AMT11
,AMT31
,AMT61
,AMT71
), IDs (ID#
,VNID#1
), payee names (PYN11
,PYN21
), addresses (VNAD11
,VNAD21
,CTSTZ1
), and vendor number (VNVEN1
).
- Outputs headings (
- Form 2 (Indicator 32):
- Similar to Form 1 but uses fields like
AMT12
,AMT32
,AMT62
,AMT72
,VNID#2
,PYN12
,PYN22
,VNAD12
,VNAD22
,CTSTZ2
, andVNVEN2
.
- Similar to Form 1 but uses fields like
- Totals (LR Indicator):
- Prints totals (
LRAMT1
,LRAMT3
,LRAMT6
,LRAMT7
,LRAMT
,COUNT
) and headings at the end of the job.
- Prints totals (
Business Rules¶
- Amount Validation:
- The sum of
L1AMT1
andL1AMT2
must equalENTAMT
. If not, the program skips to theEND
tag, bypassing further processing for that record. - Form Layout:
- Two forms are printed per page (top and bottom), controlled by indicators 31 and 32, respectively.
COUNTP
toggles between 1 (top) and 2 (bottom). - If only one form remains at the end of the file, it is printed with indicator 30.
- Payee Name Handling (JB01, 2013):
- If
VNPYN1
is blank, useVNNAME
. IfVNPYN1
andVNPYN2
are provided, use them for printing payee names. - Name Overflow (JB02, 2014):
- If
VNNOVF
is 'Y', set indicators 35/71 (Form 1) or 36/72 (Form 2) to handle name continuation on the second line. - Address Formatting:
- Address lines are processed from
VNADD4
toVNADD1
, using the highest non-blank line forCTSTZ1
/CTSTZ2
and shifting lower lines toVNAD11
/VNAD21
orVNAD12
/VNAD22
. - Amount Mapping:
- Amounts (
L1AMT1
,L1AMT2
) are assigned to specific boxes (1, 3, 6, or 7) based onBOX1
andBOX2
values, corresponding to IRS 1099 form fields. - Vendor Number as Account (JB02, 2014):
- Vendor number (
VNVEND
) is printed as the account number (VNVEN1
,VNVEN2
). - Laser Paper Printing (MG03, 2016):
- Designed to print on laser paper with two forms per page.
- Two Different Forms (MG04, 2021):
- Supports printing two distinct 1099 forms per page, with separate fields for each.
- 1099 Code Handling:
- If
VN1099
is 'M', set indicator 33 (Miscellaneous Income). - If
VN1099
is 'N', set indicator 34 (Nonemployee Compensation).
- If
Tables Used¶
- AP766:
- Input disk file containing vendor data:
VNDEL
,VN1099
,VNVEND
,VNNAME
,VNADD1–VNADD4
,L1AMT1
,L1AMT2
,BOX1
,BOX2
,VNID#
,VNPYN1
,VNPYN2
,VNNOVF
,STATID
,STATED
. - No explicit arrays are defined, but work fields like
AMT11
,AMT31
,LRAMT1
, etc., act as temporary storage for calculations and printing.
External Programs Called¶
- None:
- The program does not explicitly call any external programs (no
CALL
statements). - It is invoked from a main OCL script, but no details about the OCL or other programs are provided.
Summary¶
The AP765
program:
- Reads vendor data from the AP766
file and prints 1099 forms to the AP1099
printer file, formatted for laser paper with two forms per page.
- Validates that the sum of L1AMT1
and L1AMT2
matches ENTAMT
.
- Formats payee names, using VNPYN1
and VNPYN2
if provided, or VNNAME
otherwise, with overflow handling.
- Processes addresses by selecting the highest non-blank line and shifting others accordingly.
- Maps amounts to specific 1099 form boxes (1, 3, 6, 7) based on BOX1
and BOX2
.
- Accumulates totals and prints a summary at the end.
- Uses indicators to control printing of top (31) and bottom (32) forms, with special handling for the last form.
- Does not call external programs but is part of a larger OCL-driven process.