BB9059 RPGLE
The RPG program BB9059
is a component of the Accounts Payable system, designed to capture a "replacing" carrier ID when creating a new carrier ID, specifically to populate the bbfx62w
file with "From" and "To" carrier IDs. It is called by the BB905
program to handle this specific task. Below is a detailed explanation of the process steps, business rules, database tables used, and external programs called, based on the provided source code.
Process Steps of the RPG Program BB9059
¶
The BB9059
program manages the entry of a replacement carrier ID through a display window (rplwdw
) and validates the input before updating the bbfx62w
file. It ensures the "From" carrier ID is valid and not linked to a vendor, then sends confirmation messages to specific users. Here’s a step-by-step breakdown of the process:
- Initialization (
*inzsr
Subroutine): - Receive Input Parameters: The program accepts four parameters:
p$co
: Company number.p$caid
: Carrier ID (the "To" carrier ID, representing the new carrier).p$flag
: Return code (1
for successful update,2
for cancellation).p$fgrp
: File group (Z
orG
for database overrides).
- Initialize Format Fields: Copies
p$co
tow$co
andp$caid
tow$cito
(the "To" carrier ID field for the display window). - Set Up Variables: Initializes message handling fields (
dspmsg
,m@pgmq
,m@key
), and defines key lists:kltocaid
: For chaining tobbcaid
withw$co
andw$cito
(To carrier).klfrcaid
: For chaining tobbcaid
withw$co
andw$cifr
(From carrier).klapveny
: For checkingapveny
withw$co
andw$cifr
.
-
Set Window Flag: Sets
winagn
to*on
to enter the window processing loop. -
Open Database Tables (
opntbl
Subroutine): - Apply File Overrides: Based on
p$fgrp
(Z
orG
), executes override commands (ovrdbf
) usingQCMDEXC
to point to the appropriate database files (gapveny
,gbbcaid
,gbbfx62w
orzapveny
,zbbcaid
,zbbfx62w
).- Loops through three override commands (
ovg
orovz
) for each file.
- Loops through three override commands (
-
Open Files: Opens
apveny
(input-only for vendor data),bbcaid
(input-only for carrier data), andbbfx62w
(input/add for replacement data). -
Retrieve Data (
rtvdta
Subroutine): -
Check To Carrier ID: Chains to
bbcaid
usingkltocaid
(w$co
,w$cito
) to verify the "To" carrier ID.- If found (
*in99 = *off
), the program proceeds (though no specific action is taken, asw$tonm
assignment is commented out). - If not found, no error is raised, as the "To" carrier is assumed to be new (per the program’s context).
- If found (
-
Process Window (
prcwdw
Subroutine): -
Main Loop (
winagn
):- Display Message Subfile: If
dspmsg
is on, writes the message subfile (wrtmsg
); otherwise, clears it (msgclr
). - Display Window: Displays the
rplwdw
format usingexfmt
, allowing the user to enter a "From" carrier ID (w$cifr
). - Clear Messages: Clears the message subfile if displayed (
clrmsg
). - Clear Error Indicators: Resets indicators
*in50
to*in69
. - Process User Input:
- F12 (Exit): Sets
winagn
to*off
, setsp$flag = '2'
(indicating cancellation), and iterates to exit the loop. - F22 (Confirm): Validates input via
winedt
. If no errors (*in50 = *off
), updates the database viawinupd
, setsp$flag = '1'
(success), and exits the loop. - Other (e.g., Enter): Validates input via
winedt
and redisplays the window if errors exist.
- Display Message Subfile: If
-
Edit Window Input (
winedt
Subroutine): - Allow Blank Entry: If the "From" carrier ID (
w$cifr
) is blank, no update tobbfx62w
is performed, and no error is raised. - Validate From Carrier ID:
- Chains to
bbcaid
usingklfrcaid
(w$co
,w$cifr
). - If not found (
*in99 = *on
), clearsw$frnm
(From carrier name), sets errorERR0000
with messagecom(01)
("Invalid Carrier ID"), sets*in50
and*in51
, and callsaddmsg
. - If found, moves the carrier name (
cicanm
) tow$frnm
.
- Chains to
-
Check Vendor Linkage:
- If no prior errors (
*in50 = *off
), checksapveny
usingklapveny
(w$co
,w$cifr
). - If no vendor record is found (
*in99 = *on
), sets errorERR0000
with messagecom(02)
("Code [w$cifr] is linked to a vendor for ARGLMS. Contact IT to convert."), sets*in50
and*in51
, and callsaddmsg
.
- If no prior errors (
-
Update Database from Window Input (
winupd
Subroutine): - Check Blank Entry: If
w$cifr
is blank, no update occurs, and the subroutine exits. - Update bbfx62w: Clears the
bbfx62wpf
record, setsw1cifr
(From carrier ID) tow$cifr
, setsw1cito
(To carrier ID) tow$cito
, and writes the record tobbfx62w
. -
Send Confirmation Messages:
- Constructs two messages using the
msg
array: - First message: "BBFX62W Entry Created. From Carrier [w$cifr] To Carrier [w$cito].) TOUSR(JLBIT)"
- Second message: "BBFX62W Entry Created. From Carrier [w$cifr] To Carrier [w$cito].) TOUSR(CAPO)"
- Executes each message using
QCMDEXC
with a length of 120 characters, sending notifications to usersJLBIT
andCAPO
.
- Constructs two messages using the
-
Message Handling:
- Add Message (
addmsg
): Sends error messages to the program message queue usingQMHSNDPM
with message ID, file (GSMSGF
), data, and type (*DIAG
). - Write Message Subfile (
wrtmsg
): Writes the message subfile (msgctl
) with indicator*in49
. -
Clear Message Subfile (
clrmsg
): Clears messages usingQMHRMVPM
. (Saving/restoringrcdnam
andpagrrn
is commented out, likely unnecessary for a window-based interface.) -
Program Termination:
- Closes all files (
close *all
). - Sets the last record indicator (
*inlr
) to*on
and returns.
Business Rules¶
The program enforces the following business rules:
1. Replacement Carrier Capture:
- The program captures a "From" carrier ID (w$cifr
) to pair with the "To" carrier ID (w$cito
) when creating a new carrier ID, storing the relationship in bbfx62w
.
- A blank "From" carrier ID is allowed, in which case no record is written to bbfx62w
.
- Validation:
- The "From" carrier ID must exist in
bbcaid
for the given company (w$co
). If not, an error (ERR0000
, "Invalid Carrier ID") is displayed. -
The "From" carrier ID must not be linked to a vendor in
apveny
. If linked, an error (ERR0000
, "Code [w$cifr] is linked to a vendor for ARGLMS. Contact IT to convert.") is displayed, preventing the update. -
User Notification:
-
Upon successful creation of a
bbfx62w
record, two messages are sent viaQCMDEXC
to usersJLBIT
andCAPO
, confirming the entry with both carrier IDs. -
User Interface:
- The window (
rplwdw
) allows the user to enter a "From" carrier ID and confirm with F22 or cancel with F12. - F12 sets
p$flag = '2'
, indicating the user chose not to proceed with the replacement. -
F22 triggers validation and, if successful, updates
bbfx62w
and setsp$flag = '1'
. -
Error Handling:
- Errors prevent the database update and keep the window open for correction.
- Messages are displayed via the message subfile for user feedback.
Database Tables Used¶
The program interacts with the following database files:
1. apveny: Input-only file for vendor data, overridden to gapveny
or zapveny
based on p$fgrp
. Used to check if the "From" carrier ID is linked to a vendor.
2. bbcaid: Input-only file for carrier ID data, overridden to gbbcaid
or zbbcaid
. Used to validate the "From" carrier ID.
3. bbfx62w: Input/add file for storing replacement carrier relationships, overridden to gbbfx62w
or zbbfx62w
. Updated with "From" and "To" carrier IDs.
4. bb9059d: Display file (workstation file) containing the rplwdw
window format and message subfile (msgctl
) for user interaction.
External Programs Called¶
The program calls the following external program:
1. QCMDEXC: Executes override commands (ovrdbf
) for database files and sends confirmation messages to users JLBIT
and CAPO
.
Summary¶
The BB9059
program is a specialized module called by BB905
to capture a "From" carrier ID when creating a new carrier ID, storing the relationship in the bbfx62w
file. It presents a window (rplwdw
) for user input, validates the "From" carrier ID against bbcaid
and apveny
, and ensures it is valid and not linked to a vendor. Upon successful validation, it writes to bbfx62w
and notifies users JLBIT
and CAPO
. The program supports cancellation (F12) and confirmation (F22), with business rules enforcing data integrity and user notification. File overrides ensure the correct dataset is used, and error messages guide the user through invalid inputs.