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 (
*inzsrSubroutine): - Receive Parameters: The program accepts four parameters via the
*ENTRYplist: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
TIMEoperation 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
fmtagnanddelagnto*offfor controlling format and deletion window processing. - Message fields: Initializes
dspmsgto blank,m@pgmqto'*', andm@keyto blanks.
- Output parameters: Clears
- Define Key Lists:
klship: For accessingshiptowithbacono,bacust, andbaship.klcuag: For accessingbicuagwithp$conoandp$seqn.klcnty: For accessinggstablwithk$cntrty(set to'CNTRTY') andk$cnty(container type).
- Open Database Tables: Calls
opntblto 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 (
opntblSubroutine): - File Overrides: Based on
p$fgrp('G'or'Z'), applies file overrides usingovgorovzarrays (e.g.,ovrdbf file(bicuag) tofile(*libl/gbicuag)for'G'). Executes overrides withQCMDEXCfor five files. - Open Files: Opens the following files with
usropn:gscntr1(container file, input-only, keyed, replacedgscntrperjk02).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 (
GorZ) for data operations. -
Retrieve Data (
rtvdtaSubroutine, 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*IN71to*ON(record has expired). - If the record’s deletion flag (
badel) is'Y', sets*IN72to*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
bicuagfields (e.g.,bacono,bacust,baloc,bacntr,baship,bapr01–bapr10,bapord,bastd8,baend8,baprce,baoffp) to display file fields (f$,s1, ors2prefixes) 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 (
srfmtSubroutine, Partially Truncated): - Initialize Window: Sets
winagn = *ONto indicate the main window is active. - Main Window Loop:
- Displays the
bb944ddisplay file, likely with a subfile (sfl1orsfl2) 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:
F23for delete,F22for reactivate,F12for cancel,ENTERfor confirmation,PAGEDNfor scrolling).
- Displays the
- Handle Function Keys:
- F23 (Delete): Marks the record for deletion by setting
badel = 'Y'inbicuagand 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
bicuagand logging tobicuagh.
- F23 (Delete): Marks the record for deletion by setting
-
Subfile Processing: Uses
*IN88forREADC(read changed subfile) and*IN49for message subfile display/control. -
Clear Message Subfile (
clrmsgSubroutine): - Clear Messages: Calls
QMHRMVPMto remove messages from the program message queue. - Save/Restore Context: Saves and restores the current record format (
rcdnamtorcdsav) and subfile page relative record number (pagrrntopagsav). - Parameters: Passes
m@pgmq,m@scnt,m@rmvk,m@rmv, andm@errctoQMHRMVPM. -
Set Flag: Sets
dspmsg = *OFFto indicate no messages are displayed. -
Write to History File (Implied, Not Shown):
- When deleting a record, likely writes a copy to
bicuaghwith 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 = *onto terminate. - Returns
p$flagto 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
badelis blank, the action is to delete (*IN72 = *OFF,F23=Delete). -
Expired records (
baend8 ≠ 0) are marked with*IN71 = *ONfor display purposes. -
Record Retrieval:
- Retrieves the agreement from
bicuagusingp$conoandp$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
bicuaghwith audit fields (hhchd8,hhchtm,hhuser). -
The deletion flag (
badel) is copied tohhdelin 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
bicuagbefore processing. -
Validates container codes (
gscntr1, replacedgscntrperjk02) and other fields (viagstabl,shipto). -
Error Handling:
- Displays errors using the message subfile (
*IN49) with messages stored inm@80array andGSMSGFmessage 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 (
sfl1orsfl2). - gscntr1: Container file (replaced
gscntrperjk02), 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
opntblsubroutine to execute file override commands. -
Parameters:
dbov##(override command string, 80 bytes),dbol##(length, 15.5). -
QMHRMVPM:
- Called in the
clrmsgsubroutine 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
bicuagand 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 tobicuaghfor 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
bicuaghwith 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
GorZfile 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!