AP105P RPG
Let’s analyze the provided RPG program AP105P.rpg to extract the process steps, business rules, tables used, and external programs called. This program is called by the CLP program AP105PCL.clp and is part of the A/P SOGAS ACH payment processing system on IBM i.
Process Steps¶
The RPG program AP105P.rpg performs the following steps:
- File Declarations:
- Defines the following files:
AP105PSC: Workstation file (screen display file).APSOGAS: Input primary file (127 bytes, disk).APSGACH: Input file with keyed access (64 bytes, 7-byte key, disk).APVEND: Input file with keyed access (579 bytes, 7-byte key, disk).LIST132: Output printer file (132 bytes).
-
Defines the User Data Structure (UDS) for Local Data Area (LDA) fields:
CANCEL(positions 100–105)ERRORS(position 106)DESC(positions 107–119)CANTAX(position 120, Canadian tax upload flag)UPTYPE(position 121, positive/negative dollar values flag)
-
Parameter Input:
-
Accepts a single 1-character parameter
@FGRPvia*ENTRY PLIST. -
Initialization (Indicator 09 Off):
-
If indicator
09is off (likely controlled by file status or program logic):- Initializes counters:
COUNT(5-digit numeric) to 0.ERRCNT(5-digit numeric, error count) to 0.DUP(5-digit numeric, duplicate count) to 0.DATES(5-digit numeric) to 0.ERRORS(LDA position 106) to blanks.- Captures system time and date:
- Stores current time/date in
TIMDAT(12 digits). - Extracts time to
SYTIME(6 digits). - Extracts date to
SYDATE(6 digits). - Converts
SYDATEtoSYDYMD(YYYYMMDD format) by multiplying by 10000.01. - Extracts
MONTH(2 digits) andYEAR(2 digits) fromSYDATE. - Sets indicators:
- Sets indicator
09and51on. - If
CANTAX= 'Y', sets indicator54on. - If
UPTYPE= 'T', sets indicator55on. - If both
54and55are off, sets indicator56on and setsERRORSto 'Y', then turns off indicators50and51.
-
Increment Counter:
-
Increments
COUNTby 1 for each record processed. -
Validation of
APSOGASRecord: - Uses
ANOWNR(owner number, positions 1–7) fromAPSOGASto chain (lookup) inAPSGACH. - If the chain fails (indicator
99on, record not found):- Increments
ERRCNT. - Sets indicator
50on,51off. - Jumps to
SKIPtag (bypassing further processing for this record).
- Increments
-
If the chain succeeds (indicator
99off):- Builds a 7-character key
VNKEYby combining a hardcoded '10' withAGVEND(vendor number) fromAPSGACH. - Chains to
APVENDusingVNKEY. - If the chain to
APVENDfails (indicator53on, vendor not found): - Sets indicator
50on,51off. - Sets
ERRORSto 'Y'. - Increments
ERRCNT. - Writes an exception output (
EXCPT) toLIST132. - Jumps to
SKIPtag.
- Builds a 7-character key
-
Clear and Display Screen:
- If indicator
50is off, clears indicator56. -
Executes
EXFMT(write/read) forSCREEN1in theAP105PSCdisplay file. -
Output to Printer:
- Writes to
LIST132(printer file) with fields:ANOWNR(positions 1–10)ERRCNT(positions 11–17)ANNAME(positions 18–55)
Business Rules¶
The program enforces the following business rules:
- Owner Validation:
-
Each
APSOGASrecord’sANOWNRmust exist inAPSGACH. If not, an error is logged (ERRCNTincremented,ERRORSset to 'Y'), and processing skips to the next record. -
Vendor Validation:
-
The vendor number (
AGVEND) fromAPSGACHmust exist inAPVEND. If not, an error is logged (ERRCNTincremented,ERRORSset to 'Y'), and an exception report is generated. -
Error Handling:
-
Errors are tracked via
ERRCNTand theERRORSflag in the LDA (position 106). If errors occur, the program may signal to the calling CLP (AP105PCL) to skip further processing (e.g., S/36 procedureAP105). -
Canadian Tax and Upload Type Checks:
- If
CANTAX= 'Y', sets indicator54to flag Canadian tax-related processing. - If
UPTYPE= 'T', sets indicator55to flag specific dollar value handling (positive/negative). -
If neither condition is met (
54and55off), setsERRORSto 'Y' and indicator56on, indicating a validation failure. -
Dynamic File Processing:
-
The program processes records from
APSOGASand validates againstAPSGACHandAPVEND, ensuring data integrity for A/P SOGAS ACH payments. -
Reporting:
- Outputs errors or processing results to a printer file (
LIST132) for reporting, including owner number, error count, and name.
Tables Used¶
The program uses the following files (tables):
- APSOGAS (Input Primary, 127 bytes):
- Fields:
ANOWNR(positions 1–7): Owner number.ANNAME(positions 8–42): Name.ANCHNM(positions 43–49): Check name.ANDATE(positions 50–59): Date.ANCHAM(positions 60–65, packed): Check amount.ANSTDT(positions 66–75): Start date.ANENTE(positions 76–85): Entry date.ANDUDT(positions 86–95): Due date.
-
Used as the primary input file for payment data.
-
APSGACH (Input, Keyed, 64 bytes, 7-byte key):
- Fields:
AGOWNR(positions 1–7): Owner number.AGVEND(positions 8–12): Vendor number.
-
Used to validate
ANOWNRfromAPSOGAS. -
APVEND (Input, Keyed, 579 bytes, 7-byte key):
- Fields:
VNDEL(position 1): Record code.VNCO(positions 2–3): Company number.VNVEND(positions 4–8): Vendor number.VNVNAM(positions 9–38): Vendor name.VNAD1toVNAD4(positions 39–158): Address lines.VNHOLD(position 240): Hold invoices flag.VNSNGL(position 241): Single check flag.VNEXGL(positions 254–261): Expense GL and sub-account.VNTERM(positions 262–263): AP terms code.VNCAID(positions 294–299): Carrier ID.VNPRID(positions 384–387, packed): ADP payroll ID.VNACLS(positions 388–390): ACH class.VNACOS(position 391): ACH checking or savings.VNARTE(positions 392–400): ACH bank routing code.VNABK#(positions 401–417): ACH bank account number.
-
Used to validate vendors associated with
AGVENDfromAPSGACH. -
LIST132 (Output, Printer, 132 bytes):
-
Used to generate a report with
ANOWNR,ERRCNT, andANNAME. -
AP105PSC (Workstation, Display File):
- Contains
SCREEN1for interactive display (written and read viaEXFMT).
External Programs Called¶
- None: The program does not explicitly call any external programs via
CALLor other mechanisms. It interacts with the display fileAP105PSCand printer fileLIST132but does not invoke other RPG or CL programs.
Summary¶
- Process Steps: Declare files, initialize counters and LDA, process
APSOGASrecords, validate againstAPSGACHandAPVEND, handle errors, display screen, and output to printer. - Business Rules: Validates owner and vendor numbers, tracks errors in LDA, handles Canadian tax and upload type flags, and generates error reports.
- Tables Used:
APSOGAS(payment data),APSGACH(owner validation),APVEND(vendor details),LIST132(printer output),AP105PSC(display file). - External Programs Called: None.
This RPG program validates A/P SOGAS ACH payment records, ensuring owners and vendors exist in the respective files, and reports errors via a printer file and interactive screen.