AP760 RPG36
The AP760.rpg36.txt is an RPG/36 program (likely running on an IBM System/36 or AS/400 environment) called from the AP760P.ocl36.txt OCL program to generate a Vendor 1099 Register. This program processes vendor data from the AP761 file and produces a printed report (APPRINT) summarizing 1099-related information, such as vendor payments categorized by 1099 box types (e.g., rent, medical, miscellaneous). Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called, based on the provided RPG code.
Process Steps of the RPG/36 Program (AP760)¶
The AP760 program reads vendor data from the AP761 file, retrieves 1099 type descriptions from GSTABL, accumulates totals for specific 1099 boxes, and outputs a formatted report to the printer file APPRINT. Here’s a step-by-step breakdown of the process:
- Program Initialization (lines 0026–0032):
-
ONCE Subroutine:
- Checks if the
ONCEflag is zero (first execution) (line 0026). - Retrieves the system time and date using the
TIMEoperation and stores them inTIMDAT(12 bytes), then moves them toTIME(6 bytes, time) andDATE(6 bytes, date) fields (lines 0027–0029). - Initializes the
SEParray (66 elements, 2 bytes each) with'* 'for use as a separator in the report (line 0030). - Sets
ONCEto 1 to prevent re-execution (line 0031).
- Checks if the
-
Processing Vendor Records (Level 2 Break - L2):
- The program processes records from the
AP761file at level 2 (L2), indicated by theL2indicator, which suggests a control break for grouping records by 1099 type (VN1099). -
Steps for Each L2 Group (lines 0034–0074):
- Initializes the table key (
TBKEY, 12 bytes) to blanks and sets the prefix to'AP1099'(lines 0034–0035). - Appends the vendor’s 1099 code (
VN1099) toTBKEYand chains to theGSTABLfile to retrieve the corresponding description (TBDESC) (lines 0036–0037). - If the record is not found (indicator 99 on) and
KYTY1(from UDS, set byAP760P) is neither'M'(miscellaneous) nor'N'(non-employee compensation), sets indicators 33 or 34 to adjust report formatting (line 0037). - Initializes counters and accumulators for the L2 group:
L2CNT(count of vendors in the group) to zero (line JB01).L21AMT(total for box 1, rent),L23AMT(total for box 3, non-employee compensation),L26AMT(total for box 6, medical), andL27AMT(total for box 7, miscellaneous) to zero (lines 0038–0040).- Initializes report accumulators for each box (
BX1AMT,BX3AMT,BX6AMT,BX7AMT) to zero (lines 0044–0046).
- Initializes the table key (
-
Processing Individual Vendor Records (Level 1 Break - 01):
-
For each vendor record (
AP761, indicator 01), the program processes payment amounts and payee names:- Accumulate Box Amounts (lines 0048–0070):
- Checks the first box number (
VNBOX1) and assigns the first amount (VNAMT1) to the corresponding accumulator:- If
VNBOX1 = 1, addsVNAMT1toBX1AMT(rent) (lines 0048–0050). - If
VNBOX1 = 3, addsVNAMT1toBX3AMT(non-employee compensation) (lines 0052–0054). - If
VNBOX1 = 6, addsVNAMT1toBX6AMT(medical) (lines 0052–0054). - If
VNBOX1 = 7, addsVNAMT1toBX3AMT(miscellaneous, treated as non-employee compensation) (lines 0056–0058).
- If
- Checks the second box number (
VNBOX2) and assigns the second amount (VNAMT2) similarly:- If
VNBOX2 = 1, addsVNAMT2toBX1AMT(rent) (lines 0060–0062). - If
VNBOX2 = 6, addsVNAMT2toBX6AMT(medical) (lines 0064–0066). - If
VNBOX2 = 7, addsVNAMT2toBX3AMT(miscellaneous) (lines 0068–0070).
- If
- Update Group Totals (lines 0071–0074, JB01):
- Increments the vendor count (
L2CNT) for the L2 group. - Adds
BX1AMT,BX3AMT,BX6AMT, andBX7AMTto their respective L2 totals (L21AMT,L23AMT,L26AMT,L27AMT). - Handle Payee Names (lines JB01):
- Initializes
PYN1andPYN2(payee name fields, 40 bytes each) to blanks and turns off indicators 71 and 72 (formatting flags). - If
VNPYN1(payee name 1) is blank, usesVNNAME(vendor name) forPYN1(lines JB01). - If
VNNOVF = 'Y'(name overflow flag), movesVNADD1(address line 1) toPYN2and sets indicator 72 for printing (lines JB02). - If
VNPYN1is not blank, usesVNPYN1forPYN1and sets indicator 71. - If
VNPYN2(payee name 2) is not blank, usesVNPYN2forPYN2and sets indicator 72 (lines JB01).
-
Report Output (APPRINT) (lines 0076–0120):
- The program writes to the printer file
APPRINT(132 characters per line) with the following structure:- L2 Detail and Overflow Lines (lines 0076–0108):
- Prints page number (
PAGE), date (DATE, formatted asY), and time (TIME, formatted asHH.MM.SS) (lines 0078–0086). - Prints the report title “VENDOR 1099 REGISTER” (line 0084).
- Prints the 1099 type (
VN1099) and description (TBDESC) fromGSTABL(lines 0088–0089). - Prints column headers: “NUMBER” (vendor number), “1099 ID #”, “PAYEE NAME”, “RENT (BOX=1)”, “MEDICAL (BOX=6)”, “MISC (BOX=3)” (lines 0095–0105).
- Prints separator lines (
SEP) as needed (lines 0092, 0108). - Vendor Detail Lines (01) (lines 0109–0115, JB01):
- Prints vendor number (
VNVENDZ), 1099 ID (VNID#), payee name 1 (PYN1), and amounts for boxes 1, 6, and 3 (BX1AMTK,BX6AMTK,BX3AMTK) (lines 0109–0115). - If indicator 72 is on, prints payee name 2 (
PYN2) on a second line (line JB01). - L2 Totals (lines 0116–0120):
- Prints “** TOTALS”, vendor count (
L2CNT), and total amounts for boxes 1, 6, and 3 (L21AMTK,L26AMTK,L23AMTK) at the end of each 1099 type group.
Business Rules¶
The AP760 RPG program enforces the following business rules for generating the 1099 register report:
- 1099 Type Grouping:
- The report groups vendors by 1099 type (
VN1099), with subtotals printed at each type change (L2 break). -
Descriptions for 1099 types are retrieved from
GSTABLusing the keyAP1099+VN1099. -
Box Number Mapping:
- Box 1: Rent payments (
VNBOX1orVNBOX2= 1). - Box 3: Miscellaneous payments (
VNBOX1orVNBOX2= 3 or 7). - Box 6: Medical payments (
VNBOX1orVNBOX2= 6). - Box 7: Treated as miscellaneous (mapped to
BX3AMT). -
Amounts are accumulated separately for each box and totaled by 1099 type.
-
Payee Name Formatting (JB01, JB02):
- If
VNPYN1(payee name 1) is blank, useVNNAME(vendor name) as the primary name (PYN1). - If
VNNOVFis'Y', useVNADD1(address line 1) as the secondary name (PYN2) for name overflow. - If
VNPYN1is not blank, useVNPYN1asPYN1andVNPYN2(if not blank) asPYN2. -
Indicators 71 and 72 control printing of
PYN1andPYN2. -
Report Layout:
- Headers include page number, date, time, 1099 type, and column labels.
- Detail lines show vendor number, 1099 ID, payee name(s), and amounts for rent, medical, and miscellaneous boxes.
-
Totals at each 1099 type break include vendor count and box amounts.
-
Data Exclusion:
-
Records marked as deleted (
VNDEL = 'D', position 1) are skipped (handled by prior steps inAP760.ocl36.txtandAP761.rpg36.txt). -
Special Handling:
- If
KYTY1is'M'or'N'and theGSTABLlookup fails, set indicators 33 or 34, respectively, which may affect report formatting or filtering (line 0037).
Tables Used¶
The RPG program uses the following files (tables):
- AP761:
- Type: Disk file (
DISK), primary input file (IP). - Size: 196 bytes.
- Fields:
VNDEL(position 1, 1 byte): Delete code.VN1099L2(position 2, 1 byte): 1099 code (renamedVN1099).VNVENDL1(positions 3–7, 5 bytes): Vendor number (renamedVNVENDZ).VNID#(positions 8–18, 11 bytes): 1099 ID number.VNNAME(positions 19–48, 30 bytes): Vendor name.VNAMT1(positions 49–57, 9 bytes, packed decimal): First box amount.VNAMT2(positions 58–66, 9 bytes, packed decimal): Second box amount.VNBOX1(positions 67–68, 2 bytes): First box number.VNBOX2(positions 69–70, 2 bytes): Second box number.VNPYN1(positions 71–110, 40 bytes): Payee name 1 (added by JB01).VNPYN2(positions 111–150, 40 bytes): Payee name 2 (added by JB01).VNNOVF(position 151, 1 byte): Name overflow (added by JB02).VNADD1(positions 152–181, 30 bytes): Address line 1 (added by JB02).
-
Purpose: Preprocessed 1099 data from
AP761.rpg36.txt, containing one record per vendor. -
GSTABL:
- Type: Disk file (
DISK), input file (IC), keyed access. - Size: 256 bytes, with a 12-byte key.
- Fields:
TBDESC(positions 14–43, 30 bytes): Table description.
-
Purpose: Lookup table for 1099 type descriptions, accessed with key
AP1099+VN1099. -
APPRINT:
- Type: Printer file (
PRINTER), output file (O). - Size: 132 bytes.
- Purpose: Output file for the 1099 register report, containing headers, detail lines, and totals.
External Programs Called¶
The AP760 program does not explicitly call any external programs. However:
- It is invoked by the AP760P.ocl36.txt OCL program, either directly or via a job queue, as specified in the OCL’s // JOBQ or // AP760 commands.
- The AP760P program (previously analyzed) sets up and validates parameters passed to AP760 via the User Data Structure (UDS), specifically KYTY1 for 1099 type filtering.
Summary¶
The AP760 RPG/36 program generates a Vendor 1099 Register by:
1. Initializing date, time, and report formatting settings.
2. Processing vendor records from AP761, grouped by 1099 type (VN1099), and retrieving type descriptions from GSTABL.
3. Accumulating payment amounts for 1099 boxes (1: rent, 3: non-employee compensation, 6: medical, 7: miscellaneous) and handling payee names (using vendor name, payee names, or address for overflow).
4. Printing a formatted report to APPRINT with headers, vendor details, and totals for each 1099 type group.
5. Enforcing business rules for box mapping, payee name formatting, and report structure.
Tables/Files Used:
- AP761 (vendor 1099 data, primary input).
- GSTABL (1099 type descriptions, indexed).
- APPRINT (printer output for the report).
External Programs Called:
- None directly called, but invoked by AP760P.ocl36.txt and relies on parameters set by AP760P.
If you need further details, such as a sample report layout or additional analysis of the AP761 file structure, let me know!