AP256 RPG
The provided RPG program, AP256.rpg36.txt
, is executed by the OCL program AP256.ocl36.txt
, which is called from the main OCL program (AP250.ocl36.txt
) within an IBM System/36 or AS/400 Accounts Payable (A/P) system. Its purpose is to generate vendor payment detail reports for ACH (Automated Clearing House) vendors, with output directed to four spool files (REPORT1
to REPORT4
) that are emailed to vendors. Below, I will explain the process steps, business rules, tables (files) used, and external programs called based on the RPG code.
Process Steps of the AP256 RPG Program¶
The AP256
RPG program processes temporary A/P transaction data (APDTWS
and APDTWSC
), retrieves vendor and company information, and generates up to four reports (REPORT1
to REPORT4
) containing payment details for ACH vendors, formatted for emailing. Here is a detailed breakdown of the process steps:
- Initialization (Level 2 - Company Break):
-
At the company level (
L2
, based onADCO
):- Retrieves the current system date and time using the
TIME
operation, storing it inTIMDAT
(12 digits). - Extracts the date portion into
DATE
(6 digits) and converts it to a year-month-day format (DATYMD
) by multiplying by10000.01
. - Sets the century prefix (
20
for 2000s) intoDATE8
(8-digit date, e.g.,20YYMMDD
) and movesDATYMD
intoDATE8
. - Chains to the
APCONT
file using the company number (ADCO
) to retrieve the company name (ACNAME
). - Initializes the page number (
PAGE
) to 0 and a separator line (SEP
) to'* '
for report formatting.
- Retrieves the current system date and time using the
-
Vendor Processing (Level 1 - Vendor Break):
-
At the vendor level (
L1
, based onADVEND
):- Chains to the
APVEND
file using the company/vendor number (ADCOVN
) to retrieve vendor details (e.g.,VNNAME
,VNADD1
toVNADD4
,VNZIP5
,VNZPX4
). - Chains to the
APDTWSC
file to retrieve the ACH transaction count (ACECNT
) for the vendor. - Chains to the
APVNFMX
file up to four times to retrieve email addresses (AMEMLA
) for ACH transactions (AMFMTY = 'ACHE'
): - Stores email addresses in
EMALP1
toEMALP4
for use inREPORT1
toREPORT4
. - Initializes totals for invoice amount (
L1INV$M
), discount (L1DIS$M
), and payment (L1PYM$M
) to zero. - Sets indicator
60
based on the vendor type (VNCAID
): - If
VNCAID ≠ 'CRUDE'
,60
is off, using standard messages (MSG,1
toMSG,3
). - If
VNCAID = 'CRUDE'
,60
is on, using crude-specific messages (MSG,4
toMSG,6
).
- Chains to the
-
Transaction Processing (Indicator 01):
-
For each record in the
APDTWS
file (primary input, indicator01
):- Converts the payment date (
ADDATE
) to an 8-digit format (KYCKDTY
, e.g.,MMDDYYYY
) using century-aware logic (Y2KCEN
). - Formats monetary fields for reporting:
- Invoice amount (
ADINV$
) toADINV$M
. - Discount amount (
ADDISC
) toADDISCM
. - Payment amount (
ADLPAM
) toADPYM$M
. - Accumulates totals at the vendor level (
L1
): - Adds
ADINV$
toL1INV$M
. - Adds
ADDISC
toL1DIS$M
. - Adds
ADLPAM
toL1PYM$M
.
- Converts the payment date (
-
Report Generation (REPORT1 to REPORT4):
-
Generates four reports (
REPORT1
toREPORT4
), each directed to a different spool file (OF
,OG
,OA
,OB
) and potentially emailed to different vendor email addresses (EMALP1
toEMALP4
):- Headers (Lines 06-28):
- Prints at the vendor level (
L1
, lines 52/53):- Current date (
UDATE
, formatted asMMDDYY
). - Company number (
ADCO
) and vendor number (ADVEND
). - Vendor name (
VNNAME
) and address (VNADD1
toVNADD4
). - Messages based on vendor type:
- Standard vendors (
N60
):MSG,1
toMSG,3
(e.g., "THE INVOICES LISTED BELOW WERE PAID BY ARG THROUGH ACH ON MM/DD/YY."). - Crude vendors (
60
):MSG,4
toMSG,6
(e.g., "THIS EMAIL IS NOTIFICATION THAT A DEPOSIT WILL BE MADE INTO YOUR ACCOUNT."). - Payment date (
KYCKDTY
). - Email address (
EMALP1
toEMALP4
) for the respective report.
- Current date (
- Detail Lines (Line 31-33):
- Prints for each
APDTWS
record:- Payment date (
KYCKDTY
). - Invoice number (
ADINVN
). - Invoice amount (
ADINV$M
). - Discount amount (
ADDISCM
). - Payment amount (
ADPYM$M
).
- Payment date (
- Totals (Line E 3):
- Prints vendor-level totals at
L1
:"TOTAL:"
.- Total invoice amount (
L1INV$M
). - Total discount (
L1DIS$M
). - Total payment (
L1PYM$M
).
- Continuation Message:
- If the report exceeds the page length, prints
"CONTINUED ON NEXT PAGE"
.
-
Completion:
- Processes all
APDTWS
records, generating reports for each vendor with ACH transactions. - Terminates, returning control to the
AP256.ocl36.txt
OCL program.
Business Rules¶
The program enforces the following business rules based on its logic and context within the A/P system:
- ACH Vendor Reporting:
- Generates detailed payment reports for vendors using ACH payments, identified by
AMFMTY = 'ACHE'
inAPVNFMX
. -
Supports up to four email addresses per vendor (
EMALP1
toEMALP4
), allowing multiple recipients for payment notifications. -
Vendor Type Differentiation:
- Distinguishes between standard vendors and crude vendors (
VNCAID = 'CRUDE'
):- Standard vendors receive messages
MSG,1
toMSG,3
(e.g., instructions to send invoices toacctpayable@amref.com
). - Crude vendors receive messages
MSG,4
toMSG,6
(e.g., notification of deposit with contact details for Ashley Lipps).
- Standard vendors receive messages
-
Indicator
60
controls message selection based onVNCAID
. -
Data Summarization:
- Accumulates invoice, discount, and payment amounts at the vendor level (
L1INV$M
,L1DIS$M
,L1PYM$M
) for reporting totals. -
Includes only ACH-related transactions from
APDTWS
, as filtered byAP256A
. -
Date Handling:
-
Uses century-aware date processing to format payment dates (
ADDATE
toKYCKDTY
) based onY2KCEN
(e.g.,19
or20
for century). -
Report Output:
- Produces four reports (
REPORT1
toREPORT4
), each directed to a separate spool file and potentially emailed to different vendor email addresses. - Reports include vendor details, payment details, and totals, formatted for clarity and email delivery.
-
Supports pagination with continuation messages.
-
File Access:
APDTWS
is processed sequentially as the primary input file (IP
).APDTWSC
,APVEND
,APVNFMX
, andAPCONT
are accessed randomly (IF
, keyed) for reference data.-
Reports are written to spool files (
LPRINTER
) for printing or emailing. -
Integration with A/P Process:
- Relies on
APDTWS
andAPDTWSC
being populated byAP256A
and prior steps inAP250.ocl36.txt
. -
Uses
APVEND
andAPCONT
for vendor and company details, andAPVNFMX
for ACH-specific email addresses. -
Error Handling:
- No explicit error reporting for unmatched records or missing data, assuming valid input from
AP256A
.
Tables (Files) Used¶
The program uses the following files, as defined in the File Specification (F-spec) section:
- APDTWS (IP, 256 bytes, keyed,
DISK
): - Primary input file, temporary A/P transaction file containing payment details.
-
Fields include:
ADDEL
: Deletion flag (position 1).ADCO
: Company number (positions 2-3,L2
).ADVEND
: Vendor number (positions 4-8,L1
).ADCOVN
: Company/vendor number (positions 2-8).ADINVN
: Invoice number (positions 9-28).ADIDSC
: Invoice description (positions 29-53).ADINV$
: Invoice amount (packed, positions 54-59).ADDISC
: Discount amount (packed, positions 60-64).ADLPAM
: Last payment amount (packed, positions 65-70).ADDATE
: Payment date (positions 71-76).ADVCH#
: Voucher/check number (positions 77-81).
-
APDTWSC (IF, 10 bytes, keyed,
DISK
): - Indexed temporary file, containing ACH transaction counts from
AP256A
. -
Fields include:
ACDEL
: Deletion flag (position 1).ACCO
: Company number (positions 2-3).ACVEND
: Vendor number (positions 4-8).ACECNT
: ACH transaction count (positions 9-10).
-
APVEND (IF, 579 bytes, keyed,
DISK
): - Vendor master file, containing vendor details.
-
Fields include:
VNDEL
: Deletion flag (position 1).VNCO
: Company number (positions 2-3).VNVEND
: Vendor number (positions 4-8).VNNAME
: Vendor name (positions 9-38).VNADD1
toVNADD4
: Address lines (positions 39-158).VNZIP5
: Zip code (positions 159-163).VNZPX4
: Extra zip (positions 164-167).VNSORT
: Alpha sort abbreviation (positions 168-177).VNAREA
: Area code (positions 178-179).VNTELE
: Telephone number (positions 180-183).VNLPAY
: Last payment amount (packed, positions 184-188).VNLPDT
: Last payment date (positions 189-194).VN$YTD
: Year-to-date purchases (packed, positions 195-200).VN$LYR
: Last year purchases (packed, positions 201-206).VNDMTD
: Month-to-date discounts (packed, positions 207-210).VNDYTD
: Year-to-date discounts (packed, positions 211-215).VNNOVF
: Name overflow flag (position 216).VNPBAL
: Previous balance (packed, positions 220-224).VNPURC
: Month-to-date purchases (packed, positions 225-229).VNPAY
: Month-to-date payments (packed, positions 230-234).VNCBAL
: Current balance (packed, positions 235-239).VNHOLD
: Hold payments flag (position 240).VNSNGL
: Single check flag (position 241).VNTYDP
: Year-to-date paid (packed, positions 242-247).VNLYDP
: Last year-to-date paid (packed, positions 248-253).VNEXGL
: Expense G/L account (positions 254-261).VNTERM
: A/P terms code (positions 262-263).VN1099
: 1099 code (position 264).VNID#
: 1099 ID number (positions 265-275).VNBOX1
,VNBOX2
: 1099 box numbers (positions 276-279).VNB2AM
: 1099 box amount (packed, positions 280-285).VNLPD8
: Last payment date (positions 286-293).VNCAID
: Carrier ID (positions 294-299).
-
APVNFMX (IF, 266 bytes, keyed,
DISK
): - Vendor master extension file, containing ACH email addresses and other details.
-
Fields include (based on
AP256A.rpg.txt
):AMCONO
: Company number.AMCVEN
: Vendor number.AMCOVN
: Company/vendor number.AMFMTY
: Form type (e.g.,'ACHE'
).AMEMLA
: Email address.
-
APCONT (IF, 256 bytes, keyed,
DISK
): - A/P control file, containing company details.
-
Fields include:
ACNAME
: Company name.
-
REPORT1 (O, 132 bytes,
LPRINTER
,OF
): - First report spool file, emailed to
EMALP1
. -
Contains vendor payment details for ACH transactions.
-
REPORT2 (O, 132 bytes,
LPRINTER
,OG
): - Second report spool file, emailed to
EMALP2
. -
Contains vendor payment details for ACH transactions.
-
REPORT3 (O, 132 bytes,
LPRINTER
,OA
): - Third report spool file, emailed to
EMALP3
. -
Contains vendor payment details for ACH transactions.
-
REPORT4 (O, 132 bytes,
LPRINTER
,OB
): - Fourth report spool file, emailed to
EMALP4
. - Contains vendor payment details for ACH transactions.
External Programs Called¶
The AP256
RPG program does not call any external programs. It is self-contained, performing all processing within the main logic and level breaks (L1
, L2
). It is invoked by the AP256.ocl36.txt
OCL program.
Summary¶
The AP256
RPG program generates detailed vendor payment reports for ACH vendors, formatted for emailing. Its key functions are:
- Process Steps:
- Initializes company-level data and retrieves company name (
L2
). - Processes vendor-level data, retrieving vendor details and up to four ACH email addresses (
L1
). - Processes
APDTWS
records, formatting payment details and accumulating totals. -
Generates four reports (
REPORT1
toREPORT4
) with headers, detail lines, totals, and vendor-specific messages. -
Business Rules:
- Generates reports only for ACH vendors (
AMFMTY = 'ACHE'
). - Differentiates between standard and crude vendors (
VNCAID = 'CRUDE'
) for messaging. - Supports up to four email addresses per vendor for report distribution.
- Accumulates invoice, discount, and payment totals at the vendor level.
- Uses century-aware date formatting.
-
Produces formatted reports for printing or emailing via spool files.
-
Tables Used:
APDTWS
: Temporary A/P transaction file (input).APDTWSC
: Indexed temporary file with ACH counts (input).APVEND
: Vendor master file (input).APVNFMX
: Vendor master extension file (input).APCONT
: A/P control file (input).-
REPORT1
toREPORT4
: Report spool files (output). -
External Programs Called: None.
The program integrates with the A/P process by leveraging data prepared by AP256A
and prior steps, producing vendor-specific reports for ACH payments. If you need further details (e.g., specific report formats or email delivery mechanics), please let me know!