AP910 RPGLE
The RPGLE program AP910.rpgle.txt is part of an IBM AS/400 or IBM i accounts payable system, designed for vendor master maintenance and inquiry. It is called from the OCL program AP910P99.ocl36.txt via AP910P and is used to create, update, or display vendor records, with specific support for 1099 form processing. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPGLE Program¶
The AP910 program is a display file-driven application that manages vendor master records through a single-panel interface (fmt01). It supports maintenance (MNT) and inquiry (INQ) modes, allowing users to add, update, or view vendor details. The program includes validations for 1099-related fields and integrates with an SQL vendor table for synchronization. Here’s a step-by-step breakdown of the process:
- Initialization (
*inzsrSubroutine): - Receives Parameters: The program accepts five parameters via the
*entryPLIST:p$co(company code).p$vend(vendor number).p$mode(3A): Run mode, eitherMNT(maintenance) orINQ(inquiry).p$file(10A): Vendor file name for 1099 processing (e.g.,APVN2025).p$fgrp(1A): File group, eitherGorZ, for file overrides.p$flag(1A): Return flag to indicate success (1) or failure.
- Sets Up Fields: Initializes display file fields (
f$co,f$vend), key lists (klvend,klglms,klcaid, etc.), and message handling fields. Defines data structures for date conversion (d#cymd), time conversion (time12), and vendor record storage (wkds01,svds). -
Purpose: Prepares the program environment for processing vendor data.
-
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(GorZ), applies overrides toAPCONT,GLMAST,GSTABL,BBCAID, andAPVENDusingQCMDEXCto executeOVRDBFcommands:- For
p$fgrp = 'G': Overrides toGAPCONT,GGLMAST,GGSTABL,GBBCAID,GAPVEND. - For
p$fgrp = 'Z': Overrides toZAPCONT,ZGLMAST,ZGSTABL,ZBBCAID,ZAPVEND. - If
p$fileis provided (e.g.,APVN2025), uses it forAPVEND.
- For
- Opens Files: Opens
APCONT,GLMAST,GSTABL,BBCAID, andAPVENDwithUSROPNfor dynamic access. -
Purpose: Ensures access to the correct files, especially year-specific vendor files for 1099 processing.
-
Retrieve Data (
rtvdtaSubroutine): - Fetch Company Data: Chains to
APCONTusingf$coto retrieve the company name (acname) intof$conm. If not found, clearsf$conm. - Fetch Vendor Data: Chains to
APVENDusingklvend(f$co,f$vend). If the vendor exists (*in99 = *off), loads the record; otherwise, clearsapvendpf. - Set Mode and Header: Sets protection indicator
*in70(*offforMNT,*onforINQ) and header (c$hdr1) to “Vendor Master Maintenance” or “Vendor Master Inquiry” based onp$mode. -
Purpose: Loads existing vendor data or prepares for a new record.
-
Process Panel Formats (
srfmtSubroutine): - Clear Screen: Writes
clrscrto reset the display. - Initialize Panel: Calls
f01movto set up fields forfmt01and setsw$fmt = 'FMT01'. - Main Loop (
fmtagn):- Displays the message subfile if needed (
wrtmsg). - Displays
fmt01usingEXFMT. - Clears error indicators (
*in50–*in69,*in76–*in79) and message subfile (clrmsg). - Processes user input based on the current format (
f01srforfmt01).
- Displays the message subfile if needed (
-
Purpose: Manages the interactive display of the vendor maintenance/inquiry panel.
-
Process Format (
f01srSubroutine): - Handle Function Keys:
- F04: Calls
promptto handle field-level prompting (e.g., lookup for GL account, terms, or 1099 code). - F05: Calls
AP915Pfor vendor contact maintenance/inquiry (commented out in this version). - F10: Repositions the cursor to the top of the screen.
- F12: Exits the program (
fmtagn = *off).
- F04: Calls
- Inquiry Mode: If
p$mode = 'INQ', callsf01nxtto determine the next format (though onlyfmt01is active). - Enter Key: Validates input (
f01edt), updates the database if inMNTmode (upddbf), and processes the next format (f01nxt). -
Purpose: Handles user interactions with the
fmt01panel. -
Determine Next Format (
f01nxtSubroutine): - If no input changes are detected (
*in19 = *off), exits the main loop (fmtagn = *off). -
Purpose: Controls whether to continue or exit the panel loop (only
fmt01is used in this version). -
Edit Format Input (
f01edtSubroutine): - Validates fields in
fmt01:- Name (
vnname): Must not be blank (ERR0012,*in51). - Name Overflow (
vnnovf): Must beYorN(ERR0014,*in52). - ACH Fields (commented out): If bank account (
vnabk#) is non-blank, validates: vnacos: Must beCorS(com(05),*in77).vnacls: Must beCCD(com(06),*in78).vnarte: Must be non-zero (com(07),*in79).- ACH Hold Validation: If
vnhold = 'A'andvnabk#is blank, errors (com(08),*in76–*in79). - Sort Field (
vnsort): Must not be blank (ERR0012,*in53). - Hold (
vnhold): Must beH,A,W,E,U, or blank (com(01),*in54). - Single Payee (
vnsngl): Must beSor blank (com(02),*in55). - Expense GL (
vnexgl): Must exist inGLMAST, not deleted or inactive (ERR0010,*in56), and not a special account (ERR0015). - Carrier (
vncaid): Must exist inBBCAIDand not be deleted (ERR0010,*in57). - Inactive Code (
vndel): Setsf$inacto “INACTIVE” ifvndel = 'I'. - Terms (
vnterm): Must exist inGSTABLand not be deleted (ERR0010,*in58). - Gal/Rcpts Required (
vngrrq): Commented out validation forGSTABLlookup (ERR0010,*in71). - Category (
vncatg): Must exist inGSTABL(no deleted check,*in62commented out). - 1099 Code (
vn1099): - Must not be blank (
ERR0010,*in59). - Must exist in
GSTABLand not be deleted (ERR0010,*in59). - If
MorN, requires:- IRS Name Control (
vnnmct) non-blank (com(04),*in61). - IRS EIN (
vnidno) non-blank (com(10),*in64). - IRS Box 1 (
vnbox1) non-zero (com(11),*in65).
- IRS Name Control (
- Zip Code (
vnzip5): Required ifvnctry = 'US'andvn1099 ≠ 'X'andvnhold ≠ 'E'(com(09),*in63). - Payees (
vnpyn2): If non-blank,vnpyn1must also be non-blank (com(03),*in60).
- Name (
- Inquiry Mode: Clears errors and messages if
p$mode = 'INQ'. -
Purpose: Ensures valid input before updating the database.
-
Initialize Format Fields (
f01movSubroutine): - Calls
f01edtto validate and populate display fields. - Clears errors if validation fails.
- Calls
f01pro(empty in this version) for format protection. -
Purpose: Prepares the
fmt01panel with validated data. -
Update Database (
upddbfSubroutine): - Saves current vendor record (
wkds01) tosvds. - Checks if the vendor exists in
APVEND(klvendchain):- If exists (
*in80 = *off) and fields changed, restoressvdstowkds01, updatesapvendpf, setsp$flag = '1', and callsupdSQLvn(commented out). - If not exists, clears
apvendpf, populates withsvds, setsvncoandvnvend, writes a new record, setsp$flag = '1', and callsupdSQLvn.
- If exists (
-
Purpose: Updates or creates vendor records in
APVEND. -
Update SQL Vendor Master (
updSQLvnSubroutine):- Commented out code to call a PC program (
UpdateVendor.EXE) viaSTRPCOCLPandQCMDEXCto synchronize the AS/400 vendor table with an SQL version. - Purpose: Intended to keep an external SQL vendor table in sync (disabled per
MG01).
- Commented out code to call a PC program (
-
Field Prompting (
promptSubroutine):- Determines cursor position for window return.
- For
fmt01, handles field lookups: - VNEXGL: Calls
LGLMASTto select a GL account, updatesvnexglif valid. - VNCAID: Calls
LBBCAIDto select a carrier, updatesvncaid. - VNTERM: Calls
LGSTABLto select terms, updatesvnterm. - VNGRRQ: Calls
LGSTABLfor gal/rcpts required (commented out). - VNCATG: Calls
LGSTABLto select a category, updatesvncatg. - VN1099: Calls
LGSTABLto select a 1099 code, updatesvn1099. - Sets
*in19to indicate a format change. - Purpose: Provides interactive lookup for key fields.
-
Message Handling (
addmsg,wrtmsg,clrmsgSubroutines):- Add Message (
addmsg): Sends error or confirmation messages to the program message queue (QMHSNDPM). - Write Message (
wrtmsg): Displays the message subfile (msgctl). - Clear Message (
clrmsg): Clears the message subfile (QMHRMVPM). - Purpose: Manages user feedback for errors and confirmations.
- Add Message (
-
Program Termination:
- Closes all files (
close *all), sets*inlr = *on, and returns. - Purpose: Ensures clean program exit.
- Closes all files (
Business Rules¶
- Mode-Based Access:
- In
MNTmode, users can create or update vendor records, with input fields enabled (*in70 = *off). -
In
INQmode, users can only view vendor details, with input fields protected (*in70 = *on). -
File Overrides for 1099 Processing:
- Overrides
APVENDto year-specific files (e.g.,APVN2025) based onp$fileandp$fgrp(GorZ) to support 1099 processing, as noted in revisionJB01. -
Similarly overrides
APCONT,GLMAST,GSTABL, andBBCAID. -
Validation Rules:
- Mandatory Fields:
- Vendor name (
vnname) and sort field (vnsort) must not be blank (ERR0012). - If second payee (
vnpyn2) is non-blank, first payee (vnpyn1) must be non-blank (com(03)).
- Vendor name (
- Valid Values:
- Name overflow (
vnnovf):YorN(ERR0014). - Hold (
vnhold):H(check),A(ACH),W(wire),E,U(utility auto-pay, perMG03), or blank (com(01)). - Single payee (
vnsngl):Sor blank (com(02)). - ACH fields (commented out): If
vnabk#non-blank,vnacos(C/S),vnacls(CCD), andvnarte(non-zero) are required. Ifvnhold = 'A'andvnabk#blank, errors (com(08)).
- Name overflow (
- Reference File Checks:
- Expense GL (
vnexgl): Must exist inGLMAST, not deleted or inactive (ERR0010), and not special (ERR0015). - Carrier (
vncaid): Must exist inBBCAIDand not deleted (ERR0010). - Terms (
vnterm): Must exist inGSTABLand not deleted (ERR0010). - Category (
vncatg): Must exist inGSTABL(no deleted check). - 1099 Code (
vn1099): Must exist inGSTABL, not deleted, and not blank (ERR0010).
- Expense GL (
-
1099-Specific Validations (per
MG02,JK01):- If
vn1099 = 'M'(MISC) or'N'(NEC): - IRS Name Control (
vnnmct) must be non-blank (com(04)). - IRS EIN (
vnidno) must be non-blank (com(10)). - IRS Box 1 (
vnbox1) must be non-zero (com(11)). - If
vnctry = 'US'andvn1099 ≠ 'X'andvnhold ≠ 'E', zip code (vnzip5) must be non-zero (com(09)).
- If
-
Database Updates:
- In
MNTmode, updates or creates records inAPVENDand setsp$flag = '1'on success. -
Synchronization with an SQL vendor table is commented out (
MG01). -
User Interface:
- Supports function keys: F04 (field prompting), F05 (vendor contacts, commented out), F10 (cursor home), F12 (exit), and Enter (process input).
- Displays a single panel (
fmt01) with vendor details and validation messages.
Tables (Files) Used¶
- AP910D:
- Display file (CF,
workstn) for the vendor maintenance/inquiry interface (fmt01,clrscr,msgctl). -
Used for user input/output.
-
APCONT:
- Input-only file (IF,
usropn) for company data. - Overridden to
GAPCONTorZAPCONTbased onp$fgrp. -
Used to validate company code (
f$co) and retrieve company name (acname). -
GLMAST:
- Input-only file (IF,
usropn) for general ledger accounts. - Overridden to
GGLMASTorZGLMAST. -
Used to validate expense GL account (
vnexgl). -
GSTABL:
- Input-only file (IF,
usropn) for reference data (terms, category, 1099 codes). - Overridden to
GGSTABLorZGSTABL. -
Used to validate
vnterm,vncatg,vn1099, and commented-outvngrrq. -
BBCAID:
- Input-only file (IF,
usropn) for carrier data (replacesGSTABLfor carrier lookup perJK03). - Overridden to
GBBCAIDorZBBCAID. -
Used to validate carrier (
vncaid). -
APVEND:
- Update file (UF,
usropn) for vendor master data. - Overridden to
GAPVEND,ZAPVEND, or a year-specific file (e.g.,APVN2025) based onp$fileandp$fgrp. - Used for reading, updating, or creating vendor records.
External Programs Called¶
- LGLMAST:
- Called in
promptfor GL account lookup (VNEXGL). -
Parameters:
o$co(company),o$acct(account),o$sub(sub-account),o$spec(special accounts flag),o$fgrp(file group). -
LBBCAID:
- Called in
promptfor carrier lookup (VNCAID, perJK03). -
Parameters:
o$co(company),o$caid(carrier ID),o$fgrp(file group). -
LGSTABL:
- Called in
promptfor lookup of terms (VNTERM), category (VNCATG), and 1099 code (VN1099). -
Parameters:
k$apterm/k$apcatg/k$ap1099(table type),k$term/k$catg/k$1099(code),o$fgrp(file group). -
QCMDEXC:
-
System program to execute file override commands (
OVRDBF) forAPCONT,GLMAST,GSTABL,BBCAID, andAPVEND. -
QMHSNDPM:
-
System program to send messages to the program message queue.
-
QMHRMVPM:
-
System program to clear messages from the message subfile.
-
AP915P (commented out)**:
- Intended for vendor contact maintenance/inquiry (per
JK02). -
Parameters:
o$co#(company),o$vend(vendor),o$mode(MNT/INQ),o$fgrp(file group). -
STRPCOCLP and UpdateVendor.EXE (commented out)**:
- Intended to synchronize the AS/400 vendor table with an SQL table (per
JB05, disabled perMG01).
Summary¶
The AP910 RPGLE program is a critical component of the accounts payable system, providing an interactive interface for maintaining or viewing vendor master records. It supports creating and updating vendor data in MNT mode and viewing in INQ mode, with robust validations for 1099-related fields (e.g., IRS Name Control, EIN, Box 1, zip code). The program integrates with the OCL program AP910P99 and AP910P to manage vendor data for 1099 processing, using year-specific files like APVNYYYY. It includes field lookups and error handling to ensure data integrity.
Tables/Files: AP910D (display), APCONT, GLMAST, GSTABL, BBCAID, APVEND (overridden to GAPCONT, GGLMAST, GGSTABL, GBBCAID, GAPVEND, or APVNYYYY).
External Programs: LGLMAST, LBBCAID, LGSTABL, QCMDEXC, QMHSNDPM, QMHRMVPM, AP915P (commented out), STRPCOCLP/UpdateVendor.EXE (commented out).
If you need further details on related programs (AP9104, LGLMAST, etc.) or file structures, let me know, and I can provide additional analysis or search for relevant information!