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 (
*inzsr
Subroutine): - Receives Parameters: The program accepts five parameters via the
*entry
PLIST: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, eitherG
orZ
, 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 (
opntbl
Subroutine): - File Overrides: Based on
p$fgrp
(G
orZ
), applies overrides toAPCONT
,GLMAST
,GSTABL
,BBCAID
, andAPVEND
usingQCMDEXC
to executeOVRDBF
commands:- For
p$fgrp = 'G'
: Overrides toGAPCONT
,GGLMAST
,GGSTABL
,GBBCAID
,GAPVEND
. - For
p$fgrp = 'Z'
: Overrides toZAPCONT
,ZGLMAST
,ZGSTABL
,ZBBCAID
,ZAPVEND
. - If
p$file
is provided (e.g.,APVN2025
), uses it forAPVEND
.
- For
- Opens Files: Opens
APCONT
,GLMAST
,GSTABL
,BBCAID
, andAPVEND
withUSROPN
for dynamic access. -
Purpose: Ensures access to the correct files, especially year-specific vendor files for 1099 processing.
-
Retrieve Data (
rtvdta
Subroutine): - Fetch Company Data: Chains to
APCONT
usingf$co
to retrieve the company name (acname
) intof$conm
. If not found, clearsf$conm
. - Fetch Vendor Data: Chains to
APVEND
usingklvend
(f$co
,f$vend
). If the vendor exists (*in99 = *off
), loads the record; otherwise, clearsapvendpf
. - Set Mode and Header: Sets protection indicator
*in70
(*off
forMNT
,*on
forINQ
) 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 (
srfmt
Subroutine): - Clear Screen: Writes
clrscr
to reset the display. - Initialize Panel: Calls
f01mov
to set up fields forfmt01
and setsw$fmt = 'FMT01'
. - Main Loop (
fmtagn
):- Displays the message subfile if needed (
wrtmsg
). - Displays
fmt01
usingEXFMT
. - Clears error indicators (
*in50
–*in69
,*in76
–*in79
) and message subfile (clrmsg
). - Processes user input based on the current format (
f01sr
forfmt01
).
- Displays the message subfile if needed (
-
Purpose: Manages the interactive display of the vendor maintenance/inquiry panel.
-
Process Format (
f01sr
Subroutine): - Handle Function Keys:
- F04: Calls
prompt
to handle field-level prompting (e.g., lookup for GL account, terms, or 1099 code). - F05: Calls
AP915P
for 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'
, callsf01nxt
to determine the next format (though onlyfmt01
is active). - Enter Key: Validates input (
f01edt
), updates the database if inMNT
mode (upddbf
), and processes the next format (f01nxt
). -
Purpose: Handles user interactions with the
fmt01
panel. -
Determine Next Format (
f01nxt
Subroutine): - 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
fmt01
is used in this version). -
Edit Format Input (
f01edt
Subroutine): - Validates fields in
fmt01
:- Name (
vnname
): Must not be blank (ERR0012
,*in51
). - Name Overflow (
vnnovf
): Must beY
orN
(ERR0014
,*in52
). - ACH Fields (commented out): If bank account (
vnabk#
) is non-blank, validates: vnacos
: Must beC
orS
(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 beS
or 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 inBBCAID
and not be deleted (ERR0010
,*in57
). - Inactive Code (
vndel
): Setsf$inac
to “INACTIVE” ifvndel = 'I'
. - Terms (
vnterm
): Must exist inGSTABL
and not be deleted (ERR0010
,*in58
). - Gal/Rcpts Required (
vngrrq
): Commented out validation forGSTABL
lookup (ERR0010
,*in71
). - Category (
vncatg
): Must exist inGSTABL
(no deleted check,*in62
commented out). - 1099 Code (
vn1099
): - Must not be blank (
ERR0010
,*in59
). - Must exist in
GSTABL
and not be deleted (ERR0010
,*in59
). - If
M
orN
, 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,vnpyn1
must 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 (
f01mov
Subroutine): - Calls
f01edt
to validate and populate display fields. - Clears errors if validation fails.
- Calls
f01pro
(empty in this version) for format protection. -
Purpose: Prepares the
fmt01
panel with validated data. -
Update Database (
upddbf
Subroutine): - Saves current vendor record (
wkds01
) tosvds
. - Checks if the vendor exists in
APVEND
(klvend
chain):- If exists (
*in80 = *off
) and fields changed, restoressvds
towkds01
, updatesapvendpf
, setsp$flag = '1'
, and callsupdSQLvn
(commented out). - If not exists, clears
apvendpf
, populates withsvds
, setsvnco
andvnvend
, writes a new record, setsp$flag = '1'
, and callsupdSQLvn
.
- If exists (
-
Purpose: Updates or creates vendor records in
APVEND
. -
Update SQL Vendor Master (
updSQLvn
Subroutine):- Commented out code to call a PC program (
UpdateVendor.EXE
) viaSTRPCOCLP
andQCMDEXC
to 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 (
prompt
Subroutine):- Determines cursor position for window return.
- For
fmt01
, handles field lookups: - VNEXGL: Calls
LGLMAST
to select a GL account, updatesvnexgl
if valid. - VNCAID: Calls
LBBCAID
to select a carrier, updatesvncaid
. - VNTERM: Calls
LGSTABL
to select terms, updatesvnterm
. - VNGRRQ: Calls
LGSTABL
for gal/rcpts required (commented out). - VNCATG: Calls
LGSTABL
to select a category, updatesvncatg
. - VN1099: Calls
LGSTABL
to select a 1099 code, updatesvn1099
. - Sets
*in19
to indicate a format change. - Purpose: Provides interactive lookup for key fields.
-
Message Handling (
addmsg
,wrtmsg
,clrmsg
Subroutines):- 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
MNT
mode, users can create or update vendor records, with input fields enabled (*in70 = *off
). -
In
INQ
mode, users can only view vendor details, with input fields protected (*in70 = *on
). -
File Overrides for 1099 Processing:
- Overrides
APVEND
to year-specific files (e.g.,APVN2025
) based onp$file
andp$fgrp
(G
orZ
) 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
):Y
orN
(ERR0014
). - Hold (
vnhold
):H
(check),A
(ACH),W
(wire),E
,U
(utility auto-pay, perMG03
), or blank (com(01)
). - Single payee (
vnsngl
):S
or 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 inBBCAID
and not deleted (ERR0010
). - Terms (
vnterm
): Must exist inGSTABL
and 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
MNT
mode, updates or creates records inAPVEND
and 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
GAPCONT
orZAPCONT
based 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
GGLMAST
orZGLMAST
. -
Used to validate expense GL account (
vnexgl
). -
GSTABL:
- Input-only file (IF,
usropn
) for reference data (terms, category, 1099 codes). - Overridden to
GGSTABL
orZGSTABL
. -
Used to validate
vnterm
,vncatg
,vn1099
, and commented-outvngrrq
. -
BBCAID:
- Input-only file (IF,
usropn
) for carrier data (replacesGSTABL
for carrier lookup perJK03
). - Overridden to
GBBCAID
orZBBCAID
. -
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$file
andp$fgrp
. - Used for reading, updating, or creating vendor records.
External Programs Called¶
- LGLMAST:
- Called in
prompt
for 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
prompt
for carrier lookup (VNCAID
, perJK03
). -
Parameters:
o$co
(company),o$caid
(carrier ID),o$fgrp
(file group). -
LGSTABL:
- Called in
prompt
for 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!