AP910P RPGLE
The RPGLE program AP910P.rpgle.txt is an IBM AS/400 or IBM i program designed for working with vendor records in an accounts payable (AP) system, specifically for maintaining vendor data related to 1099 forms. It is called from the OCL program AP910P99.ocl36.txt and provides an interactive interface for users to manage vendor records. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPGLE Program¶
The AP910P program is a display file-driven application that manages vendor records through a subfile interface. It supports maintenance (MNT) and inquiry (INQ) modes, allowing users to create, update, inactivate/reactivate, or display vendor records. Here’s a step-by-step breakdown of the process:
- Initialization (
*inzsrSubroutine): - Receives Parameters: The program accepts three parameters via the
*entryPLIST:p$mode(3A): Run mode, eitherMNT(maintenance) orINQ(inquiry).p$file(10A): Vendor file name (e.g.,APVN2025for 1099 processing).p$fgrp(1A): File group, eitherGorZ, to determine file overrides.
- Sets Up Fields: Initializes subfile control fields, message handling fields, and headers. Defines key lists (
klsfl1,kls1s1,kls1r1) for file access and sets default values for flags and counters. -
Purpose: Prepares the program environment, including repositioning fields, subfile control, and message queue setup.
-
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(GorZ), applies overrides to theAPCONT,APVEND, andAPVENDRDfiles usingQCMDEXCto executeOVRDBFcommands:- For
p$fgrp = 'G': Overrides toGAPCONTandGAPVEND. - For
p$fgrp = 'Z': Overrides toZAPCONTandZAPVEND. - If
p$fileis provided (e.g.,APVN2025), uses it forAPVENDandAPVENDRD.
- For
- Opens Files: Opens
APCONT,APVEND, andAPVENDRDwithUSROPNfor dynamic access. -
Purpose: Ensures the correct vendor files are accessed, especially for year-specific 1099 files like
APVNYYYY. -
Process Subfile (
srsfl1Subroutine): - Clear Message Subfile: Calls
clrmsgto clear any existing messages andwrtmsgto initialize the message subfile. - Initialize Subfile Control: Sets default values for subfile control fields (e.g.,
c$co= company code,c$dlyn= 'N' for inactive records). - Set Protection Mode: If
p$mode = 'MNT', enables input fields (*in70 = *off); otherwise, protects fields for inquiry mode (*in70 = *on). - Position File: Calls
sf1repto position theAPVENDRDfile based on user input (company code, vendor number, or search string). - Main Loop (
sf1agn):- Displays the command line and message subfile.
- Checks for subfile records to set display indicators (
*in41forSFLDSP). - Displays the subfile control record (
sflctl1) usingEXFMT. - Processes user input based on function keys:
- F3: Exits the program.
- F4: Calls
prompt(empty in this code, likely for future field-level help). - F5: Refreshes the subfile, clearing selection fields and repositioning.
- Page Down: Loads additional subfile records (
sf1lod). - Enter: Processes subfile changes (
sf1prc) if records are modified. - F10: Repositions the cursor to the control record.
- Handles direct access (
sf1dir) if a specific vendor is selected (d$selandd$vend). - Repositions the subfile if control fields change (
sf1rep).
-
Purpose: Manages the interactive subfile interface, allowing users to view and manipulate vendor records.
-
Process Subfile on Enter (
sf1prcSubroutine): - Reads changed subfile records (
readc sfl1) and processes each usingsf1chg. -
Purpose: Handles user selections or modifications made in the subfile.
-
Process Subfile Record Change (
sf1chgSubroutine): - Copies the selected vendor number (
s1vend) to working fields (s$vend,a$vend). - Based on the subfile selection option (
s1sel):- Option 2: Calls
sf1s02(change vendor) ifp$mode = 'MNT'. - Option 4: Calls
sf1s04(inactivate/reactivate vendor) ifp$mode = 'MNT'. - Option 5: Calls
sf1s05(display vendor).
- Option 2: Calls
- Updates the subfile record after processing by chaining to
APVEND, formatting the record (sf1fmt), applying color coding (sf1col), and updatingsfl1. -
Purpose: Processes user-selected actions for specific vendor records.
-
Reposition Subfile (
sf1repSubroutine): - Clears the subfile (
sf1clr) and resets the relative record number (rrn1). - Validates control fields (
sf1cte). - Positions the
APVENDRDfile usingsetllbased on the company code (c$co) and vendor number (c$vend). - Retains control fields for repositioning and loads new subfile records (
sf1lod). -
Purpose: Refreshes the subfile based on user-specified filters (company, vendor, search string, or inactive flag).
-
Edit Subfile Control Input (
sf1cteSubroutine): - Validates the company code (
c$co) by chaining toAPCONT. If invalid or blank, sets error messageERR0000and indicators*in50,*in51. - Ensures
c$dlyn(include inactive) isYorN; if invalid, sets error messageERR0014and indicators*in50,*in52. -
Purpose: Validates user input in the subfile control area to ensure correct data filtering.
-
Load Subfile Records (
sf1lodSubroutine): - Loads up to
pagsz1(30) records into the subfile. - Reads records from
APVENDRDusingreadewith key listkls1r1. - Filters records:
- Skips inactive records (
vndel = 'I') ifc$dlyn = 'N'. - Applies search string filter (
c$srch) usingscanonvnname.
- Skips inactive records (
- Formats each record (
sf1fmt) and applies color coding (sf1col). - Writes records to the subfile (
sfl1) and updatesrrn1. -
Purpose: Populates the subfile with filtered vendor records for display.
-
Format Subfile Line (
sf1fmtSubroutine): - Clears the subfile record and populates fields:
s1del: Vendor deletion flag (vndel).s1vend: Vendor number (vnvend).s1name: Vendor name (vnname).s1tel#: Vendor phone (vnarea+vntele).s1lpay: Last payment amount (vnlpay).s1lpdt: Last payment date (vnlpd8, converted to MMDDYY).
-
Purpose: Formats vendor data for display in the subfile.
-
Subfile Color Coding (
sf1colSubroutine):- Sets indicator
*in71to*onif the vendor is inactive (s1del = 'I'), likely for visual highlighting. - Purpose: Visually distinguishes inactive vendors in the subfile.
- Sets indicator
-
Direct Access Processing (
sf1dirSubroutine):- Validates direct selection (
d$selandd$vend): - For option 1 (create) in
MNTmode, ensuresd$vendis not zero (ERR0103if zero). - Checks if the vendor exists in
APVEND(klsfl1 setll):- For non-create options, errors if vendor does not exist (
ERR0102). - For create, errors if vendor already exists (
ERR0101).
- For non-create options, errors if vendor does not exist (
- Processes valid selections by calling
sf1s01,sf1s02,sf1s04, orsf1s05. - Clears selection fields after processing.
- Purpose: Handles direct vendor selection for create, change, inactivate, or display actions.
- Validates direct selection (
-
Clear Subfile (
sf1clrSubroutine):- Resets
rrn1andrrnsv1to zero and clears the subfile (*in42 = *on, writessflctl1). - Purpose: Prepares the subfile for reloading.
- Resets
-
Option Processing Subroutines:
- Create (
sf1s01): - Calls
AP910withMNTmode, passing company, vendor, file name, file group, and a return flag. - If successful (
o$flag = '1'ando$vendnon-zero), sends confirmation message (com(02)+ vendor number) and triggers subfile repositioning. - Change (
sf1s02): - Ensures the vendor is not deleted (
vndel ≠ 'D'); if deleted, sets errorcom(08). - Calls
AP910withMNTmode. - If successful (
o$flag = '1'), sends confirmation message (com(03)+ vendor number). - Inactivate/Reactivate (
sf1s04): - Calls
AP9104, passing company, vendor, file name, file group, and return flag. - Based on
o$flag, sends confirmation message:I: Inactive (com(05)+ vendor number).A: Active (com(06)+ vendor number).
- Display (
sf1s05): - Calls
AP910withINQmode to display vendor details. - Purpose: Executes specific vendor actions based on user selection.
- Create (
-
Message Handling (
addmsg,wrtmsg,clrmsgSubroutines):- Add Message (
addmsg): Sends messages to the program message queue (QMHSNDPM) with error or confirmation text. - Write Message (
wrtmsg): Displays the message subfile (msgctl). - Clear Message (
clrmsg): Clears the message subfile usingQMHRMVPM. - 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 (option 1), change (option 2), or inactivate/reactivate (option 4) vendor records. -
In
INQmode, users can only display vendor details (option 5), with input fields protected (*in70 = *on). -
File Overrides for 1099 Processing:
- When called from the 1099 process, the program overrides
APVENDandAPVENDRDto year-specific files (e.g.,APVN2025) based onp$fileandp$fgrp(GorZ). -
Ensures historical vendor data (from
GAPVEND) is accessed correctly. -
Validation Rules:
- Company code (
c$co) must exist inAPCONT(ERR0000if invalid). - Inactive flag (
c$dlyn) must beYorN(ERR0014if invalid). - For create (option 1), vendor number must be non-zero (
ERR0103) and must not already exist (ERR0101). - For non-create options, vendor must exist (
ERR0102). -
Deleted vendors (
vndel = 'D') cannot be modified (ERR0000). -
Subfile Filtering:
- Users can filter vendors by company code, vendor number, search string (
c$srch), or include inactive records (c$dlyn = 'Y'). -
Inactive vendors are visually highlighted (
*in71 = *on). -
User Interface:
- Supports function keys: F3 (exit), F4 (prompt, not implemented), F5 (refresh), F10 (position to control), Page Down (load more records), and Enter (process changes).
- Displays up to 30 records per subfile page (
pagsz1). -
Maintains cursor position and subfile page for redisplay.
-
Confirmation Messages:
- Provides feedback for successful create (
com(02)), change (com(03)), inactivate (com(05)), or reactivate (com(06)) actions.
Tables (Files) Used¶
- AP910PD:
- Display file (CF,
workstn) with a subfile (sfl1) for interactive vendor management. -
Used for user interface (input/output via
sflctl1,sflcmd1,msgctl,msgclr). -
APCONT:
- Input-only file (IF,
usropn) containing company data. - Overridden to
GAPCONTorZAPCONTbased onp$fgrp. -
Used to validate company code (
c$co). -
APVEND:
- Input-only file (IF,
usropn) containing vendor data. - Overridden to
GAPVEND,ZAPVEND, or a year-specific file (e.g.,APVN2025) based onp$fileandp$fgrp. -
Used for chaining vendor records during updates.
-
APVENDRD:
- Input-only file (IF,
usropn) with renamed record format (apvendpftoapvendpr). - Overridden similarly to
APVEND. - Used for reading vendor records to populate the subfile.
External Programs Called¶
- AP910:
- Called for:
- Create (
sf1s01,MNTmode): Creates a new vendor record. - Change (
sf1s02,MNTmode): Updates an existing vendor record. - Display (
sf1s05,INQmode): Displays vendor details.
- Create (
-
Parameters:
o$co(company),o$vend(vendor),o$mode(MNT/INQ),o$file(file name),o$fgrp(file group),o$flag(return flag). -
AP9104:
- Called for inactivate/reactivate (
sf1s04,MNTmode): Toggles vendor status between active and inactive. -
Parameters:
o$co,o$vend,o$file,o$fgrp,o$flag(returnsIfor inactive,Afor active). -
QCMDEXC:
-
System program to execute file override commands (
OVRDBF) forAPCONT,APVEND, andAPVENDRD. -
QMHSNDPM:
-
System program to send messages to the program message queue for errors or confirmations.
-
QMHRMVPM:
- System program to clear messages from the message subfile.
Summary¶
The AP910P RPGLE program is a core component of the accounts payable system, providing an interactive subfile interface for managing vendor records. It supports creating, updating, inactivating/reactivating, and displaying vendors, with specific handling for 1099 processing via year-specific file overrides. The program validates inputs, filters records, and provides user feedback through a message subfile. It integrates with the OCL program AP910P99 to allow manual updates to vendor payment totals for 1099 forms.
Tables/Files: AP910PD (display), APCONT, APVEND, APVENDRD (overridden to GAPCONT, GAPVEND, ZAPCONT, ZAPVEND, or APVNYYYY).
External Programs: AP910, AP9104, QCMDEXC, QMHSNDPM, QMHRMVPM.
If you need further details on the called programs (AP910, AP9104) or file structures, let me know, and I can provide additional analysis or search for relevant information!