AP791 RPG36
The provided document, AP791.rpg36.txt
, is an RPG/36 program (used in IBM System/36 or AS/400 environments) called from the OCL program AP791.ocl36.txt
. This program processes and prints a 1099 file for IRS reporting, handling data from the IRSTAX
file, outputting to the PA1099
file, and generating a printed report. Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.
Process Steps of the AP791 RPG Program¶
The RPG program follows a structured flow to read, process, and output 1099-related data. Here’s a breakdown of the process steps based on the RPG/36 code:
- File Definitions (Lines 0005-0006):
- Input File (
IRSTAX
): Defined as a primary input file (IP
) with a record length of 750 bytes. It contains 1099 data, including transmitter "T" records and payee "B" records. Multiple commented-out definitions suggest possible variations (e.g.,IRSTAXSOIS
or a 864-byte version), but only the 750-byteIRSTAX
is active. - Output File (
PA1099
): Defined as an output file (O
) with a record length of 875 bytes, used to store processed 1099 data. -
Printer File (
PRINT
): Defined as a printer output file (O
) with a record length of 164 bytes, used to generate a formatted 1099 report. -
Input Specifications (Lines 0007-0122):
- The program reads records from
IRSTAX
and identifies them by a record type (A1REC
) at position 1:- Transmitter "T" Record (Line 0007,
NS 01
): Identified byA1REC = 'T'
, processed differently from payee records. - Payee "B" Record (Line 0007,
NS 02
): Default record type for payee data, processed for 1099 reporting.
- Transmitter "T" Record (Line 0007,
-
Fields are mapped from the
IRSTAX
file, including:- Payment year (
A1YR
, positions 2-5) - Taxpayer ID number (
A1TIN#
, positions 12-20) - Type of TIN (
A1TTIN
, position 11,1
for EIN,2
for SSN) - Payment amounts (
A1PAY1
toA1PAYC
, positions 55-198, for various payment types) - Payee details (name, address, city, state, zip, etc.)
- Tax withholding (
A1SITW
for state,A1LITW
for local) - Other indicators (e.g.,
A1FCI
for foreign country,A1DSI
for direct sales).
- Payment year (
-
Calculation Specifications (Lines 0194-0206):
- Record Processing:
- For "T" records (
NS 01
): - The program skips processing and jumps to the
END
tag (Line 0206), bypassing payee calculations. - For "B" records (
NS 02
): - Increments a record counter (
REC#
) and a count (COUNT
) for tracking (Line 0194, 0199). - Accumulates non-zero payment amounts (
A1PAY1
,A1PAY2
,A1PAY3
,A1PAY7
) into totals (TPAY1
,TPAY2
,TPAY3
,TPAY7
) and a combined total (DPAY
) (Lines 0199-0200). - Checks the TIN type (
A1TTIN
=1
for EIN or2
for SSN) to set indicators21
or22
(Lines 0203-0204). - Writes the processed record to the
PA1099
file via theIN
exception output (Line 0205).
- For "T" records (
-
Commented-Out Logic:
- Some conditional checks (e.g.,
A1PYES IFNE 'PA'
) and additional accumulations (NPAY1
,NPAY2
,NPAY7
) are commented out, suggesting they were used in prior versions or for specific cases (e.g., filtering by state or additional totals).
- Some conditional checks (e.g.,
-
Output Specifications (Lines 0207-0251):
- Printer Output (
PRINT
):- Header Records (Lines 0207-0231):
- Prints headers for the report, including:
- Company name (“AMERICAN REFINING GROUP, INC”).
- Program name (“AP791”) and report title (“A/P 1099 FILE”).
- Page number (
PAGE
) and date (UDATE
). - Column headers for record number, TIN type, name control, SSN/EIN, payment amounts, name, address, city, state, and zip.
- Headers are printed at the start of the report (
1P
) or on overflow (OF
). - Detail Lines (Lines 0232-0251,
E IN
): - For each payee record, prints:
- Record number (
REC#
). - TIN type (
A1TTIN
) and name control (A1NCTL
). - Formatted TIN (
A1ID21
,A1ID22
, etc., with hyphens for readability). - Payment amounts (
A1PAY1M
,A1PAY2M
,A1PAY3M
). - Payee details (name, address, city, state, zip).
- Record number (
- Total Lines (Line 0232,
E TOTL
): - Prints accumulated totals for
TPAY1
,TPAY2
,TPAY7
at the end of the report.
-
File Output (
PA1099
) (Lines 0232-0251,EADD IN
):- Writes records to the
PA1099
file with: - Hard-coded values (e.g.,
222318612
for payer TIN,001
for sequence). - Payment year (
A1YR
), TIN (A1TIN#
), vendor number (A1VEND
), and payee details. - Payment amounts (
A1PAY1
,A1PAY2
,A1PAY3
,A1PAY7
,A1SITW
). - Company details (“AMERICAN REFINING GROUP, INC”, address, etc.).
- Combined payment total (
DPAY
).
- Writes records to the
-
End of Program:
- After processing all records, the program writes final totals to the printer (
EXCPTTOTL
) and terminates at theEND
tag (Line 0206).
Business Rules¶
The program enforces the following business rules for 1099 processing: 1. Record Type Handling: - Skips “T” (Transmitter) records, as they are not relevant for payee reporting. - Processes “B” (Payee) records for 1099 data.
- Payment Accumulation:
- Only non-zero payment amounts (
A1PAY1
,A1PAY2
,A1PAY3
,A1PAY7
) are added to running totals (TPAY1
,TPAY2
,TPAY3
,TPAY7
) and a combined total (DPAY
). -
These payments likely correspond to specific 1099 categories (e.g., non-employee compensation, rents, royalties).
-
TIN Formatting:
-
TINs are identified as EIN (
A1TTIN = '1'
) or SSN (A1TTIN = '2'
) and formatted accordingly (e.g.,XXX-XXXXXX
for EIN,XXX-XX-XXXX
for SSN) for the printed report. -
Payee Filtering:
-
Commented-out logic suggests a prior rule to filter records where the state (
A1PYES
) is not “PA” (Pennsylvania), but this is not active in the current version. -
Output Formatting:
- The
PA1099
file includes fixed payer details (e.g., TIN222318612
, address “77 NORTH KENDALL AVENUE, BRADFORD, PA 16701”) and payee-specific data. -
The printed report formats TINs with hyphens for readability and aligns payment amounts and payee details in columns.
-
IRS Compliance:
- The program structures data in the
PA1099
file to meet IRS 1099 reporting requirements, including payment amounts, withholding, and payee information (name, address, TIN).
Tables/Files Used¶
- IRSTAX:
- Type: Input (
IP
) - Record Length: 750 bytes
-
Description: Primary input file containing 1099 data, including transmitter (“T”) and payee (“B”) records. Fields include payment year, TIN, payment amounts, and payee details.
-
PA1099:
- Type: Output (
O
) - Record Length: 875 bytes
-
Description: Output file storing processed 1099 data for IRS submission, including payer and payee details, payment amounts, and withholding.
-
PRINT:
- Type: Printer Output (
O
) - Record Length: 164 bytes
- Description: Printer file for generating a formatted 1099 report with headers, detail lines, and totals.
External Programs Called¶
- None: The RPG program does not explicitly call any external programs. The
GSY2K
program referenced in the OCL program is executed beforeAP791
is loaded, so it is not called from within the RPG code.
Additional Notes¶
- Commented-Out Code: The presence of commented-out definitions (e.g.,
IRSTAXSOIS
, alternateIRSTAX
lengths) and logic (e.g., state filtering, additional totals) suggests the program was adapted over time or supports multiple configurations. These could be re-enabled for specific requirements. - TIN Formatting: The program formats TINs differently for EIN and SSN, ensuring compliance with IRS reporting standards.
- Hard-Coded Values: The
PA1099
output includes fixed payer details (e.g., TIN222318612
, address), indicating the program is tailored for “AMERICAN REFINING GROUP, INC.” - Environment: The program is designed for the System/36 or AS/400, using RPG/36 syntax and OCL for job control.
If you need further details (e.g., specific field mappings, IRS 1099 form alignment, or analysis of commented-out logic), please let me know!