BB001 RPG36
Process Steps of the RPG Program (BB001.rpg36.txt)¶
This RPG III program (BB001) manages the selection, creation, viewing, updating, and deletion of order entry batches. It interacts with the user via workstation screens to handle batch operations before posting. The program is interactive, using screens for input/output and handling paging (roll keys) for batch lists. It is called from the main OCL procedure (BB201.ocl36.txt) in the "Order Batch Selection" section, with parameters from the LDA (local data area) like PAR13C (mode, e.g., 'PP' for Viscosity ASN Posts), USER, WSID, PGM ('O' for order entry mode?), and BATCH#.
The program executes in a loop based on screen indicators (01, 02, 03 for screens S1, S2, S3), with subroutines for initialization, screen handling, paging, and record operations. High-level process steps:
- Initialization (ONETIM Subroutine):
- Clears variables (e.g., CANCEL to blanks, BLIM to 0 for batch limit).
- Positions to the first record in BBBTCH using SETLL with BLIM.
- Calls DRLFWD to load initial batch data for display.
- Sets indicators (83 on for initial roll, 44 off if PGM = 'O' for order entry mode, else on).
-
Runs only once (controlled by 09 off).
-
Main Loop and Screen Handling:
- Clears indicators (50, 21-24 off) and MSG (message field) at each iteration.
- Handles cancel: If CANCEL = 'CANCEL' (from KG key or input), sets LR on and exits.
- Screen 1 (S1 Subroutine):
- Displays input screen for batch# (BTCH#X).
- Validates input: If BTCH#X = 0 (blank/new), proceeds to create new batch.
- Checks for existing batch: Chains to BBBTCHX using batch#.
- If exists: Loads details (lock status, user, dates, record count), displays locked description (from COM array based on ABLOCK: blank='AVAILABLE', 'O'='ORD ENTRY', 'L'='PICK LIST', 'B'='BOL PRINT', 'P'='POSTING').
- Handles delete input (DEL = '4'): Marks ABDEL = 'D', updates BBBTCHX.
- If locked/in use: Displays error message (e.g., COM,03: 'BATCH # IN USE--PLEASE CHOOSE ANOTHER').
- Screen 2 (S2 Subroutine): Displays detailed batch info (batch#, lock desc, WSID, printed status, user, create/update dates, record count). Allows updates (e.g., lock changes).
-
Screen 3 (S3 Subroutine): Similar to S2 but for confirmation or additional views.
-
Paging and Data Loading (ROLLKY, DRLFWD, DRLBAK Subroutines):
- Handles roll keys: STATUS 01122 for forward (75 on), 01123 for backward (76 on).
- Forward (DRLFWD): Reads next 10 batches from BBBTCH (loop X=1 to 10), skips deleted (ABDEL='D') or mismatched source (ABSRCE != PAR13C per comment, but revised 10/20/17 to strict != skip).
- Loads arrays (BTC, LKD, LKW, PRT, USR, DTE, LUD, #RC).
- Converts dates (ABDATE/ABLUDT * 100.0001 to MDY).
- Sets 23 if <10 records loaded.
- Backward (DRLBAK): Sets 21 on, tags BAKEND (minimal logic, likely positions to prior records via SETLL).
-
Clears detail arrays (DETCLR) before loading.
-
Batch Creation (In S1):
- If new (BTCH#X=0 and not exists): Adds record to BBBTCHX (EADD UPDNXB).
- Sets defaults: ABDEL blank, ABBTCH='99' (next?), ABLOCK='X', ABLKWS='XX', ABPRTD, ABUSER=USER, ABDATE=DATE (CYMD), ABLUDT, ABREC=0, ABSRCE=PAR13C (JB01), ABNXTB=Z2.
- Writes with EADD ADDBCH (batch#, PGM, WSID, PRTD, USER, DATE, LUDT, #REC, PAR13C, Z2).
-
If cannot create (locked): Error message (COM,02: 'CANNOT CREATE A BATCH NOW').
-
Batch Update/Delete (In S1/S2):
- Update: Chains to BBBTCHX, updates fields (e.g., lock via SAVBCH: SVLOCK/ABLOCK, SVLKWS/ABLKWS; UPDBCH: PGM, WSID, LUDT).
- Delete: If DEL='4' and not locked, sets ABDEL='D', updates via DELBCH (DEL='D').
-
Release: Via RELBCH (no fields shown, likely clears lock).
-
End of Processing:
- Exits on cancel (LR on) or user confirmation.
- Outputs selected batch# to LDA (BATCH# field).
Business Rules¶
- Batch Creation: Only if not exists and not locked. Sets initial lock 'X', source from PAR13C (JB01: e.g., 'PP' mode). Cannot create if in use (error COM,02).
- Batch Selection/Validation:
- Existing batch must match source (ABSRCE = PAR13C, revised 10/20/17 to skip mismatches).
- Locked batches: Display status (LKD from COM based on ABLOCK), cannot post if locked (COM,05), cannot delete if locked/in use.
- Deletion: Requires CMD 4 (DEL='4'), only if not deleted (ABDEL!='D') and not locked. Marks 'D' (soft delete), skips deleted in displays.
- Locking: Statuses: blank (available), 'O' (order entry), 'L' (pick list), 'B' (BOL print), 'P' (posting). Updates save prior lock (SVLOCK/SVLKWS).
- Paging/Display: Loads 10 batches at a time (X=1-10), skips deleted/mismatched. Dates in CYMD converted to MDY for display. Record count (#RC=ABREC).
- Modes: PGM='O' hides some fields (44 off). PAR13C filters batches (e.g., 'PP' skips non-'PP').
- Errors: Standard messages from COM array (e.g., invalid batch COM,01; in use COM,03; delete prompt COM,04).
- No Hard Deletes: Uses soft delete ('D'), archives/purges likely elsewhere.
Tables Used (Files)¶
Files are workstation or disk, with keyed access (AI for alternate index).
- SCREEN: Combined primary (CP), 600 bytes, workstation file for interactive display/input. Uses WSID, INFDS STAT for status, INFSR ROLLKY for roll keys.
- BBBTCH: Input (ID), 48 bytes, record address (L 2AI), disk file for batch records (indexed read).
- BBBTCHX: Update combined (UC), 48 bytes, record address (R 2AI), disk file for batch updates/adds (same as BBBTCH but update-capable).
External Programs Called¶
None. The program does not call any external programs (no CALL opcodes). It relies on internal subroutines (e.g., ONETIM, S1, DRLFWD) and file operations.