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 (
*inzsrSubroutine): - 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 (1for successful update,2for cancellation).p$fgrp: File group (ZorGfor database overrides).
- Initialize Format Fields: Copies
p$cotow$coandp$caidtow$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 tobbcaidwithw$coandw$cito(To carrier).klfrcaid: For chaining tobbcaidwithw$coandw$cifr(From carrier).klapveny: For checkingapvenywithw$coandw$cifr.
-
Set Window Flag: Sets
winagnto*onto enter the window processing loop. -
Open Database Tables (
opntblSubroutine): - Apply File Overrides: Based on
p$fgrp(ZorG), executes override commands (ovrdbf) usingQCMDEXCto point to the appropriate database files (gapveny,gbbcaid,gbbfx62worzapveny,zbbcaid,zbbfx62w).- Loops through three override commands (
ovgorovz) 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 (
rtvdtaSubroutine): -
Check To Carrier ID: Chains to
bbcaidusingkltocaid(w$co,w$cito) to verify the "To" carrier ID.- If found (
*in99 = *off), the program proceeds (though no specific action is taken, asw$tonmassignment 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 (
prcwdwSubroutine): -
Main Loop (
winagn):- Display Message Subfile: If
dspmsgis on, writes the message subfile (wrtmsg); otherwise, clears it (msgclr). - Display Window: Displays the
rplwdwformat 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
*in50to*in69. - Process User Input:
- F12 (Exit): Sets
winagnto*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
winedtand redisplays the window if errors exist.
- Display Message Subfile: If
-
Edit Window Input (
winedtSubroutine): - Allow Blank Entry: If the "From" carrier ID (
w$cifr) is blank, no update tobbfx62wis performed, and no error is raised. - Validate From Carrier ID:
- Chains to
bbcaidusingklfrcaid(w$co,w$cifr). - If not found (
*in99 = *on), clearsw$frnm(From carrier name), sets errorERR0000with messagecom(01)("Invalid Carrier ID"), sets*in50and*in51, and callsaddmsg. - If found, moves the carrier name (
cicanm) tow$frnm.
- Chains to
-
Check Vendor Linkage:
- If no prior errors (
*in50 = *off), checksapvenyusingklapveny(w$co,w$cifr). - If no vendor record is found (
*in99 = *on), sets errorERR0000with messagecom(02)("Code [w$cifr] is linked to a vendor for ARGLMS. Contact IT to convert."), sets*in50and*in51, and callsaddmsg.
- If no prior errors (
-
Update Database from Window Input (
winupdSubroutine): - Check Blank Entry: If
w$cifris blank, no update occurs, and the subroutine exits. - Update bbfx62w: Clears the
bbfx62wpfrecord, 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
msgarray: - 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
QCMDEXCwith a length of 120 characters, sending notifications to usersJLBITandCAPO.
- Constructs two messages using the
-
Message Handling:
- Add Message (
addmsg): Sends error messages to the program message queue usingQMHSNDPMwith 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/restoringrcdnamandpagrrnis commented out, likely unnecessary for a window-based interface.) -
Program Termination:
- Closes all files (
close *all). - Sets the last record indicator (
*inlr) to*onand 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
bbcaidfor 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
bbfx62wrecord, two messages are sent viaQCMDEXCto usersJLBITandCAPO, 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
bbfx62wand 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.