AP193 RPG
The provided document is an RPG (Report Program Generator) program named AP193
for the IBM System/36 or AS/400, called from the OCL program discussed previously. It serves as an edit program for Accounts Payable (A/P) check reconciliation data uploaded from PNC, validating data in the workfile (APCRTR
) against control files (APCONT
, GLMAST
, APCHKR
) and producing a report (LIST
). Below, I’ll explain the process steps, business rules, tables used, and any external programs called.
Process Steps of the RPG Program (AP193)¶
The AP193
program reads records from the A/P check reconciliation workfile (APCRTR
), validates them against control files (APCONT
, GLMAST
, APCHKR
), accumulates totals, and generates a report (LIST
) with validation results and errors. Here’s a step-by-step breakdown:
- File Definitions:
- Input Files:
APCRTR
(Primary Input,IP
, 80 bytes, indexed with 2-byte key at position 16): Workfile containing check reconciliation data fromAP192
.APCONT
(Input Control,IC
, 256 bytes, indexed with 2-byte key at position 2): A/P control file with company or configuration data.GLMAST
(Input Control,IC
, 256 bytes, indexed with 2-byte key at position 11): General Ledger master file for account validation.APCHKR
(Input Control,IC
, 128 bytes, indexed with 2-byte key at position 16): A/P check reconciliation file with historical check data.
- Output File:
LIST
(Output,O
, 132 bytes, printer file): Generates a report detailing check reconciliation results, errors, and totals.
-
Data Structures:
COM
(Error message array, 10 elements, 30 bytes each): Stores error messages (e.g., "INVALID CHECK #", "CHECK NOT FOUND").SEP
(66-byte array, 2 elements): Likely used for report separators (e.g., lines or spaces).
-
Input Record Mapping:
- APCRTR (Primary Input):
ATKEY
(positions 2–17): Key field (likely check number).ATCO
(positions 2–3): Company code, used forL3
(company-level) totaling.ATGL#
(positions 4–11): General Ledger number, used forL2
(G/L-level) totaling.ATCHK#
(positions 12–17): Check number, used for validation.ATCLAM
(positions 23–33): Clear amount (check amount to be reconciled).ATCLDT
(positions 40–45): Clear date (date the check cleared).
- APCONT (Control):
ACDEL
(position 1): Deletion flag (‘D’ for deleted).ACNAME
(positions 4–33): Company name.
- GLMAST (Control):
GLDEL
(position 1): Deletion flag (‘D’ for deleted).GLDESC
(positions 13–37): General Ledger description.
- APCHKR (Control):
AMCODE
(position 1): Check status code (‘D’, ‘O’, ‘R’, ‘V’ for deleted, open, reconciled, voided).AMVEN#
(positions 18–22): Vendor number.AMCKAM
(positions 23–33): Check amount.AMCKDT
(positions 34–39): Check date.AMVNNM
(positions 46–75): Vendor name.
-
UDS (User Data Structure):
Y2KCEN
(positions 509–510): Century for Y2K handling.Y2KCMP
(positions 511–512): Company code for Y2K.
-
Initialization (N09 Block):
- If indicator
09
is off (N09
), the program:- Initializes
L2CLAM
andL3CLAM
(G/L and company clear amount totals) to zero (Z-ADD*ZEROS
). - Captures system time (
TIME
) and moves it toTIMDAT
(12 bytes), then extractsSYSTIM
(time, 6 bytes) andSYSDAT
(date, 6 bytes). - Sets
SEP
to'* '
(separator for report). - Initializes
PAGE
to zero for report pagination. - Sets
GLKEY
to'C'
(11 bytes, likely a default G/L key). - Sets indicator
09
on to prevent re-execution.
- Initializes
-
This block runs once at program start to set up variables and report parameters.
-
Indicator and Variable Reset:
- Indicators
30
,31
,32
,33
,34
,81
,90
,91
,92
,93
,94
,95
,96
are turned off (SETOF
). - Error message fields (
MSG
,MSG1
–MSG6
) are cleared to blanks. -
COUNT
(error counter) is reset to zero. -
Validation Logic:
- Company Validation:
- The program chains
ATCO
(company code fromAPCRTR
) toAPCONT
(CHAINAPCONT
, indicator30
). - If no record is found or
ACDEL
= ‘D’ (deleted), indicator30
is set, andCONONM
(company name) is cleared; otherwise,CONONM
is set toACNAME
.
- The program chains
- General Ledger Validation:
- Constructs
GLKEY
by combiningATCO
andATGL#
intoGLKY10
(10 bytes) and moving it toGLKEY
. - Chains
GLKEY
toGLMAST
(CHAINGLMAST
, indicator31
). - If no record is found or
GLDEL
= ‘D’ (deleted), indicator31
is set, andBKGLNM
(G/L description) is cleared; otherwise,BKGLNM
is set toGLDESC
.
- Constructs
- Check Validation:
- Chains
ATKEY
(check number) toAPCHKR
(CHAINAPCHKR
, indicator32
). - If no record is found, sets indicator
90
, logs error “CHECK # NOT FOUND” (COM,3
/COM,4
toMSG1
), incrementsCOUNT
, and branches toAROUND
(skips further checks). - Checks
AMCODE
inAPCHKR
for: - ‘D’ (Deleted): Sets indicator
91
, logs “CHECK WAS PREVIOUSLY DELETED” (COM,3
/COM,5
toMSG2
), incrementsCOUNT
. - ‘R’ (Reconciled): Sets indicator
92
, logs “CHECK IS ALREADY RECONCILED” (COM,3
/COM,6
toMSG3
), incrementsCOUNT
. - ‘V’ (Voided): Sets indicator
93
, logs “CHECK WAS PREVIOUSLY VOIDED” (COM,3
/COM,7
toMSG4
), incrementsCOUNT
. - ‘O’ (Open): Sets indicator
94
, logs “CHECK IS NOT OPEN” (COM,3
/COM,8
toMSG5
), incrementsCOUNT
. - Compares
ATCLAM
(clear amount fromAPCRTR
) toAMCKAM
(check amount fromAPCHKR
) (COMP
, indicator34
). - If amounts don’t match, sets indicator
95
, logs “CLEAR AMOUNT DOES NOT MATCH” (COM,10
toMSG6
), incrementsCOUNT
.
- Chains
-
If any validation fails, the program branches to
AROUND
to skip further processing for the record. -
Accumulation:
-
If validations pass (no branch to
AROUND
), addsATCLAM
toL2CLAM
(G/L total) andL3CLAM
(company total). -
Report Generation:
-
The program writes to the
LIST
printer file:- Header (Level
L3
, Company-Level): - Prints company name (
ACNAME
), page number (PAGE
), system date (SYSDAT
), bank info, and report title (“A/P CANCELLED CHECKS EDIT FROM PNC UPLOAD”). - Includes system time (
SYSTIM
) and separators (SEP
). - Column headers: “CHECK #”, “CLEAR DATE”, “CLEAR AMOUNT”.
- Detail Lines (Level
01
): - Prints check number (
ATCHK#
), clear date (ATCLDT
), and clear amount (ATCLAM
). - If errors exist (indicators
90
–95
), prints corresponding error messages (MSG1
–MSG6
) at position 110. - Totals (Level
L2
andL3
): - At
L2
(G/L break), prints “BANK G/L # TOTAL” withL2CLAM
. - At
L3
(company break), prints “COMPANY TOTAL” withL3CLAM
.
- Header (Level
-
Program Flow:
- The RPG cycle reads each
APCRTR
record, validates it againstAPCONT
,GLMAST
, andAPCHKR
, logs errors, accumulates totals, and writes report lines. - The program continues until all
APCRTR
records are processed, producing a report with headers, detail lines, error messages, and totals.
Business Rules¶
- Validation of Company and G/L:
- Each record’s company code (
ATCO
) must exist inAPCONT
and not be deleted (ACDEL ≠ ‘D’
). -
The G/L number (
ATGL#
) combined withATCO
must exist inGLMAST
and not be deleted (GLDEL ≠ ‘D’
). -
Check Validation:
- The check number (
ATKEY
) must exist inAPCHKR
. - The check must not be deleted (
AMCODE ≠ ‘D’
), reconciled (AMCODE ≠ ‘R’
), voided (AMCODE ≠ ‘V’
), or non-open (AMCODE ≠ ‘O’
). -
The clear amount (
ATCLAM
) must match the check amount (AMCKAM
) inAPCHKR
. -
Error Handling:
- Errors are logged with predefined messages (e.g., “CHECK # NOT FOUND”, “CLEAR AMOUNT DOES NOT MATCH”).
-
Each error increments a counter (
COUNT
) and is printed in the report. -
Totaling:
- Clear amounts are accumulated at the G/L level (
L2CLAM
) and company level (L3CLAM
) for valid records. -
Totals are printed at G/L and company breaks in the report.
-
Report Formatting:
- The report includes headers with company, date, time, and bank info.
- Detail lines show check number, clear date, clear amount, and any errors.
- Totals are printed for each G/L account and company.
Tables (Files) Used¶
- APCRTR:
- Primary input file, 80 bytes, indexed.
- Contains check reconciliation data from
AP192
(check number, G/L number, company code, clear amount, clear date). - APCONT:
- Input control file, 256 bytes, indexed.
- Stores company data (name, deletion flag).
- GLMAST:
- Input control file, 256 bytes, indexed.
- Stores General Ledger data (description, deletion flag).
- APCHKR:
- Input control file, 128 bytes, indexed.
- Stores historical check data (status code, vendor number, check amount, check date, vendor name).
- LIST:
- Output printer file, 132 bytes.
- Generates the reconciliation edit report.
External Programs Called¶
The AP193
RPG program does not explicitly call any external programs. It is a self-contained program that processes input from APCRTR
, validates against APCONT
, GLMAST
, and APCHKR
, and produces a report via LIST
. It is called by the OCL program as part of the A/P reconciliation workflow.
Summary¶
The AP193
RPG program validates A/P check reconciliation data from APCRTR
against control files (APCONT
, GLMAST
, APCHKR
), logs errors, accumulates totals, and generates a report (LIST
). It:
- Validates company, G/L, and check data, ensuring records are not deleted, reconciled, or voided, and amounts match.
- Logs errors with predefined messages and counts errors.
- Accumulates clear amount totals at G/L and company levels.
- Produces a formatted report with headers, detail lines, error messages, and totals.
Business Rules: - Validate company, G/L, and check data for existence and status. - Ensure clear amounts match historical check amounts. - Log and report errors for invalid records. - Accumulate and report totals by G/L and company.
Tables Used: APCRTR
(input), APCONT
(control), GLMAST
(control), APCHKR
(control), LIST
(output).
External Programs Called: None.
If you need further details, such as specific field formats or deeper analysis of the report structure, let me know!