BB001 RPG36
The BB001.rpg36.txt
document is an RPG III (System/36 style) program called from the BB101.ocl36.txt
OCL program in an IBM System/36 or AS/400 (now IBM i) environment. It handles the selection and management of order entry batches, stored in the BBBTCH
and BBBTCHX
files, allowing users to create, select, update, or delete batches. Below is a detailed explanation of the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG Program¶
The BB001
RPG program manages the batch selection process for order entry through interactive screen processing and file operations. It supports creating new batches, selecting existing ones, updating batch details, and deleting batches, with validations to ensure proper batch handling. The process steps are organized around screen interactions and subroutines, as follows:
- Program Initialization:
- The program is defined with a header specification (
H P064
) and is identified asBB001
. - It uses the
SCREEN
workstation file for interactive display (record length 600, withWSID
,STAT
, andROLLKY
for workstation ID, status, and roll key handling). - Files
BBBTCH
(input, disk, 48 bytes, indexed) andBBBTCHX
(update-capable, disk, 48 bytes, indexed) are defined for batch data storage. -
Arrays and data structures are defined:
COM
: 15-element array for standard messages (42 bytes each).BTC
: 10-element array for batch numbers (2 digits).LKD
: 10-element array for lock descriptions (10 bytes).LKW
: 10-element array for locked workstation IDs (2 bytes).PRT
: 10-element array for BOL printed flags (1 byte).USR
: 10-element array for user IDs (8 bytes).DTE
: 10-element array for creation dates (6 digits).LUD
: 10-element array for last update dates (6 digits).#RC
: 10-element array for record counts (8 digits).STAT
: Data structure for status tracking (STATUS
field).UDS
: User data structure for local data area fields (KYHDG
,CANCEL
,PAR13C
,BATCH#
,USER
,WSID
,PGM
,RECCNT
).
-
Main Line Processing:
- Initializes indicators (50, 21, 22, 23, 24, 75, 76) to off and clears the
MSG
field (N75N76
conditions, lines 0065-0068). - Executes the
ONETIM
subroutine on indicator 09 to perform one-time setup (line 0070). -
Processes one of three screens based on indicators:
- Screen 1 (
S1
, indicator 01, line 0072). - Screen 2 (
S2
, indicator 02, line 0073). - Screen 3 (
S3
, indicator 03, line 0074).
- Screen 1 (
-
Screen Processing:
- Screen 1 (BB001S1, Output: 21, Line 0331):
- Displays batch selection data, including heading (
KYHDG
), batch numbers (BTC
), lock descriptions (LKD
), locked workstation IDs (LKW
), BOL printed flags (PRT
), user IDs (USR
), creation dates (DTE
), last update dates (LUD
), record counts (#RC
), input batch number (BTCH#X
), delete code (DEL
), and message (MSG
). - Accepts input for
BTCH#X
(batch number, positions 3-40) andDEL
(delete code, position 5).
- Displays batch selection data, including heading (
- Screen 2 (BB001S2, Output: 22, Line 0346):
- Displays batch details for confirmation, including batch number (
BATCH#
), lock description (LKDESC
), workstation ID (WSID
), BOL printed flag (PRTD
), user ID (USER
), creation date (DTMDY
), last update date (LUMDY
), record count (#REC
), and message (MSG
).
- Displays batch details for confirmation, including batch number (
-
Screen 3 (BB001S3, Output: 24, Line 0359):
- Similar to Screen 2 but used for resetting or canceling batch operations.
-
Subroutines:
- ROLLKY (Lines 0079-0098):
- Handles roll key processing for navigating batch records.
- Clears indicators (21, 22, 23, 24, 50) and checks
STATUS
for roll forward (01122, indicator 75) or roll backward (01123, indicator 76). - Calls
DRLFWD
for forward navigation (indicator 75, 83) orDRLBAK
for backward navigation (indicator 76, 83). - Clears
STATUS
and resets indicator 09.
- ONETIM (Lines 0100-0114):
- Performs one-time initialization:
- Clears
CANCEL
and initializes counters (BLIM
,Z2
,Z7
,Z8
). - Positions
BBBTCH
file at the beginning (SETLL
, line 0104). - Calls
DRLFWD
to load initial batch records. - Sets indicators 21 and 83.
- Sets indicator 44 based on
PGM
value ('O' for order entry clears 44, otherwise sets 44).
- S1 (Lines 0116-0212):
- Handles Screen 1 processing:
- If command key KG (cancel) is pressed, sets
CANCEL
to 'CANCEL', sets last record indicator (LR
), and exits toENDS1
(lines 0119-0122). - For new batch creation (
BTCH#X=0
, indicator 40, lines 0124-0167):- Checks if
PGM
is not 'O' (order entry); if so, displays error message "CANNOT CREATE A BATCH NOW" (COM,2) and sets indicators 90, 21, 51. - Retrieves next batch number (
ABNXTB
) fromBBBTCHX
(chain on '99', line 0136). - Increments
ABNXTB
and resets to 1 if it reaches 99 (lines 0137-0141). - Updates
BBBTCHX
with new batch number (EXCPTUPDNXB
, line 0142). - Initializes batch fields: lock description (
LKDESC
=COM,11), BOL printed (PRTD='N'
), creation date (DTMDY
,DATE
), last update date (LUMDY
,LUDT
=0), record count (#REC
=0). - Checks if batch number exists (
CHAIN BBBTCHX
, line 0156); if not, adds new batch record (EXCPTADDBCH
, line 0162) and setsLR
.
- Checks if
- For existing batch selection (
BTCH#X<>0
, lines 0169-0209):- Chains to
BBBTCHX
withBATCH#
(line 0174). - Validates batch: if deleted (
ABDEL='D'
) orBATCH#=99
, displays error "INVALID BATCH NO." (COM,1) and sets indicators 90, 21, 51. - For
PP
program (PGM='P'
), checks if batch is locked for order entry (ABLOCK='O'
); if so, displays error "BATCH # IN USE--CANNOT POST NOW" (COM,5). - Validates batch source (
PAR13C
vs.ABSRCE
, JB01, 10/27/09); if mismatched, displays error "INVALID BATCH NO." and sets indicators 51, 90, 21. - Checks if batch is locked (
ABLOCK<>blank
); if locked by different user (ABUSER<>USER
), displays error "BATCH # IN USE" (COM,3), releases batch (EXCPTRELBCH
), and exits. - If user matches (
ABUSER=USER
, MG01), bypasses lock check. - Initializes fields for update: lock description, BOL printed, dates, and record count.
- If delete is requested (
DEL='D'
, indicator 52), displays confirmation message (COM,4) and sets indicators 90, 22. - Updates batch record (
EXCPTUPDBCH
) unlessPGM='P'
, then sets indicator 24 and exits.
- Chains to
- S2 (Lines 0214-0240):
- Handles Screen 2 processing:
- On KA key press, repositions
BBBTCH
file (SETLL
), sets indicators 83, 21, 09, and callsDRLFWD
. - On delete confirmation (
DEL='D'
, indicator 52, KD key), sets update indicator (U1
), deletes batch (EXCPTDELBCH
), and setsLR
. - For new batch record, checks if batch exists (
CHAIN BBBTCHX
); if not, adds it (EXCPTADDBCH
) and setsLR
.
- S3 (Lines 0242-0254):
- Handles Screen 3 processing:
- On KG key press, chains to
BBBTCHX
withBATCH#
; if found, saves batch (EXCPTSAVBCH
), clears indicators (01, 02, 03, 09), setsCANCEL='CANCEL'
, and setsLR
.
- DRLFWD (Lines 0256-0308):
- Reads forward through
BBBTCH
to populate batch arrays for display: - Initializes counter (
X=1
) and clears arrays (DETCLR
). - Reads records, skipping deleted (
ABDEL='D'
) or invalid (ABBTCH=99
) batches. - Validates batch source (
ABSRCE
vs.PAR13C
, 10/20/17); skips mismatches. - Sets lock description based on
ABLOCK
value ('O', 'L', 'B', 'P', or blank, using COM messages 11-15). - Populates arrays (
BTC
,LKD
,LKW
,PRT
,USR
,DTE
,LUD
,#RC
) for up to 10 records. - Sets indicator 68 if end-of-file is reached and repositions file if necessary.
- Reads forward through
- DRLBAK (Lines 0323-0327):
- Handles backward navigation by setting indicator 21.
-
DETCLR (Lines 0310-0321):
- Clears batch arrays (
BTC
,LKD
,LKW
,PRT
,USR
,DTE
,LUD
,#RC
) to zero or blanks.
- Clears batch arrays (
-
File Operations:
- UPDNXB (Lines 0371-0377):
- Updates or adds the next batch number (
ABNXTB
) inBBBTCHX
.
- Updates or adds the next batch number (
- RELBCH (Line 0379):
- Releases a locked batch.
- DELBCH (Line 0381):
- Marks a batch for deletion by setting
DEL
inBBBTCHX
.
- Marks a batch for deletion by setting
- ADDBCH (Lines 0384-0393):
- Adds a new batch record to
BBBTCHX
with fields:BATCH#
,PGM
,WSID
,PRTD
,USER
,DATE
,LUDT
,#REC
,PAR13C
(JB01), andZ2
.
- Adds a new batch record to
- UPDBCH (Lines 0395-0399):
- Updates batch record with
PGM
,WSID
, andLUDT
.
- Updates batch record with
- SAVBCH (Lines 0401-0402):
- Saves batch lock status (
SVLOCK
,SVLKWS
).
- Saves batch lock status (
Business Rules¶
The program enforces several business rules to ensure proper batch management:
- Batch Number Validation:
- Batch numbers must be valid and not equal to 99 (error 01, "INVALID BATCH NO.").
- Deleted batches (
ABDEL='D'
) cannot be selected (error 01). -
Batch source (
ABSRCE
) must matchPAR13C
(e.g., 'PP' for product moves or viscosity ASN entry, JB01, 10/27/09); mismatches trigger error 01. -
Batch Creation:
- New batches can only be created in order entry mode (
PGM='O'
); otherwise, error 02 ("CANNOT CREATE A BATCH NOW") is displayed. - Next batch number is retrieved from
BBBTCHX
(key '99') and incremented, resetting to 1 if it reaches 99. -
New batch records are initialized with:
PRTD='N'
(BOL not printed).- Creation date (
DATE
) set to current date (UDATE
). - Last update date (
LUDT
) and record count (#REC
) set to 0. - Batch source (
PAR13C
) written toABSRCE
(JB01).
-
Batch Locking:
- If a batch is locked (
ABLOCK<>blank
) and the user (ABUSER
) does not match the current user (USER
), error 03 ("BATCH # IN USE") is displayed, and the batch is released. - If the user matches the lock owner (
ABUSER=USER
, MG01), access is granted. -
For
PP
program (PGM='P'
), locked batches (ABLOCK='O'
) trigger error 05 ("BATCH # IN USE--CANNOT POST NOW"). -
Batch Deletion:
- Deletion requires confirmation on Screen 2 (
DEL='D'
, message COM,4: "CMD 4 - TO DELETE EXISTING BATCH"). -
Deleted batches are marked with
DEL
inBBBTCHX
. -
Navigation and Display:
- Only non-deleted batches with matching
ABSRCE
are displayed. - Lock status is displayed using descriptions from
COM
(11: AVAILABLE, 12: ORD ENTRY, 13: PICK LIST, 14: POSTING, 15: BOL PRINT). -
Up to 10 batch records are loaded into arrays for display on Screen 1.
-
Cancel and Reset:
- Pressing KG (cancel) sets
CANCEL='CANCEL'
and exits the program. - Screen 3 resets batch records and cancels operations if KG is pressed.
Tables (Files) Used¶
The program interacts with the following files:
- SCREEN: Workstation display file for interactive screens (BB001S1, BB001S2, BB001S3).
- BBBTCH: Batch header file (input, 48 bytes, indexed, key fields: 1-2).
- Fields:
ABDEL
(delete code),ABBTCH
(batch number),ABLOCK
(lock status),ABLKWS
(lock workstation ID),ABPRTD
(BOL printed),ABUSER
(user ID),ABDATE
(creation date),ABLUDT
(last update date),ABREC
(record count),ABSRCE
(batch source),ABNXTB
(next batch number). - BBBTCHX: Update-capable batch header file (48 bytes, indexed, key fields: 1-2).
- Same fields as
BBBTCH
.
External Programs Called¶
The BB001
RPG program does not explicitly call any external programs. All processing is handled internally through subroutines and file operations.
Summary¶
The BB001
RPG program, called from the BB101.ocl36.txt
OCL program, manages the selection, creation, updating, and deletion of order entry batches stored in BBBTCH
and BBBTCHX
. It uses three screens (S1, S2, S3) for user interaction, supports navigation via roll keys, and enforces business rules such as batch number validation, lock checking, and program mode restrictions. The program initializes new batches with the next available number, ensures only authorized users can access locked batches, and prevents invalid operations like creating batches outside order entry mode. It interacts with the SCREEN
, BBBTCH
, and BBBTCHX
files and does not call external programs, relying on internal subroutines for all processing.