BB944 RPGLE
The provided document is an RPGLE program named BB944
, called from the OCL procedure BB943INQ.ocl36.txt
in the IBM System/36 (or AS/400 compatibility mode) environment. This program, titled "Customer Sales Agreement Delete Program," is designed to delete or reactivate customer sales agreement records in the bicuag
file, with history logging to the bicuagh
file. It interacts with users via a display file (bb944d
) and supports operations like marking records for deletion or reactivating previously deleted records. Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code and its context within the customer sales agreement maintenance system, integrating with BB943
, BB943V
, BB9433
, and GSDTCLC1
.
Process Steps of the RPGLE Program¶
The BB944
program is an interactive module that allows users to delete or reactivate customer sales agreement records based on a provided company number (p$cono
) and sequence number (p$seqn
). It uses a display file (bb944d
) for user interaction and updates the bicuag
file, logging changes to bicuagh
. Due to the truncation of the source code (9,696 characters), some logic (e.g., the srfmt
and rtvdta
subroutines) is incomplete, but I’ll reconstruct the process steps based on the available code and context.
- Initialization (
*inzsr
Subroutine): - Receive Parameters: The program accepts four parameters via the
*ENTRY
plist:p$cono
(company number, defined likebacono
).p$seqn
(sequence number, defined likebaseqn
).p$fgrp
(1 character, file group:'G'
or'Z'
for file overrides).p$flag
(1 character, return flag: e.g.,'1'
for success,'0'
for failure).
- Set System Information: Uses the
psds##
program status data structure to retrieve:ps#pgm
(program name).ps#usr
(user ID, 10 characters).ps#usr8
(user ID, 8 characters, perjk01
).ps#mdy
(job date, MMDDYY).ps#hms
(job time, HHMMSS).
- Set Current Date/Time: Uses the
TIME
operation to populatet#time
(14-digit timestamp) and converts it tot#cymd
(8-digit CCYYMMDD) for history record timestamps. - Initialize Fields:
- Output parameters: Clears
o$fgrp
,o$mode
, ando$flag
. - Work fields: Sets
l$cncd
(container code, 2.0) to zeros,w$cnty
(container type, 1 character) to blanks. - Control flags: Sets
fmtagn
anddelagn
to*off
for controlling format and deletion window processing. - Message fields: Initializes
dspmsg
to blank,m@pgmq
to'*'
, andm@key
to blanks.
- Output parameters: Clears
- Define Key Lists:
klship
: For accessingshipto
withbacono
,bacust
, andbaship
.klcuag
: For accessingbicuag
withp$cono
andp$seqn
.klcnty
: For accessinggstabl
withk$cntrty
(set to'CNTRTY'
) andk$cnty
(container type).
- Open Database Tables: Calls
opntbl
to apply file overrides and open files. -
Note: Test parameters (commented out, e.g.,
p$cprf = 'E0910114'
,p$mode = 'MNT'
) are for debugging and not used in production. -
Open Database Tables (
opntbl
Subroutine): - File Overrides: Based on
p$fgrp
('G'
or'Z'
), applies file overrides usingovg
orovz
arrays (e.g.,ovrdbf file(bicuag) tofile(*libl/gbicuag)
for'G'
). Executes overrides withQCMDEXC
for five files. - Open Files: Opens the following files with
usropn
:gscntr1
(container file, input-only, keyed, replacedgscntr
perjk02
).gstabl
(table file for codes, input-only, keyed).shipto
(ship-to address file, input-only, keyed).bicuag
(sales agreement file, update/input, keyed).bicuagh
(sales agreement history file, output-only, keyed, added perjk01
).
-
Purpose: Ensures access to the correct file library (
G
orZ
) for data operations. -
Retrieve Data (
rtvdta
Subroutine, Truncated): - Chain to
bicuag
: Likely usesklcuag
(p$cono
,p$seqn
) to retrieve the sales agreement record. - Check Record Status:
- If the record’s end date (
baend8
) is non-zero, sets*IN71
to*ON
(record has expired). - If the record’s deletion flag (
badel
) is'Y'
, sets*IN72
to*ON
(record is marked deleted, action is reactivate); otherwise,*IN72 = *OFF
(record is active, action is delete).
- If the record’s end date (
- Populate Display Fields: Moves
bicuag
fields (e.g.,bacono
,bacust
,baloc
,bacntr
,baship
,bapr01
–bapr10
,bapord
,bastd8
,baend8
,baprce
,baoffp
) to display file fields (f$
,s1
, ors2
prefixes) for user confirmation. -
Validate Related Data: Likely chains to
gscntr1
(container),gstabl
(unit of measure, container type), andshipto
(ship-to address) to display descriptions. -
Process Panel Formats (
srfmt
Subroutine, Partially Truncated): - Initialize Window: Sets
winagn = *ON
to indicate the main window is active. - Main Window Loop:
- Displays the
bb944d
display file, likely with a subfile (sfl1
orsfl2
) for agreement details, controlled by indicators: *IN40
: Subfile clear.*IN41
: Subfile display control.*IN42
: Subfile display.*IN43
: Subfile end/next change.*IN71
: Record has expired.*IN72
: Action is reactivate (*ON
) or delete (*OFF
).- Processes user input (function keys:
F23
for delete,F22
for reactivate,F12
for cancel,ENTER
for confirmation,PAGEDN
for scrolling).
- Displays the
- Handle Function Keys:
- F23 (Delete): Marks the record for deletion by setting
badel = 'Y'
inbicuag
and writes tobicuagh
. - F22 (Reactivate): Clears
badel = ' '
to reactivate the record. - F12 (Cancel): Exits without changes, setting
p$flag = '0'
. - ENTER: Confirms the delete/reactivate action, updating
bicuag
and logging tobicuagh
.
- F23 (Delete): Marks the record for deletion by setting
-
Subfile Processing: Uses
*IN88
forREADC
(read changed subfile) and*IN49
for message subfile display/control. -
Clear Message Subfile (
clrmsg
Subroutine): - Clear Messages: Calls
QMHRMVPM
to remove messages from the program message queue. - Save/Restore Context: Saves and restores the current record format (
rcdnam
torcdsav
) and subfile page relative record number (pagrrn
topagsav
). - Parameters: Passes
m@pgmq
,m@scnt
,m@rmvk
,m@rmv
, andm@errc
toQMHRMVPM
. -
Set Flag: Sets
dspmsg = *OFF
to indicate no messages are displayed. -
Write to History File (Implied, Not Shown):
- When deleting a record, likely writes a copy to
bicuagh
with audit fields:hhchd8
(change date, set tot#cymd
).hhchtm
(change time, set tot#hms
).hhuser
(user ID, set tops#usr8
, perjk01
).
-
Uses
wkdshist
(external data structure forbicuagh
) to populate fields. -
Program Termination:
- Closes all files (
close *all
). - Sets
*inlr = *on
to terminate. - Returns
p$flag
to indicate success ('1'
) or failure/cancellation ('0'
).
Business Rules¶
The program enforces the following business rules for deleting or reactivating customer sales agreements:
- Delete vs. Reactivate:
- If the record’s deletion flag (
badel
) is'Y'
, the action is to reactivate (*IN72 = *ON
,F22=ReActivate
). - If
badel
is blank, the action is to delete (*IN72 = *OFF
,F23=Delete
). -
Expired records (
baend8 ≠ 0
) are marked with*IN71 = *ON
for display purposes. -
Record Retrieval:
- Retrieves the agreement from
bicuag
usingp$cono
andp$seqn
(klcuag
). -
Validates related data (container in
gscntr1
, unit of measure/container type ingstabl
, ship-to inshipto
). -
History Logging (per
jk01
): - When a record is deleted, a copy is written to
bicuagh
with audit fields (hhchd8
,hhchtm
,hhuser
). -
The deletion flag (
badel
) is copied tohhdel
in the history record. -
User Interaction:
- Displays the agreement details for confirmation using
bb944d
. - Supports function keys:
F23
: Marksbadel = 'Y'
and logs tobicuagh
.F22
: Clearsbadel = ' '
to reactivate.F12
: Cancels the operation.ENTER
: Confirms the delete/reactivate action.PAGEDN
: Scrolls the subfile.
-
Protects input fields in certain modes (
*IN70–*IN79
). -
Validation:
- Ensures the agreement exists in
bicuag
before processing. -
Validates container codes (
gscntr1
, replacedgscntr
perjk02
) and other fields (viagstabl
,shipto
). -
Error Handling:
- Displays errors using the message subfile (
*IN49
) with messages stored inm@80
array andGSMSGF
message file. - Positions the cursor (
csrloc
) on error fields (*IN50–*IN69
,*IN21–*IN39
).
Tables Used¶
The program uses the following files, as defined in the File Specification (F-spec) section:
- bb944d: Display file (workstation file) for user interaction, likely with subfile support (
sfl1
orsfl2
). - gscntr1: Container file (replaced
gscntr
perjk02
), input-only, keyed. - gstabl: Table file (for codes like unit of measure, container type), input-only, keyed.
- shipto: Ship-to address file, input-only, keyed.
- bicuag: Sales agreement file, update/input, keyed.
- bicuagh: Sales agreement history file (added per
jk01
), output-only, keyed.
File Overrides:
- The ovg
and ovz
arrays specify overrides for file groups 'G'
and 'Z'
, mapping files to libraries (e.g., ggscntr1
, zbicuagh
).
External Programs Called¶
The program explicitly calls one external program:
- QCMDEXC:
- Called in the
opntbl
subroutine to execute file override commands. -
Parameters:
dbov##
(override command string, 80 bytes),dbol##
(length, 15.5). -
QMHRMVPM:
- Called in the
clrmsg
subroutine to clear messages from the message subfile. - Parameters:
m@pgmq
,m@scnt
,m@rmvk
,m@rmv
,m@errc
.
No other external programs are explicitly called, though GSDTCLC1
(from the previous context) may be used for date calculations in the truncated rtvdta
or srfmt
subroutines.
Summary¶
- Process Steps:
- Initialize by receiving
p$cono
,p$seqn
,p$fgrp
, andp$flag
, setting date/time, and defining key lists. - Apply file overrides and open files (
opntbl
). - Retrieve agreement data from
bicuag
and related files (rtvdta
, truncated). - Process user interaction via
bb944d
, handling delete (F23
), reactivate (F22
), or cancel (F12
) actions (srfmt
, partially truncated). - Clear message subfile (
clrmsg
). - Update
bicuag
(setbadel
) and log tobicuagh
for deletions. -
Terminate, closing files and returning
p$flag
. -
Business Rules:
- Deletes records by setting
badel = 'Y'
(F23
) or reactivates by clearingbadel
(F22
), based on*IN72
. - Logs deleted records to
bicuagh
with audit fields (jk01
). - Validates agreement existence and related data (container, ship-to).
- Displays expired records with
*IN71
. - Handles user input with function keys and subfile navigation.
-
Uses
G
orZ
file groups for overrides. -
Tables Used:
-
bb944d
,gscntr1
,gstabl
,shipto
,bicuag
,bicuagh
. -
External Programs Called:
QCMDEXC
(for file overrides).QMHRMVPM
(for message clearing).
Due to the truncation of the source code, details of the srfmt
and rtvdta
subroutines are incomplete, limiting visibility into the full display logic and record processing. If you can provide the complete BB944.rpgle
code or specific sections (e.g., srfmt
, rtvdta
), I can refine the process steps and business rules further. Additionally, if you have the display file (bb944d
) or related programs, I can provide more context. Let me know how you’d like to proceed!