AP205 RPG
The AP205.rpg36.txt
file is an RPG III program (AP205
) called within the AP200.ocl36.txt
OCL procedure to summarize Accounts Payable (A/P) transactions for the Purchase Journal. Below, I provide a detailed explanation of its process steps, business rules, tables/files used, and external programs called, along with its purpose in the context of the AP200
OCL procedure.
Purpose in AP200 OCL¶
The AP205
program is responsible for summarizing A/P journal entries from the Purchase Journal process initiated by AP200
. It processes sorted journal register records (APPJJR
), accumulates amounts for summarized A/P entries, and writes summarized or detailed journal entries to a temporary general ledger file (TEMGEN
) and a printed report (APPRINT
). This step finalizes the journal entries for A/P transactions, ensuring they are properly formatted for general ledger integration and reporting.
In the AP200
OCL procedure, AP205
is called after sorting the journal register (APPJ?WS?
into APPK?WS?
) to produce a summarized output, which is critical for financial reporting and ledger updates.
Process Steps¶
- Initialization:
- Set Indicators and Variables:
- Clears indicator
60
(SETOF 60
). - Checks if the year/period (
KYYYPD
) inAPCONT
is non-zero; if zero, sets indicator99
(SETON 99
).
- Clears indicator
- Time and Date Setup:
- Retrieves system time (
TIME
toTIMDAT
) and formats it intoTIME
(HHMMSS) andDATE
(MMDDYY). - Converts
DATE
toSYSYMD
(YYYYMMDD) by multiplying by 10000.01 and moves toSYSDT8
(8-digit date).
- Retrieves system time (
- Page and Separator:
- Initializes page number (
PAGE
) to 0. - Sets separator (
SEP
) to'* '
for report formatting.
- Initializes page number (
-
Company Lookup:
- Chains
PJCONO
(company number fromAPPJJR
) toAPCONT
to retrieve company name (ACNAME
). Sets indicator94
if not found.
- Chains
-
Process Input Records (
APPJJR
): - Read Input:
- Reads records from
APPJJR
(journal register file) at levelL4
(company level).
- Reads records from
- Determine Debit/Credit:
- Compares
PJCORD
(credit/debit flag) to'D'
; sets indicator30
if debit (DEBIT
).
- Compares
- Summarize A/P Entries:
- Compares
PJTYPE
to'AP '
; sets indicator20
if true (summarize A/P only).
- Compares
-
Accumulate Amount:
- Adds
PJAMT
(amount fromAPPJJR
) toL1AMT
(level 1 accumulator) for summarized entries.
- Adds
-
Date and Century Handling:
- Converts
PJDATE
(purchase journal date) toYMD
(YYYYMMDD) by multiplying by 10000.01. - Extracts year (
YY
) fromYMD
. - Compares
YY
toY2KCMP
(80, fromAPCONT
):- If
YY >= 80
, sets century (CN
) toY2KCEN
(19). - Otherwise, adds 1 to
Y2KCEN
(e.g., 19 + 1 = 20).
- If
-
Combines century and
YMD
intoCYMD
(century + YYYYMMDD). -
Journal Entry Processing:
- Non-Summarized Entries:
- If not summarized (
N20
), callsJRNL
subroutine to write detailed journal entries.
- If not summarized (
-
Summarized Entries:
- At level
L1
(summary level) and ifPJTYPE = 'AP '
(20
), callsJRNL
subroutine to write summarized A/P entries.
- At level
-
JRNL Subroutine:
- Increments journal reference number (
JRREF#
). - Sets credit/debit flag (
CORD
) based onPJCORD
:- If
L1AMT < 0
(indicator10
), reverses sign ofL1AMT
and togglesCORD
('C'
for credit,'D'
for debit).
- If
- Accumulates amounts:
- If debit (
CORD = 'D'
, indicator11
), addsL1AMT
toL4DR
(debit total). - If credit (
CORD != 'D'
,N11
), addsL1AMT
toL4CR
(credit total).
- If debit (
- Sets journal amount (
JRAMT
) toL1AMT
and resetsL1AMT
to 0. -
Checks if gallons (
PJGALN
) is non-zero (sets indicator60
). -
Write to Output Files:
- TEMGEN (General Ledger File):
- Writes detailed entries (
DADD 01N20
): - Includes company (
PJCONO
), G/L number (PJGLNO
), journal number (PJJRNL
), reference (JRREF#
), credit/debit (CORD
), description (PJDES1
orPJDES2
), vendor (PJVN10
), date (YMD
,CYMD
), amount (JRAMT
), gallons (PJGALN
), and receipt (PJRCPT
). - Writes summarized entries (
TADD L1 20
): - Similar fields but with fixed description (
'-SUMMARIZED A/P '
) andPJDATE
.
- Writes detailed entries (
-
APPRINT (Printed Report):
- Prints header (
D 103 L4
orOFNL4
): - Company name (
ACNAME
), page number, date (DATE
), time (TIME
), journal title (PURCHASE JOURNAL
), and period (KYPD
,KYPDYY
). - Prints column headers for journal, reference, description, vendor, G/L number, debit/credit amounts.
- Prints detailed entries (
D 1 01N20
): - Journal number, reference, description, vendor, G/L number, and amount (debit or credit).
- Includes gallons and receipt number if
PJGALN
is non-zero (60
). - Prints summarized entries (
T 1 L1 20
): - Similar format with
'-SUMMARIZED A/P'
description. - Prints journal totals (
T 2 L4
): - Debit total (
L4DR
) and credit total (L4CR
).
- Prints header (
-
End Processing:
- Continues reading
APPJJR
records until end-of-file, processing each at appropriate levels (L4
,L1
). - Outputs final totals and closes files.
Business Rules¶
- Summarization:
- Only records with
PJTYPE = 'AP '
are summarized (indicator20
). - Summarized entries aggregate amounts (
L1AMT
) by company and type, written at levelL1
. - Debit/Credit Handling:
- Determines debit (
D
) or credit (C
) based onPJCORD
. - If amount is negative, reverses sign and toggles
CORD
(e.g., negative debit becomes credit). - Year 2000 Compliance:
- Handles dates using
Y2KCEN
(century, default 19) andY2KCMP
(80) to determine if year is 19xx or 20xx. - Error Checking:
- Validates year/period (
KYYYPD
) inAPCONT
; sets indicator99
if invalid (zero). - Chains to
APCONT
for company name; sets indicator94
if not found. - Output Formatting:
- Detailed entries include vendor, gallons, and receipt data if applicable.
- Summarized entries use a fixed description and aggregated amounts.
- Report includes headers, totals, and formatted dates/amounts.
- Gallons and Receipt:
- Includes
PJGALN
(gallons) andPJRCPT
(receipt number) in output only ifPJGALN
is non-zero.
Tables/Files Used¶
- Input:
APPJJR
(Primary Input,IP
):- Journal register file (sorted input from
AP200
). - Fields:
PJDEL
(delete flag),PJCONO
(company),PJJRNL
(journal number),PJCORD
(credit/debit),PJGLNO
(G/L number),PJDES1
(description 1),PJDATE
(journal date),PJAMT
(amount),PJDES2
(description 2),PJVN10
(vendor),PJTYPE
(type),PJGALN
(gallons),PJRCPT
(receipt).
- Journal register file (sorted input from
AP205S
(Secondary Input,IR
):- Sorted journal register file (used for control breaks).
- Keys:
PJCONO
(company),PJCORD
(credit/debit),PJTYPE
(type).
APCONT
(Chained Input,IC
):- A/P control file.
- Fields:
ACNAME
(company name),KYYYPD
(year/period),KYPDYY
,KYPD
,JRDATE
(journal date),WIREDS
(wire transfer description),Y2KCEN
(century),Y2KCMP
(year compare).
- Output:
TEMGEN
(Output,O
):- Temporary general ledger file.
- Stores detailed and summarized journal entries for ledger integration.
APPRINT
(Printer,O
):- Printed Purchase Journal report.
- Includes headers, detailed/summarized entries, and totals.
External Programs Called¶
- None:
- The
AP205
program does not call external programs. It relies on internal subroutines (JRNL
) for processing.
Role in AP200 OCL¶
In the AP200
OCL procedure, AP205
is called after sorting the journal register (APPJ?WS?
into APPK?WS?
) to:
- Summarize A/P transactions for the Purchase Journal.
- Generate a formatted report (APPRINT
) for auditing and financial review.
- Write journal entries to TEMGEN
for integration with the general ledger.
- Ensure accurate debit/credit totals and proper date handling for compliance.
This step is critical for consolidating A/P data into a summarized format, making it ready for ledger posting and reporting, which aligns with the overall goal of AP200
to process and post A/P voucher transactions.
Key Notes¶
- Control Breaks:
- Uses
L4
(company),L3
(credit/debit),L2
(type), andL1
(summary) for processing records hierarchically. - Y2K Handling:
- Ensures dates are correctly interpreted for 19xx or 20xx centuries.
- Output Flexibility:
- Supports both detailed and summarized entries, with conditional inclusion of gallons and receipt data.
- File Integration:
- Links with
APCONT
for company and period data, ensuring consistency with A/P controls.
If you need further details on specific fields, logic, or integration with other OCL steps, let me know!