AP300 RPG
The provided RPG program, AP300.rpg36.txt
, is an RPG II program designed for the IBM System/36 environment, called by the OCL script AP300.ocl36.txt
. It performs the actual clearing of Month-to-Date (MTD) and Year-to-Date (YTD) totals in the Accounts Payable (A/P) vendor master file. This program is the final step in the A/P update process orchestrated by AP300P.ocl36.txt
, AP300P.rpg36.txt
, and AP300.ocl36.txt
. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called, ensuring a concise and clear analysis that integrates with the previous documents.
Process Steps of the RPG Program¶
The AP300
program processes the sorted vendor records to clear MTD and optionally YTD totals in the vendor master file. Here’s a step-by-step breakdown:
- File and Data Definitions:
- Files:
APVEND
: Vendor master file, defined as an update file (UP
) with 579-byte records, indexed (I
), used for reading and updating vendor records.AP300S
: Sorted input file, defined as an input file (IR
) with 30-byte records, indexed with 3-byte keys (3IT
), used to identify which vendor records to update.
- Input Specifications:
APVEND
fields (packed decimal,P
):VN$YTD
(6,2): YTD purchases (positions 195–200).VN$LYR
(6,2): Last year’s purchases (positions 201–206).VNDMTD
(4,2): MTD discounts (positions 207–210).VNDYTD
(5,2): YTD discounts (positions 211–215).VNPBAL
(5,2): Previous balance (positions 220–224).VNPURC
(5,2): MTD purchases (positions 225–229).VNPAY
(5,2): MTD payments (positions 230–234).VNCBAL
(5,2): Current balance (positions 235–239).VNTYDP
(6,2): This year’s YTD paid (positions 242–247).VNLYDP
(6,2): Last year’s YTD paid (positions 248–253).UDS
(Local Data Area):KYYTDY
(1 byte, position 135): Flag indicating whether to clear YTD totals ('Y'
or blank).
-
Indicators:
05
: Controls whether the program runs (set ifKYYTDY ≠ 'Y'
).50
: Set if YTD clearing is requested (KYYTDY = 'Y'
).01
: Output indicator for updatingAPVEND
records.
-
Initialization and YTD Check (Lines 0026–0027):
- Checks if
KYYTDY = 'Y'
(fromAP300P.rpg36.txt
via the Local Data Area). - If true, sets indicator
50
to control YTD field updates. -
If
KYYTDY ≠ 'Y'
, sets indicator05
to ensure the program processes MTD updates (line 0027). -
MTD Field Updates (Lines 0029–0032):
- For each vendor record processed:
- Clears
VNDMTD
(MTD discounts) to 0 (Z-ADD0
). - Sets
VNPBAL
(previous balance) to the value ofVNCBAL
(current balance), preserving the balance before clearing MTD fields. - Clears
VNPURC
(MTD purchases) to 0. - Clears
VNPAY
(MTD payments) to 0.
- Clears
-
These updates apply to all records processed, regardless of
KYYTDY
. -
YTD Field Updates (Lines 0034–0038):
-
If indicator
50
is on (KYYTDY = 'Y'
):- Moves
VN$YTD
(YTD purchases) toVN$LYR
(last year’s purchases), preserving YTD data before clearing. - Clears
VNDYTD
(YTD discounts) to 0. - Clears
VN$YTD
(YTD purchases) to 0. - Moves
VNTYDP
(this year’s YTD paid) toVNLYDP
(last year’s YTD paid), preserving payment data. - Clears
VNTYDP
(this year’s YTD paid) to 0.
- Moves
-
Output to Vendor File (Lines 0040–0049):
- Updates the
APVEND
file for each processed record (indicator01
):- If indicator
50
is on, updates: VN$YTD
(YTD purchases).VN$LYR
(last year’s purchases).VNDYTD
(YTD discounts).VNTYDP
(this year’s YTD paid).VNLYDP
(last year’s YTD paid).- Updates MTD fields for all records:
VNDMTD
(MTD discounts).VNPBAL
(previous balance).VNPURC
(MTD purchases).VNPAY
(MTD payments).
- If indicator
-
The updates are written to the
APVEND
file, modifying the vendor records. -
Program Flow:
- The program processes records from
AP300S
(sorted by company and vendor, as prepared by#GSORT
inAP300.ocl36.txt
). - For each record in
AP300S
, it locates the corresponding record inAPVEND
(via indexing) and applies the MTD and optional YTD updates. - The program relies on the
AP300S
file to determine which vendors to update, based on the company selection (KYALCO
,KYCO1
,KYCO2
,KYCO3
) fromAP300P.rpg36.txt
.
Business Rules¶
The program enforces the following business rules for clearing MTD and YTD totals:
- MTD Clearing:
- Always clears MTD fields for all processed records:
VNDMTD
(MTD discounts) set to 0.VNPURC
(MTD purchases) set to 0.VNPAY
(MTD payments) set to 0.
-
Preserves the current balance by moving
VNCBAL
toVNPBAL
before clearing MTD fields. -
YTD Clearing:
- Clears YTD fields only if
KYYTDY = 'Y'
(controlled by indicator50
):- Moves
VN$YTD
(YTD purchases) toVN$LYR
(last year’s purchases). - Clears
VN$YTD
andVNDYTD
(YTD discounts) to 0. - Moves
VNTYDP
(this year’s YTD paid) toVNLYDP
(last year’s YTD paid). - Clears
VNTYDP
to 0.
- Moves
-
Preserves YTD data in last-year fields (
VN$LYR
,VNLYDP
) for historical reference or auditing. -
Record Selection:
-
Processes only records included in the sorted
AP300S
file, which filters vendors by:- Company selection (
ALL
or specific companiesKYCO1
,KYCO2
,KYCO3
) fromAP300P
. - Non-deleted status (
NECD ≠ 'D'
) fromAP300.ocl36.txt
.
- Company selection (
-
Data Integrity:
- Ensures the current balance (
VNCBAL
) is not modified, maintaining financial accuracy. -
Preserves YTD data in last-year fields when clearing YTD totals, supporting audit and 1099 requirements.
-
Dependencies:
- Relies on
AP300P.rpg36.txt
to validate user input (KYYTDY
, company selections). - Relies on
AP300.ocl36.txt
to sortAPVEND
intoAP300S
and handle backups for 1099 processing.
Tables (Files) Used¶
The program uses the following files:
- APVEND:
- Type: Disk file (update,
UP
). - Purpose: Vendor master file containing financial data (MTD/YTD totals), updated by the program.
- Record Length: 579 bytes, indexed (
I
). - Fields Updated:
VN$YTD
,VN$LYR
,VNDMTD
,VNDYTD
,VNPBAL
,VNPURC
,VNPAY
,VNTYDP
,VNLYDP
.
-
Label:
?9?APVEND
(e.g.,PRODAPVEND
). -
AP300S:
- Type: Disk file (input,
IR
). - Purpose: Sorted temporary file containing vendor records to be updated, filtered by company and non-deleted status.
- Record Length: 30 bytes, indexed with 3-byte keys (likely company and vendor numbers).
- Label:
?9?AP300S
.
External Programs Called¶
The RPG program does not directly call any external programs (e.g., via CALL
operations). It is executed by the AP300.ocl36.txt
script and relies on:
- #GSORT (from
AP300.ocl36.txt
): - Prepares the
AP300S
file by sortingAPVEND
based on company and vendor fields. -
Not called directly by
AP300.rpg36.txt
but critical to its input. -
AP300P.rpg36.txt (indirectly):
- Provides validated parameters (
KYYTDY
,KYALCO
,KYCO1
, etc.) via the Local Data Area, set beforeAP300
runs.
No other programs are called within the RPG code.
Summary¶
Process Overview:
- AP300.rpg36.txt
clears MTD and optionally YTD totals in the APVEND
vendor master file.
- Processes records from the sorted AP300S
file, updating:
- MTD fields (VNDMTD
, VNPURC
, VNPAY
) to 0, with VNPBAL
set to VNCBAL
.
- YTD fields (VN$YTD
, VNDYTD
, VNTYDP
) to 0 if KYYTDY = 'Y'
, moving current YTD values to last-year fields (VN$LYR
, VNLYDP
).
- Updates are written back to APVEND
for each processed record.
Business Rules:
- Always clears MTD fields, preserving the current balance.
- Clears YTD fields only if KYYTDY = 'Y'
, preserving YTD data in last-year fields.
- Processes only records from AP300S
, filtered by company and non-deleted status.
- Maintains data integrity for financial accuracy and auditing.
Tables Used:
- APVEND
: Vendor master file (updated).
- AP300S
: Sorted temporary file (input).
External Programs:
- None called directly; relies on #GSORT
(via AP300.ocl36.txt
) and AP300P.rpg36.txt
(for parameters).
This program completes the A/P update process by performing the actual data modifications, integrating with the validation from AP300P.rpg36.txt
and file management from AP300.ocl36.txt
. If you need further details (e.g., file record layouts or additional context), please provide more information!