BB001 RPG36
The BB001.rpg36.txt
is an RPG II program running on an IBM System/36, designed for Order Entry Batch Selection. It is called by the BB110P.ocl36
program to manage batch selection, creation, updating, and deletion for order entry processes, such as generating picking tickets. Below, I’ll explain the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the BB001 RPG Program¶
The program handles batch selection, creation, updating, and deletion through a series of subroutines and screen interactions. It uses the BBBTCH
and BBBTCHX
files to store batch information and manages user input via the SCREEN
workstation file. Here’s a step-by-step breakdown of the process:
- Initialization (Main Line):
- Lines 0065–0068: Resets indicators (50, 21, 22, 23, 24, 75, 76) and clears the
MSG
field to blanks, preparing for screen output and error handling. - Line 0070: Calls the
ONETIM
subroutine to perform one-time initialization tasks. -
Lines 0072–0074: Depending on the screen format (01, 02, or 03), calls subroutines
S1
,S2
, orS3
to handle specific user interactions. -
ONETIM Subroutine (Lines 0100–0114):
- Line 0102: Clears the
CANCEL
field and initializes counters (BLIM
,Z2
,Z7
,Z8
) to zero. - Line 0104: Positions the
BBBTCH
file at the beginning (SETLL
withBLIM
). - Line 0105: Calls
DRLFWD
to read the first batch record. - Line 0106: Sets indicators 21 and 83 for screen control.
-
Lines 0107–0112: Checks the
PGM
field (from LDA, offset 504):- If
PGM = 'O'
(Order Entry), clears indicator 44. - If
PGM ≠ 'O'
, sets indicator 44, indicating a different mode (e.g., posting or printing).
- If
-
S1 Subroutine (Lines 0116–0212) – Batch Selection or Creation:
- Lines 0119–0122: If the
KG
key (likely a cancel key) is pressed, setsCANCEL
to'CANCEL'
, sets the Last Record (LR) indicator, and exits toENDS1
. - Line 0124: Checks if
BTCH#X
(user-entered batch number) is zero, indicating a new batch creation. - New Batch Creation (Lines 0127–0166):
- If
PGM ≠ 'O'
, displays error message "CANNOT CREATE A BATCH NOW" (COM,2), sets indicators 90, 21, 51, and exits. - Otherwise, retrieves the next batch number (
ABNXTB
) fromBBBTCHX
(line 0136). - Increments
ABNXTB
, updates the file (EXCPTUPDNXB
), and handles overflow (ifABNXTB = 99
, resets to 1). - Sets fields for the new batch:
LKDESC
(description),PRTD = 'N'
(not printed),DATE
(creation date),LUDT
(last update date, initially zero),#REC
(record count, initially zero). - Checks if the batch number exists in
BBBTCHX
. If not, adds a new record (EXCPTADDBCH
) and sets LR to exit.
- If
-
Existing Batch Selection (Lines 0170–0209):
- If
BTCH#X ≠ 0
, setsBATCH# = BTCH#X
and retrieves the batch fromBBBTCHX
. - Validates:
- If the batch is deleted (
ABDEL = 'D'
) orBATCH# = 99
, displays error "INVALID BATCH NO." (COM,1) and exits. - If
ABLOCK = 'O'
andPGM = 'P'
, displays error "BATCH # IN USE--CANNOT POST NOW" (COM,5) and exits. - If
PAR13C ≠ ABSRCE
(batch source mismatch), displays error "INVALID BATCH NO." and exits (added 10/27/09). - If the batch is locked (
ABLOCK ≠ *BLANK
) and the user isn’t the one who locked it (ABUSER ≠ USER
), displays error "BATCH # IN USE--PLEASE CHOOSE ANOTHER" (COM,3), releases the batch (EXCPTRELBCH
), and exits. - If valid, retrieves batch fields (
LKDESC
,PRTD
,DATE
,LUDT
,#REC
) and updates the batch record (EXCPTUPDBCH
) if not deleted. - If
DEL = 'D'
, displays "CMD 4 - TO DELETE EXISTING BATCH" (COM,4) and prepares for deletion confirmation. - If
PGM = 'P'
, sets indicator 24 to indicate posting mode.
- If
-
S2 Subroutine (Lines 0214–0240) – Batch Confirmation or Deletion:
- Lines 0217–0227: If the
KA
key is pressed or deletion is not confirmed (DEL ≠ 'D'
), repositionsBBBTCH
withSETLL
, callsDRLFWD
to display the next batch, and exits toENDS2
. - Lines 0229–0232: If deletion is confirmed (
DEL = 'D'
andKD
key pressed), executesEXCPTDELBCH
to mark the batch as deleted and sets LR to exit. -
Lines 0235–0238: If a new batch number is provided, checks if it exists in
BBBTCHX
. If not, adds it (EXCPTADDBCH
) and sets LR. -
S3 Subroutine (Lines 0242–0254) – Reset or Cancel Batch:
- If the
KG
key is pressed, retrieves the batch (BATCH#
) fromBBBTCHX
. -
If found, saves the batch state (
EXCPTSAVBCH
), setsCANCEL = 'CANCEL'
, clears indicators, and sets LR to exit. -
DRLFWD Subroutine (Lines 0256–0308) – Display Forward Navigation:
- Reads the next record from
BBBTCH
and populates the display arrays (BTC
,LKD
,LKW
,PRT
,USR
,DTE
,LUD
,#RC
) for up to 10 records. - Skips deleted records (
ABDEL = 'D'
) or records whereABSRCE ≠ PAR13C
(batch source mismatch, added 10/20/17). - Sets lock status messages based on
ABLOCK
(e.g., "AVAILABLE", "ORD ENTRY", "PICK LIST", etc.). -
If no more records are found or batch number is 99, sets indicator 68 and repositions the file.
-
DRLBAK Subroutine (Lines 0323–0327) – Backward Navigation:
-
Sets indicator 21 and exits (minimal logic, suggesting backward navigation is not fully implemented).
-
DETCLR Subroutine (Lines 0310–0321) – Clear Display Arrays:
-
Resets the display arrays (
BTC
,LKD
,LKW
,PRT
,USR
,DTE
,LUD
,#RC
) to zeros or blanks. -
ROLLKY Subroutine (Lines 0079–0098) – Handle Roll Keys:
- Checks the
STATUS
field for roll key codes (01122 for forward, 01123 for backward). - Calls
DRLFWD
for forward scrolling orDRLBAK
for backward scrolling. -
Clears
STATUS
and resets indicator 09 after processing. -
Output Operations:
- SCREEN Output (Lines 0331–0370):
- Format
BB001S1
: Displays batch list with batch numbers, lock status, workstation ID, print status, user, dates, and record count. - Format
BB001S2
: Confirms batch details for update or deletion. - Format
BB001S3
: Displays batch details for reset/cancel. - BBBTCHX Output (Lines 0371–0403):
UPDNXB
: Updates the next batch number.ADDBCH
: Adds a new batch record withBATCH#
,PGM
,WSID
,PRTD
,USER
,DATE
,LUDT
,#REC
, andPAR13C
.UPDBCH
: Updates an existing batch withPGM
,WSID
, andLUDT
.DELBCH
: Marks a batch as deleted (DEL = 'D'
).RELBCH
: Releases a batch lock.SAVBCH
: Saves the batch lock status and workstation ID.
Business Rules¶
- Batch Creation:
- Only allowed in Order Entry mode (
PGM = 'O'
). - Uses the next available batch number (
ABNXTB
) fromBBBTCHX
, incrementing it and resetting to 1 if it reaches 99. -
New batches are initialized with
PRTD = 'N'
, zero records, and the current date. -
Batch Selection:
- Validates that the batch exists, is not deleted (
ABDEL ≠ 'D'
), and is not numbered 99. - Checks if the batch source (
ABSRCE
) matches the input parameterPAR13C
(e.g., 'PP' for viscosity ASN or non-'PP'). -
Ensures the batch is not locked (
ABLOCK = *BLANK
) or is locked by the current user (ABUSER = USER
). -
Batch Locking:
- If a batch is locked (
ABLOCK ≠ *BLANK
) and not by the current user, it cannot be accessed, and an error is displayed. -
Locked batches display specific statuses (e.g., "ORD ENTRY", "PICK LIST", "POSTING", "BOL PRINT").
-
Batch Deletion:
- Users can mark a batch for deletion by entering
DEL = 'D'
, which is confirmed via screen formatBB001S2
. -
Deletion updates the batch record with
ABDEL = 'D'
. -
Batch Source Validation (Added 10/27/09):
-
Ensures the batch source (
ABSRCE
) matches the input parameterPAR13C
to restrict access to batches of the correct type (e.g., 'PP' for viscosity ASN). -
Error Handling:
- Displays specific error messages for invalid batch numbers, locked batches, or attempts to create a batch outside Order Entry mode.
-
Uses
COM
array for standard messages (e.g., "INVALID BATCH NO.", "BATCH # IN USE"). -
Navigation:
- Supports forward scrolling through batch records, skipping deleted or mismatched records.
- Backward navigation is minimally implemented.
Tables (Files) Used¶
- SCREEN:
- Type: Workstation file (WORKSTN).
- Purpose: Displays batch selection, confirmation, and error messages to the user.
-
Formats:
BB001S1
(batch list),BB001S2
(batch confirmation/deletion),BB001S3
(batch reset/cancel). -
BBBTCH:
- Type: Indexed disk file (48 bytes, logical file, shared access).
- Purpose: Stores batch control data for reading and positioning.
-
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:
- Type: Indexed disk file (48 bytes, physical file, update-capable, shared access).
- Purpose: Stores and updates batch control data, including the next batch number.
- Fields: Same as
BBBTCH
.
External Programs Called¶
- None: The
BB001
program does not explicitly call any external RPG programs. It operates independently, relying on file operations and user interactions via theSCREEN
file.
Summary¶
The BB001
RPG program manages the selection, creation, updating, and deletion of order entry batches. It:
- Initializes and displays batch lists for user selection.
- Creates new batches in Order Entry mode, assigning unique batch numbers.
- Validates batch accessibility based on lock status and batch source.
- Supports batch deletion and updating, with error handling for invalid or locked batches.
- Uses subroutines (S1
, S2
, S3
, DRLFWD
, DRLBAK
, DETCLR
, ROLLKY
) to handle specific tasks.
Tables Used: SCREEN, BBBTCH, BBBTCHX. External Programs Called: None.