AP250RPG GROK
The RPG program AP250.RPG36
is a core component of the Accounts Payable (A/P) Check Register process, invoked by the OCL procedure AP250.OCL36
. It handles the generation of the check register, updates master files, and processes payment-related data, including support for ACH, wire transfers, and employee expenses. Below is a detailed breakdown of the process steps, business rules, tables/files used, and external programs called as requested.
Process Steps¶
The AP250.RPG36
program is structured around a series of subroutines that process input records, update files, and generate output for the check register and related journals. The steps are derived from the RPG source code and are organized by the main processing flow and subroutine execution:
- Initialization (L4DET Subroutine):
- Retrieves the current system time and date, formatting them for output (e.g.,
TIMDAT
,DATYMD
,DATE8
). - Initializes counters and accumulators (e.g.,
PAGE
,ZERO6
,ZERO9
). - Sets a separator field (
SEP
) to'* '
. - Retrieves the check date from
APPYTR
(chain toPTCKDT
, convert toCDYMD8
with century adjustment usingY2KCEN
andY2KCMP
). - Chains to
APCONT
to retrieve company details (e.g.,ACNAME
,ACDSGL
,ACCDJR
,ACCKNO
). - Determines the journal ID (
JRNID
) based on whether a wire transfer is indicated (WIRE = 'WT'
setsJRNID
to'WD'
, otherwise'CD'
; additional logic for ACH, wire transfer, or employee expenses setsJRNID
to'AD'
,'WD'
, or'ED'
respectively). -
Sets indicator
50
for wire transfers, ACH, or employee expenses to skip writing toAPCHKR
. -
Process Each Check Record (EACH01 Subroutine):
- Processes records from
APPYCK
(check file). - Converts the check date (
AXCKDT
) to a formatted date (AXYMD8
). - Copies the check number (
AXCHEK
) to the PNC check number field (PNCCHK
) for positive pay format. - Evaluates the record code (
AXRECD
):'C'
: Credit/no pay, skip processing (indicator19
).'F'
: Full stub, void check, continue to next stub with same check number (indicator12
).'V'
: Full stub, void check, use next check number (indicator13
).'P'
,'A'
,'W'
,'E'
: Prepaid check, ACH, wire transfer, or employee expense, respectively (indicators25
,26
,27
,28
set indicator11
).
- Updates the A/P check reconciliation file (
APCHKR
):- Chains to
APCHKR
using a key constructed fromCONO
,BKGL
, andAXCHEK
. - If not found (
90
on), initializes fields (AMCODE
,AMCKAM
,AMCLDT
,AMOCAM
). - For voided checks (
13
on), setsAMCKAM
to 0 andAMCODE
to'V'
, updates clear date (AMCLDT
,CLDT8
). - For non-voided checks, sets
AMCODE
to'O'
and updatesAMCKAM
withAXAMT
. - Formats the date for PNC positive pay (
PNCDT8
) and setsPNCCOD
to'V'
for voided checks or'I'
otherwise.
- Chains to
- Updates counters and accumulators:
- Increments
C3CNT
and addsAXAMT
toC3AMT
for computer checks (non-prepaid, non-void). - Increments
P3CNT
,A3CNT
,W3CNT
, orE3CNT
and addsAXAMT
to respective accumulators (P3AMT
,A3AMT
,W3AMT
,E3AMT
) for prepaid, ACH, wire transfer, or employee expense records. - Increments
L3CNT
and addsAXAMT
toL3AMT
andL2PAID
for non-voided checks.
- Increments
-
Stores the check number (
AXCHEK
) inL4CHEK
for updatingAPCONT
. -
Process Payment Records (EACH02 Subroutine):
- Processes records from
APPAY
(payment file). - Accumulates discount taken (
OPDISC
) intoOPDSTK
andCDDISC
. - Updates vendor totals for
APVEND
:- Adds
OPGRAM
toL2GRAM
(gross amount). - Adds
OPDISC
toL2DISC
(discount). - Adds
OPPPTD
toL2PPTD
(partial paid to date). - Adds
OPLPAM
toL2AMT
(payment amount).
- Adds
- Calculates the A/P reduction (
OPPAY = OPDISC + OPLPAM
) and open amount (OPOPEN = OPGRAM - OPPPTD - OPPAY
). - If
OPOPEN = 0
, marks the record as fully paid (indicator20
). - Updates
OPPPTD
by addingOPLPAM
. - Processes
APOPEN
records:- Sets the lower limit (
SETLL
) onAPOPEN
usingOPKEY
. - Reads
APOPEN
records, comparingOPKY1
withCOVNVO
to ensure matching vouchers. - Chains to
APOPENH
,APOPEND
, orAPOPENV
based on record type (indicators04
,05
,06
).
- Sets the lower limit (
- Updates freight-related files (
FRCFBH
,FRCINH
):- Constructs a key (
FRCKEY
,FRCK39
) usingCONO
,OPCAID
,OPINVN
, andOPSORN
. - Chains to
FRCFBH
(freight bill header) first; if found andFRAPST = 'Y'
, writes an exception record (APFBST
). - If not found, chains to
FRCINH
(invoice header) and writes an exception record (APINST
).
- Constructs a key (
-
Updates the discount missed table (
APPYDS
):- Chains to
APPYDS
usingOPKY1
. - Writes an exception record to
APPYDS
(indicator70
).
- Chains to
-
Vendor Totals Update (L2TOT Subroutine):
- Chains to
APVEND
using a key (VNKEY
) constructed fromCONO
andVEND
. -
If found (
92
off):- Updates
VNLPAY
withL2AMT
(last payment amount). - Updates
VNLPDT
andVNLPD8
withAXCKDT
(last payment date). - Adds
L2DISC
toVNDMTD
andVNDYTD
(month-to-date and year-to-date discounts). - Adds
L2AMT
andL2DISC
toVNPAY
(month-to-date payments). - Subtracts
L2AMT
andL2DISC
fromVNCBAL
(current balance). - Adds
L2PAID
toVNTYDP
(year-to-date paid).
- Updates
-
Final Totals and Updates (L4TOT Subroutine):
- Checks if
L4CHEK
is non-zero and compares it withACCKNO
(next check number). - If equal, increments
ACCKNO
andACCDJR
(next cash disbursements journal number). -
Updates
APCONT
with the newACCKNO
andACCDJR
. -
Output Generation:
- Writes to
APCHKR
(check reconciliation) for non-prepaid, non-voided records (01
,N90
,N50
,N12
,N19
):- Updates or adds records with fields like
AMCODE
,AMCKAM
,AMCLDT
,CLDT8
,AMOCAM
.
- Updates or adds records with fields like
- Writes to
APOPENH
,APOPEND
,APOPENV
(header, detail, one-time vendor) for fully paid records (70
,04
/05
/06
,20
):- Marks records as deleted (
'D'
) and updates fields likeOPPPTD
,OPCKNO
,AXYMD
,CDYMD
,OPLPAM
,OPDSTK
.
- Marks records as deleted (
- Writes to
APHISTH
,APHISTD
,APHISTV
(history files) for fully paid records:- Adds records with payment details, including
OPDISC
,OPLPAM
,AXYMD
,CKDT8
,OPCAID
,OPINVN
.
- Adds records with payment details, including
- Writes to
APPYDS
(discount missed table) for header records (70
,04
,N97
):- Includes fields like
DSDEL
,DSREC1
,DSREC2
,OPCKNO
,OPPAID
,OPLPAM
,OPDISC
,DSINVN
,VNNAME
.
- Includes fields like
- Writes to
FRCINH
andFRCFBH
(freight-related files) for applicable vouchers:- Updates with payment status (
'P'
), vendor, check number, and amount.
- Updates with payment status (
- Writes to
APCDJR
(cash disbursements journal) for payment records (02
,N19
):- Outputs cash (
'C'
), discount ('D'
), and A/P ('AP'
) entries with fields likeCONO
,JRNID
,BKGL
,AXCHEK
,OPLPAM
,CDDISC
,OPPAY
.
- Outputs cash (
- Writes to
APPNCF
(PNC positive pay file) for non-prepaid, non-voided records (01
,N19
,N12
,N28
):- Outputs bank account, check number, date, amount, vendor name, and status code.
- Writes to
APPRINT
(printer file) for the check register report:- Outputs headers with company name, bank G/L, wire transfer indicator, date, time, and journal ID.
- Outputs detail lines with check number, vendor number, name, date, and amount.
- Outputs totals for computer checks, prepaid checks, ACH payments, wire transfers, employee expenses, and overall totals.
Business Rules¶
The program enforces several business rules, primarily related to payment processing, file updates, and reporting:
- Check Record Processing:
- Skips processing for credit/no-pay records (
AXRECD = 'C'
). - Handles voided checks differently based on
AXRECD
('F'
for same check number,'V'
for next check number). -
Supports multiple payment types: prepaid checks (
'P'
), ACH ('A'
), wire transfers ('W'
), and employee expenses ('E'
). -
Date Handling:
- Adjusts check dates for century (
Y2KCEN
,Y2KCMP
) to handle Y2K compliance (e.g.,PTCKYY >= Y2KCMP
usesY2KCEN
, otherwise adds 1 to century). -
Formats dates for PNC positive pay (
PNCDT8
) in MMDDYYYY format. -
Journal and Check Number Management:
- Assigns journal ID (
JRNID
) as'CD'
(check),'WD'
(wire transfer),'AD'
(ACH), or'ED'
(employee expenses). -
Increments
ACCKNO
(next check number) andACCDJR
(next journal number) only if a valid check number is processed. -
Vendor and Payment Updates:
- Accumulates gross amount, discount, and payment amounts for each vendor (
L2GRAM
,L2DISC
,L2AMT
,L2PAID
). - Updates vendor balances (
VNCBAL
), payments (VNPAY
,VNTYDP
), and discounts (VNDMTD
,VNDYTD
) inAPVEND
. -
Marks fully paid vouchers as deleted (
'D'
) inAPOPENH
,APOPEND
,APOPENV
. -
Freight Invoice Processing:
- Checks
FRCFBH
(freight bill header) beforeFRCINH
(invoice header) for vouchers with a carrier ID (OPCAID
). -
Updates payment status (
FRAPST = 'P'
) in the appropriate freight file. -
Discount Missed Tracking:
-
Writes to
APPYDS
for header records to track missed discounts, including invoice and vendor details. -
Check Reconciliation:
- Updates
APCHKR
only for non-wire transfer, non-ACH, non-employee expense records (N50
). -
Sets
AMCODE
to'O'
(open) or'V'
(voided) and updates amounts and dates accordingly. -
Reporting:
- Generates a detailed check register (
APPRINT
) with headers, detail lines, and totals by payment type. - Produces a PNC positive pay file (
APPNCF
) for bank reconciliation, including void status.
Tables/Files Used¶
The program interacts with multiple files for input, update, and output. The files are listed below with their logical names, labels, usage, and disposition:
Logical Name | Label | Usage | Disposition | Record Length |
---|---|---|---|---|
APPYCK | ?9?APPC?WS? | Input: Check data (check number, amount, date, vendor). | Input (IP) | 96 |
APPAY | ?9?APPY?WS? | Input/Update: Payment data (voucher, gross amount, discount, check number). | Input/Update (IS) | 384 |
AP250S | ?9?APPS?WS? | Input: Supporting data (used for array SEP ). |
Input (IR) | 3 |
APPYTR | ?9?APPT?WS? | Input: Transaction data (check date, year/period). | Input (IC) | 128 |
APCONT | ?9?APCONT | Update: A/P control (company name, next check/journal numbers). | Update (UC) | 256 |
APVEND | ?9?APVEND | Update: Vendor master (name, balance, payments, discounts). | Update (UC) | 579 |
APVEND2 | ?9?APVEND | Input: Vendor master (address, name overflow). | Input (IC) | 579 |
APCHKR | ?9?APCHKR | Update: Check reconciliation (check amount, clear date, status). | Update (UC) | 128 |
APOPEN | ?9?APOPEN | Input: Open A/P file (voucher data). | Input (ID) | 384 |
APOPENH | ?9?APOPNH | Update: Open A/P header (voucher header data). | Update (UC) | 384 |
APOPEND | ?9?APOPND | Update: Open A/P detail (voucher detail data). | Update (UC) | 384 |
APOPENV | ?9?APOPNV | Update: Open A/P one-time vendor data. | Update (UC) | 384 |
FRCINH | ?9?FRCINH | Update: Freight invoice header (carrier, payment status). | Update (UF) | 206 |
FRCFBH | ?9?FRCFBH | Update: Freight bill header (similar to FRCINH). | Update (UF) | 206 |
APPYDS | ?9?APDS?WS? | Input: Discount missed table (voucher, discount data). | Input (IF) | 384 |
APHISTH | ?9?APHSTH | Output: A/P history header (payment history). | Output (O) | 384 |
APHISTD | ?9?APHSTD | Output: A/P history detail (payment details). | Output (O) | 384 |
APHISTV | ?9?APHSTV | Output: A/P history one-time vendor (payment history). | Output (O) | 384 |
APCDJR | ?9?APCD?WS? | Output: Cash disbursements journal (cash, discount, A/P entries). | Output (O) | 128 |
APPRINT | ?9?APPRINT | Output: Check register report (printer file). | Output (O) | 132 |
APPNCF | ?9?APPNCF | Output: PNC positive pay file (bank reconciliation). | Output (O) | 155 |
APDSMS | ?9?APDSMS | Output: Discount missed table (missed discount records). | Output (O) | 384 |
External Programs Called¶
The AP250.RPG36
program does not explicitly call any external programs. All processing is handled within the program through its subroutines (L4DET
, EACH01
, EACH02
, L2TOT
, L4TOT
). The program is self-contained and relies on file operations and internal logic to complete its tasks.
Notes¶
- File Dispositions:
IP
(Primary Input):APPYCK
for check records.IS
(Secondary Input/Update):APPAY
for payment processing.IR
/IC
(Input): Temporary or control files (AP250S
,APPYTR
,APVEND2
).UC
/UF
(Update): Master files (APCONT
,APVEND
,APCHKR
,APOPEN*
,FRC*
).ID
(Input for Deletion):APOPEN
for reading vouchers.O
(Output): History, journal, and report files (APHIST*
,APCDJR
,APPRINT
,APPNCF
,APDSMS
).- Modifications:
JB01
(2012): Added support for ACH (A
), wire transfers (W
), and employee expenses (E
) inPTHOLD
andAXRECD
.JB02
(2018): AddedFRCFBH
processing beforeFRCINH
and increasedAPPAY
record length to 384 to matchAPOPEN
.MG03
(2022): AddedAPPYDS
andAPDSMS
for tracking missed discounts.- Y2K Compliance: The program handles century adjustments for dates to ensure correct processing of check and payment dates.
- Output Formats:
- The check register (
APPRINT
) includes detailed headers and totals by payment type. - The PNC positive pay file (
APPNCF
) is formatted for bank reconciliation, including void status.
This summary provides a comprehensive overview of the AP250.RPG36
program's functionality, business logic, file interactions, and lack of external program calls. Let me know if you need further clarification or additional analysis!