Skip to content

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

  1. Initialization:
  2. Set Indicators and Variables:
    • Clears indicator 60 (SETOF 60).
    • Checks if the year/period (KYYYPD) in APCONT is non-zero; if zero, sets indicator 99 (SETON 99).
  3. Time and Date Setup:
    • Retrieves system time (TIME to TIMDAT) and formats it into TIME (HHMMSS) and DATE (MMDDYY).
    • Converts DATE to SYSYMD (YYYYMMDD) by multiplying by 10000.01 and moves to SYSDT8 (8-digit date).
  4. Page and Separator:
    • Initializes page number (PAGE) to 0.
    • Sets separator (SEP) to '* ' for report formatting.
  5. Company Lookup:

    • Chains PJCONO (company number from APPJJR) to APCONT to retrieve company name (ACNAME). Sets indicator 94 if not found.
  6. Process Input Records (APPJJR):

  7. Read Input:
    • Reads records from APPJJR (journal register file) at level L4 (company level).
  8. Determine Debit/Credit:
    • Compares PJCORD (credit/debit flag) to 'D'; sets indicator 30 if debit (DEBIT).
  9. Summarize A/P Entries:
    • Compares PJTYPE to 'AP '; sets indicator 20 if true (summarize A/P only).
  10. Accumulate Amount:

    • Adds PJAMT (amount from APPJJR) to L1AMT (level 1 accumulator) for summarized entries.
  11. Date and Century Handling:

  12. Converts PJDATE (purchase journal date) to YMD (YYYYMMDD) by multiplying by 10000.01.
  13. Extracts year (YY) from YMD.
  14. Compares YY to Y2KCMP (80, from APCONT):
    • If YY >= 80, sets century (CN) to Y2KCEN (19).
    • Otherwise, adds 1 to Y2KCEN (e.g., 19 + 1 = 20).
  15. Combines century and YMD into CYMD (century + YYYYMMDD).

  16. Journal Entry Processing:

  17. Non-Summarized Entries:
    • If not summarized (N20), calls JRNL subroutine to write detailed journal entries.
  18. Summarized Entries:

    • At level L1 (summary level) and if PJTYPE = 'AP ' (20), calls JRNL subroutine to write summarized A/P entries.
  19. JRNL Subroutine:

  20. Increments journal reference number (JRREF#).
  21. Sets credit/debit flag (CORD) based on PJCORD:
    • If L1AMT < 0 (indicator 10), reverses sign of L1AMT and toggles CORD ('C' for credit, 'D' for debit).
  22. Accumulates amounts:
    • If debit (CORD = 'D', indicator 11), adds L1AMT to L4DR (debit total).
    • If credit (CORD != 'D', N11), adds L1AMT to L4CR (credit total).
  23. Sets journal amount (JRAMT) to L1AMT and resets L1AMT to 0.
  24. Checks if gallons (PJGALN) is non-zero (sets indicator 60).

  25. Write to Output Files:

  26. 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 or PJDES2), 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 ') and PJDATE.
  27. APPRINT (Printed Report):

    • Prints header (D 103 L4 or OFNL4):
    • 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).
  28. End Processing:

  29. Continues reading APPJJR records until end-of-file, processing each at appropriate levels (L4, L1).
  30. Outputs final totals and closes files.

Business Rules

  1. Summarization:
  2. Only records with PJTYPE = 'AP ' are summarized (indicator 20).
  3. Summarized entries aggregate amounts (L1AMT) by company and type, written at level L1.
  4. Debit/Credit Handling:
  5. Determines debit (D) or credit (C) based on PJCORD.
  6. If amount is negative, reverses sign and toggles CORD (e.g., negative debit becomes credit).
  7. Year 2000 Compliance:
  8. Handles dates using Y2KCEN (century, default 19) and Y2KCMP (80) to determine if year is 19xx or 20xx.
  9. Error Checking:
  10. Validates year/period (KYYYPD) in APCONT; sets indicator 99 if invalid (zero).
  11. Chains to APCONT for company name; sets indicator 94 if not found.
  12. Output Formatting:
  13. Detailed entries include vendor, gallons, and receipt data if applicable.
  14. Summarized entries use a fixed description and aggregated amounts.
  15. Report includes headers, totals, and formatted dates/amounts.
  16. Gallons and Receipt:
  17. Includes PJGALN (gallons) and PJRCPT (receipt number) in output only if PJGALN 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).
  • 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), and L1 (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!