AP9104 RPGLE
The RPGLE program AP9104.rpgle.txt
is part of an IBM AS/400 or IBM i accounts payable system, designed to handle the inactivation or reactivation of vendor master records. It is called from the OCL program AP910P99.ocl36.txt
via AP910P
(specifically for option 4 in the subfile interface) and provides a window-based interface (delwdw
) to toggle a vendor's status between active (A
) and inactive (I
). The program supports 1099 processing by overriding vendor files to year-specific versions (e.g., APVN2012
). Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPGLE Program¶
The AP9104
program is a display file-driven application that presents a window (delwdw
) for users to inactivate or reactivate vendor records. It operates in maintenance mode only, as it updates the vendor file (APVEND
) and does not support inquiry mode explicitly. 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$file
(10A): Vendor file name for 1099 processing (e.g.,APVN2012
).p$fgrp
(1A): File group, eitherG
orZ
, for file overrides.p$flag
(1A): Return flag to indicate the result (A
for reactivated,D
for inactivated).
- Sets Up Fields: Initializes display file fields (
f$co
,f$vend
), key list (klvend
), and message handling fields (dspmsg
,m@pgmq
,m@key
). Defines a date conversion data structure (d#cymd
) and a program status data structure (psds##
). -
Purpose: Prepares the program environment by setting initial field values and key lists.
-
Open Database Tables (
opntbl
Subroutine): - File Overrides: Based on
p$fgrp
(G
orZ
), applies overrides toAPCONT
,APOPNH
,INFIL4
, andAPVEND
usingQCMDEXC
to executeOVRDBF
commands:- For
p$fgrp = 'G'
: Overrides toGAPCONT
,GAPOPNH
,GINFIL4
,GAPVEND
. - For
p$fgrp = 'Z'
: Overrides toZAPCONT
,ZAPOPNH
,ZINFIL4
,ZAPVEND
. - If
p$file
is provided (e.g.,APVN2012
), uses it forAPVEND
.
- For
- Opens Files: Opens
APCONT
,APOPNH
,INFIL4
, andAPVEND
withUSROPN
for dynamic access. -
Purpose: Ensures access to the correct files, especially year-specific vendor files for 1099 processing (per revision
JB01
). -
Retrieve Data (
rtvdta
Subroutine): - Fetch Company Data: Chains to
APCONT
usingf$co
to validate the company code (no action taken if not found,*in99
checked). - Fetch Vendor Data: Chains to
APVEND
usingklvend
(f$co
,f$vend
). If the vendor exists (*in99 = *off
):- If
vndel = 'I'
(inactive), sets header (f$hdr
) to “Vendor Master Reactivate” and function key label (f$fkyd
) to “F22=Reactivate” (*in72 = *on
). - Otherwise, sets header to “Vendor Master Inactivate” and function key label to “F23=Inactivate” (
*in73 = *on
).
- If
-
Purpose: Loads vendor data and configures the window based on the vendor’s current status.
-
Process Window (
prcwdw
Subroutine): - Main Loop (
winagn
):- Displays the message subfile if needed (
wrtmsg
) or clears it (msgclr
). - Displays the
delwdw
window usingEXFMT
. - Clears the message subfile (
clrmsg
) and error indicators (*in50
–*in69
). - Processes user input based on function keys:
- F12: Exits the program (
winagn = *off
). - F22 or F23: Validates input (
winedt
), checks balances if F23 (chkbal
), and updates the database if no errors (winupd
). - Other (Enter): Validates input (
winedt
) without updating.
- Displays the message subfile if needed (
-
Purpose: Manages the interactive window for inactivating or reactivating vendors.
-
Edit Window Input (
winedt
Subroutine): - If F23 (inactivate) is pressed, calls
chkbal
to check for outstanding balances or history (though most checks are commented out). -
Purpose: Ensures valid conditions before allowing database updates.
-
Check Balances (
chkbal
Subroutine): - Commented out checks for:
- Open invoices in
APOPNH
(ERR0000
,com(01)
: “This Vendor Has Outstanding Invoices, Cannot Delete”). - Non-zero monthly balances (
vnpurc
,vnpay
,vndmtd
) inAPVEND
(ERR0000
,com(01)
). - Inventory history in
INFIL4
(ERR0000
,com(02)
: “This Vendor Has Inventory History, Cannot Delete”).
- Open invoices in
-
Purpose: Originally intended to prevent inactivation if the vendor has outstanding activity, but currently allows inactivation without checks (noted as “never allowed to delete a vendor”).
-
Update Database (
winupd
Subroutine): - Reactivate (F22):
- Chains to
APVEND
usingklvend
. - If the vendor exists (
*in99 = *off
) and is inactive (vndel = 'I'
), setsvndel = 'A'
, updatesapvendpf
, and setsp$flag = 'A'
.
- Chains to
- Inactivate (F23):
- Chains to
APVEND
usingklvend
. - If the vendor exists (
*in99 = *off
) and is not inactive (vndel ≠ 'I'
), setsvndel = 'I'
, updatesapvendpf
, and setsp$flag = 'D'
.
- Chains to
-
Purpose: Updates the vendor’s status in
APVEND
to active or inactive. -
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 or confirmations.
-
Program Termination:
- Closes all files (
close *all
), sets*inlr = *on
, and returns. - Purpose: Ensures clean program exit.
Business Rules¶
- Vendor Status Toggle:
- The program toggles the vendor’s deletion flag (
vndel
) inAPVEND
:- F22 (Reactivate): Changes
vndel
fromI
(inactive) toA
(active), setsp$flag = 'A'
. - F23 (Inactivate): Changes
vndel
from non-I
toI
(inactive), setsp$flag = 'D'
.
- F22 (Reactivate): Changes
-
The term “delete” in comments refers to marking a vendor as inactive (
I
), not physical deletion. -
Validation (Disabled):
- Originally, inactivation (F23) was restricted if the vendor had:
- Open invoices in
APOPNH
. - Non-zero balances (
vnpurc
,vnpay
,vndmtd
) inAPVEND
. - Inventory history in
INFIL4
.
- Open invoices in
-
These checks are commented out, allowing inactivation without validation (noted as “never allowed to delete a vendor”).
-
File Overrides for 1099 Processing:
- Overrides
APVEND
to year-specific files (e.g.,APVN2012
) based onp$file
andp$fgrp
(G
orZ
) to support 1099 processing (perJB01
). -
Similarly overrides
APCONT
,APOPNH
, andINFIL4
. -
User Interface:
- Uses a window (
delwdw
) with dynamic headers (“Vendor Master Reactivate” or “Vendor Master Inactivate”) and function key labels (F22=Reactivate
orF23=Inactivate
) based on the vendor’s current status. - Supports function keys: F12 (exit), F22 (reactivate), F23 (inactivate), and Enter (validate input).
-
Displays error messages if validation fails (though currently disabled).
-
Database Updates:
- Updates
APVEND
only if the vendor exists and meets status conditions. - Returns
p$flag
to indicate the action taken (A
orD
).
Tables (Files) Used¶
- AP9104D:
- Display file (CF,
workstn
) for the vendor inactivate/reactivate window (delwdw
,msgctl
,msgclr
). -
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
). -
APOPNH:
- Input-only file (IF,
usropn
) for open invoices. - Overridden to
GAPOPNH
orZAPOPNH
. -
Used in commented-out balance checks (
chkbal
). -
INFIL4:
- Input-only file (IF,
usropn
) for inventory history. - Overridden to
GINFIL4
orZINFIL4
. -
Used in commented-out balance checks (
chkbal
). -
APVEND:
- Update file (UF,
usropn
) for vendor master data. - Overridden to
GAPVEND
,ZAPVEND
, or a year-specific file (e.g.,APVN2012
) based onp$file
andp$fgrp
. - Used to update the vendor’s deletion flag (
vndel
).
External Programs Called¶
- QCMDEXC:
-
System program to execute file override commands (
OVRDBF
) forAPCONT
,APOPNH
,INFIL4
, andAPVEND
. -
QMHSNDPM:
-
System program to send messages to the program message queue.
-
QMHRMVPM:
- System program to clear messages from the message subfile.
Summary¶
The AP9104
RPGLE program is a specialized component of the accounts payable system, called from AP910P99
via AP910P
to inactivate or reactivate vendor records by toggling the vndel
flag in APVEND
(A
for active, I
for inactive). It uses a window interface (delwdw
) and supports 1099 processing through year-specific file overrides. Validation checks for outstanding invoices or balances are disabled, allowing unrestricted status changes. The program provides user feedback via a message subfile and integrates with the broader vendor maintenance workflow.
Tables/Files: AP9104D
(display), APCONT
, APOPNH
, INFIL4
, APVEND
(overridden to GAPCONT
, GAPOPNH
, GINFIL4
, GAPVEND
, or APVNYYYY
).
External Programs: QCMDEXC
, QMHSNDPM
, QMHRMVPM
.
If you need further details on related programs, file structures, or the OCL integration, let me know, and I can provide additional analysis or search for relevant information!