BB955 RPGLE 1
The provided document is an RPGLE program named BB955.rpgle
, which is called from the OCL program BB955.ocl36.txt
for "Rack Price File Maintenance" in the Bradford Order Entry / Invoices system. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPGLE code. Since the code is truncated, the analysis covers the available portion, focusing on the main program flow, subroutines, and key logic.
Process Steps of the RPGLE Program¶
The BB955
program is an interactive RPGLE program that maintains rack price data, allowing users to view, update, add, or delete pricing records via a subfile-based display. It uses a workstation file (bb955d
) for user interaction and manages data in a work file (bb955w
) and primary price file (bbprce
). The program follows these high-level steps:
- Program Initialization:
- Open Database Tables: The subroutine
opntbl
is executed to open the necessary files (bb955d
,bicont
,gscntr1
,gsctum
,gsprod
,gstabl
,inloc
,bbprcw
,bb955w
,bbprce
,bbprceh
). These files are opened with theUSROPN
keyword, indicating they are explicitly opened by the program. - Retrieve Initial Data: The
rtvdta
subroutine retrieves data based on the parameter passed from the OCL program ('?9?'
), likely initializing key fields or setting up the environment. -
Subfile Processing: The main logic is handled by the
srsfl1
subroutine, which manages the subfile (sfl1
) for displaying and editing rack price records. -
Subfile Processing (
srsfl1
Subroutine): - Initialize Subfile: The subfile is set to "folded" mode (
sfmod1 = '1'
,*IN45 = *ON
), controlling how data is displayed (folded or unfolded). The message subfile is cleared (clrmsg
), and function key labels are set (s1f06d
,s1f08d
). - Main Loop (
sf1agn
): The program enters a loop to handle user interaction:- Reposition Subfile: If the
repsfl
flag is set, thesf1rep
subroutine repositions the subfile based on user filters (e.g., company number, location, product). - Condition Function Keys: The program checks for subfile records (
rrn1
) to enable/disable function keys (e.g., F7 for accepting changes,*IN78
). - Display Subfile: The subfile control record (
sflctl1
) is displayed usingEXFMT
, allowing user input. The subfile display is conditioned (*IN41
) based on whether records exist. - Handle Folded/Unfolded Mode: The display toggles between folded (
*IN45 = *OFF
) and unfolded modes based onsfmod1
and whether multiple quantities exist (w$mltqty
). - Cursor Positioning: The cursor is positioned to the effective date field for new records (
*IN77
) if no errors are present.
- Reposition Subfile: If the
-
Process User Input:
- F3 (Exit): Exits the loop (
sf1agn = *OFF
). - F4 (Prompt): Calls the
prompt
subroutine to assist with field input. - F5 (Refresh): Triggers subfile repositioning (
repsfl = *ON
). - F6 (Toggle Update): Toggles whether existing records can be updated (
s1alwupd
), updating the function key label (s1f06d
). - F8 (Toggle Deleted Records): Toggles whether deleted records are shown (
s1showdel
), updating the function key label (s1f08d
). - F9 (History Inquiry): Calls the external program
GB730P
with parameters (x$custhist
) to display historical data for the selected subfile record. - F10 (Position Cursor): Clears cursor coordinates (
row1
,col1
) to reposition to the control record. - F23 (Delete/Restore): Processes deletion or restoration of a subfile record (
sf1del
,sf1fmt
,sf1pro
), updates the subfile, and setsSFLNXTCHG
(*IN44
). - User Filters: If control fields (e.g.,
c1cono
,c1loc
,c1prod
) differ from saved values, the subfile is repositioned (sf1rep
). - New Record Input: If the effective date (
c1emdy
) or location fields (loc
) change, thesf1ctenew
subroutine validates new record input. - Enter/F7 (Accept Changes): Processes subfile changes (
sf1prc
) or accepts changes (sf1f07
) if no errors are present (w$sflerr = *OFF
).
- F3 (Exit): Exits the loop (
-
Subfile Record Processing (
sf1prc
Subroutine): - Reads changed subfile records (
READC sfl1
) and processes them viasf1chg
. -
Sets the
s1chng
flag to indicate changes and checks for errors (w$sflerr
). -
Process Subfile Changes (
sf1chg
Subroutine): - Edits subfile input (
sf1edt
) to validate fields. -
Updates the database (
sf1upd
) if no errors are present (*IN50 = *OFF
). -
Update Database (
sf1upd
Subroutine): - Chains to the work file (
bb955w
) using key fields (klsfl1
). - Updates existing fields (
w1prce
,w1pr02
, etc.) and new fields (n1prce
,n1pr02
, etc.) in the work file. -
Copies data to history fields (
h1prce
,h1pr01
) for logging. -
Accept Changes (
sf1f07
Subroutine): - Checks for new records in the work file (
bb955w
) by scanning for non-zero/non-blank values (n1minq
,n1rkrq
, etc.). - Validates the effective date (
c1emdy
) for new records, displaying an error (ERR0020
) if missing. - Displays a confirmation window (
f07wrn
) and processes user input:- F12: Cancels the update (
winagn = *OFF
). - F22: Triggers the database update (
sf1f07upd
).
- F12: Cancels the update (
-
Clears the subfile and work file, calls
BB955AC
to recreate the work file, and resets filters. -
Update Database for F7 (
sf1f07upd
Subroutine): - Reads the work file (
bb955w
) and skips records marked as deleted (w1del = 'D'
). - Updates existing records in
bbprce
by comparing fields (w1prce
vs.rkprce
, etc.) and writing changes if differences exist. Callswritehist
to log changes tobbprceh
. - Adds new records for the new effective date (
c1edat
) if non-zero/non-blank values exist. Restores deleted records (rkdel = 'A'
) if applicable. -
Calls
updadlloc
andaddadlloc
to handle additional locations. -
Update Additional Locations (
updadlloc
Subroutine): - Loops through 10 additional locations (
loc
array). -
Updates existing records in
bbprce
for each non-blank location, comparing and updating fields as needed. Logs changes viawritehist
. -
Add Additional Locations (
addadlloc
Subroutine): - Loops through 10 additional locations (
loc
array). -
Adds new records to
bbprce
for non-blank locations with the new effective date (c1edat
). Logs changes viawritehist
. -
Reposition Subfile (
sf1rep
Subroutine):- Checks if user filters have changed (e.g.,
c1cono
vs.r$cono
). - If the work file is open and contains records, warns the user of unprocessed changes (
bldwrkfwrn
). - Clears the subfile (
sf1clr
), validates control fields (sf1cte
), rebuilds the work file (bldwrkf
) if needed, and loads all records (sf1lodall
).
- Checks if user filters have changed (e.g.,
-
Program Termination:
- Closes all files (
CLOSE *ALL
). - Sets
*INLR = *ON
to indicate the program is complete and returns control to the calling OCL program.
- Closes all files (
Business Rules¶
The program enforces several business rules for maintaining rack price data:
- Display Validation: The OCL program checks for a 27X132
display condition, and if present, prevents execution, indicating a compatibility issue.
- Subfile Management: The subfile supports viewing, updating, adding, and deleting records. Users can toggle between showing/hiding deleted records (s1showdel
) and allowing/preventing updates to existing records (s1alwupd
).
- Data Validation: Input fields (e.g., quantities s1qt
, prices s1pr
, new quantities n$qt
, new prices n$pr
) are validated (sf1edt
, sf1ctenew
) to ensure data integrity.
- Effective Date Requirement: New records require a valid effective date (c1emdy
). If missing, an error (ERR0020
) is displayed.
- History Logging: Changes to bbprce
are logged to bbprceh
via the writehist
subroutine (added in revision JK01
).
- Additional Locations: The program supports up to 10 additional locations (loc
array), updating or adding records for each non-blank location.
- Deleted Records: Records marked as deleted (rkdel = 'D'
) can be restored (rkdel = 'A'
) or excluded based on the s1showdel
toggle. Inactive records in gsctum
, gsctwt
, and gsumcv
are treated as deleted (revision JB05
).
- Work File Management: The work file (bb955w
) is recreated via BB955AC
and cleared after updates to ensure data consistency.
- Error Handling: Errors are displayed in a message subfile (m@msgf = 'GSMSGF'
), with indicators (*IN50
to *IN69
) flagging specific field errors.
- Currency: The program assumes prices are in U.S. dollars (c#US$ = 'U.S. Dollars'
).
Tables Used¶
The program uses the following files (tables), as defined in the file specifications:
1. bb955d: Workstation file (display file) with a subfile (sfl1
) for user interaction. Used for input/output via the display.
2. bicont: Input-only file, likely containing control or configuration data.
3. gscntr1: Input-only file, used for country or center data (replaced gscntr
in revision JK03
for an alpha key).
4. gsctum: Input-only file, possibly containing customer or unit master data (treated as deleted if inactive, per JB05
).
5. gsprod: Input-only file, containing product master data.
6. gstabl: Input-only file, likely a general table for reference data.
7. inloc: Input-only file, containing location data.
8. bbprcw: Input-only file, a renamed version of bbprcepf
(bbprcepw
) for reading price data.
9. bb955w: Update file (work file) in QTEMP
(revision jk04
), used to stage changes before updating the main price file.
10. bbprce: Update file, the primary file for rack price data.
11. bbprceh: Output file, used to log historical price changes (added in revision JK01
).
External Programs Called¶
The program calls the following external programs:
1. GB730P: Called when the F9 key is pressed to display historical data for a selected subfile record. Parameters are passed via the x$custhist
data structure.
2. BB955AC: Called to create or clear the work file (bb955w
) after updates, passing the file group parameter (p$fgrp
to o$fgrp
).
Additional Notes¶
- Truncated Code: The provided code is truncated, omitting subroutines like
opntbl
,rtvdta
,sf1edt
,sf1del
,sf1fmt
,sf1pro
,sf1cte
,sf1lodall
,bldwrkf
,bldwrkfwrn
,clrmsg
,wrtmsg
,addmsg
, andwritehist
. These likely handle specific tasks like file opening, data retrieval, validation, deletion logic, and history logging. If you have the full code, I can provide a more detailed analysis. - Revisions: The program has been updated to add history logging (
JK01
), fix a company number field issue (JB02
), update timestamps (JK02
), switch togscntr1
(JK03
), handle inactive records (JB05
), and overridebb955w
toQTEMP
(jk04
). - Subfile Design: The subfile (
sfl1
) supports up to four quantity/price pairs (s1qt
,s1pr
,n$qt
,n$pr
) and additional locations (loc
), with fields for company number, product, country, unit of measure, effective date, and more. - Parameter from OCL: The
'?9?'
parameter from the OCL program is not explicitly referenced in the provided code but likely influences thertvdta
subroutine’s behavior.
If you have the full RPGLE code or specific questions about a subroutine, please share them, and I can provide a more comprehensive explanation. Additionally, I can use DeepSearch to gather context about AS/400 RPG conventions or related systems if needed. Let me know how you’d like to proceed!