BB944 RPGLE
The RPG program BB944.rpgle
is an IBM i (AS/400) program designed for deleting or reactivating customer sales agreement records in the bicuag
file. It is called from BB943P
as part of the Customer Sales Agreement Maintenance process, specifically for handling the delete (option 4) operation. The program presents a confirmation window to the user to either delete an active record or reactivate a deleted record and updates the history file (bicuagh
) accordingly. Below, I will explain the process steps, business rules, tables used, and external programs called based on the provided RPG source code.
Process Steps of the RPG Program¶
The BB944
program follows a structured flow to manage the deletion or reactivation of customer sales agreement records using a display file (bb944d
) with a confirmation window. The key process steps are:
- Initialization (
*inzsr
Subroutine): - Parameters: Receives four input parameters:
p$cono
: Company number.p$seqn
: Sequence number of the sales agreement record.p$fgrp
: File group ('G' or 'Z') to determine database file overrides.p$flag
: Return flag to indicate the action taken ('D' for delete, 'A' for reactivate).
- Field Setup: Initializes work fields (
l$cncd
,w$cnty
), message handling fields (dspmsg
,m@pgmq
,m@key
), and current date/time (t#time
,t#cymd
) for validation and history logging. - Output Parameters: Initializes
o$fgrp
,o$mode
, ando$flag
as blank. -
Data Structures: Defines
wkds01
(external data structure forbicuag
) andwkdshist
(external data structure forbicuagh
) to hold record formats. -
Open Database Tables (
opntbl
Subroutine): - Applies file overrides (
ovg
orovz
) based onp$fgrp
using theQCMDEXC
API, mapping files to appropriate libraries (e.g.,ggscntr1
orzgscntr1
). -
Opens input files (
gscntr1
,gstabl
,shipto
) and update/output files (bicuag
,bicuagh
) withUSROPN
for data access. -
Retrieve Data (
rtvdta
Subroutine): - Chains to
bicuag
using theklcuag
keylist (p$cono
,p$seqn
) to retrieve the sales agreement record. - If the record is found (
*in99 = *off
):- Populates display fields (
f$*
) with record data (e.g.,f$cono
,f$cust
,f$loc
,f$cntr
,f$ship
,f$pord
,f$prce
,f$offp
). - Converts start/end dates (
bastd8
,baend8
) to MMDDYY format (f$smdy
,f$emdy
) for display. - Checks if the record is expired (
baend8 < t#cymd
) and sets*in71 = *on
to highlight in red. - Checks the deletion status (
badel
): - If
badel = 'D'
, sets*in72 = *on
(indicating reactivation mode,F22=ReActivate
). - If
badel ≠ 'D'
, sets*in72 = *off
(indicating deletion mode,F23=Delete
).
- Populates display fields (
-
Chains to
shipto
usingklship
to retrieve the ship-to name (f$shnm
) ifbaship ≠ 0
. -
Process Panel Formats (
srfmt
Subroutine): - Main Window Loop: Enters a loop (
winagn = *on
) to display the confirmation window (delwdw
) and process user input. - Message Handling:
- Displays the message subfile (
wrtmsg
) ifdspmsg = *on
. - Clears the message subfile (
clrmsg
) after input processing.
- Displays the message subfile (
- Display Window: Writes the overlay record (
wdwovr
) and formats (delwdw
) usingEXFMT
to show the confirmation window with record details. -
Process Input:
- F12 (Cancel): Exits the loop (
winagn = *off
), returning without action. - F23 (Delete): If
*in72 = *off
(active record), chains tobicuag
, setsbadel = 'D'
, writes to history (writehist
), updatesbicuag
, setsp$flag = 'D'
, and exits. - F22 (Reactivate): If
*in72 = *on
(deleted record), chains tobicuag
, setsbadel = 'A'
, writes to history (writehist
), updatesbicuag
, setsp$flag = 'A'
, and exits. - Other Input: Validates the password (
c1agpw
) againstw$agpw
(populated byrtvdta
) and redisplays the window if invalid.
- F12 (Cancel): Exits the loop (
-
Write History (
writehist
Subroutine): - Copies the current
bicuag
record to thewkdshist
data structure. - Sets history fields:
hhdel = badel
(deletion status, perjk01
).hhuser = ps#usr8
(user ID, 8 characters).hhmdy = ps#mdy
(current date, MMDDYY).hhhmst = ps#hms
(current time, HHMMSS).
-
Writes the record to
bicuagh
. -
Message Handling:
- Add Message (
addmsg
): Sends messages to the program message queue usingQMHSNDPM
. - Write Message (
wrtmsg
): Writes messages to the message subfile (msgctl
). -
Clear Message (
clrmsg
): Clears the message subfile usingQMHRMVPM
, preserving the current record format and subfile page. -
Program Termination:
- Closes all files (
close *all
). - Sets
*inlr = *on
and returns, passing backp$flag
('D' or 'A') to indicate the action taken.
Business Rules¶
The program enforces the following business rules for deleting or reactivating customer sales agreement records:
- Record Status:
- Records with
badel = 'D'
(deleted) can be reactivated (badel = 'A'
) using F22 (*in72 = *on
). - Records with
badel ≠ 'D'
(active) can be deleted (badel = 'D'
) using F23 (*in72 = *off
). -
Expired records (
baend8 < current date
) are highlighted in red (*in71 = *on
). -
Password Validation:
- A valid agreement password (
c1agpw
) must match the stored password (w$agpw
) fromrtvdta
for delete or reactivate actions. -
Invalid passwords cause the window to redisplay for re-entry.
-
History Logging:
-
Every delete or reactivation action writes a record to
bicuagh
with the user ID, date, time, and deletion status (hhdel = 'D'
or'A'
, perjk01
). -
Record Existence:
- The program chains to
bicuag
usingp$cono
andp$seqn
to ensure the record exists before processing (*in99 = *off
). -
If the record is not found or already in the desired state (e.g., attempting to delete a deleted record), no update occurs.
-
Ship-To Name:
-
If a ship-to code (
baship
) is non-zero, the program retrieves the ship-to name (f$shnm
) fromshipto
for display. -
File Group Overrides:
- Uses
p$fgrp
('G' or 'Z') to apply appropriate file overrides, ensuring access to the correct dataset (e.g.,gbicuag
orzbicuag
).
Tables Used¶
The program uses the following database files, with overrides applied based on p$fgrp
('G' or 'Z'):
- gscntr1: Container file (input, validates container codes, alpha key, replaced
gscntr
perjk02
). - gstabl: Table file (input, likely for container types or other reference data).
- shipto: Ship-to file (input, retrieves ship-to name for display).
- bicuag: Sales agreement file (update, primary file for deleting/reactivating records).
- bicuagh: Sales agreement history file (output, logs delete/reactivate actions, added per
jk01
).
Overrides map these files to specific libraries (e.g., ggscntr1
or zgscntr1
).
External Programs Called¶
The program calls the following external programs:
- QCMDEXC: System API to execute file override commands for the specified file group ('G' or 'Z').
- QMHSNDPM: System API to send messages to the program message queue.
- QMHRMVPM: System API to clear messages from the message subfile.
No other user-defined programs are called in the provided source code.
Summary¶
- Process Steps: Initializes parameters, applies file overrides, opens database files, retrieves the sales agreement record, displays a confirmation window, processes user input (F12 to cancel, F23 to delete, F22 to reactivate), validates passwords, updates
bicuag
, logs tobicuagh
, and handles messages. - Business Rules: Allows deletion (
badel = 'D'
) or reactivation (badel = 'A'
) of records, requires valid passwords, logs actions to history, highlights expired records, and validates record existence and ship-to names. - Tables Used:
gscntr1
,gstabl
,shipto
,bicuag
,bicuagh
. - External Programs Called:
QCMDEXC
,QMHSNDPM
,QMHRMVPM
.
If you need further analysis of specific subroutines, file structures, or integration with BB943P
or BB943
, please provide additional details or source code. Alternatively, I can perform a DeepSearch for related information if enabled. Let me know how to proceed!