BB055 RPG36
The BB055.rpg36.txt is an RPG/36 program called from the BB502.ocl36.txt OCL program and referenced in the BB502.rpg36.txt program (in the BPOST subroutine). It is designed to release or post a batch of records in the BBIBCH file, updating the batch status based on the program code (PGM) and other conditions. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPG source code.
Process Steps of the RPG Program¶
The BB055 program processes a batch identified by a batch number (BATCH#) and updates the BBIBCH file based on the program code (PGM) and batch selection criteria (KYALSL). It performs actions such as releasing, editing, marking for forms printing, or posting the batch. Here’s a step-by-step breakdown of the process:
- Program Initialization:
- The program defines the
BBIBCHfile as an update file (48 bytes, indexed, key length 2 bytes, disk-based). - Input specifications (
I) map fields from theBBIBCHfile and the User Data Structure (UDS):KYALSL(positions 103–105): Batch selection criteria (ALLor other values).BATCH#(positions 490–491, 2 digits): Batch number.PGM(position 504, 1 character): Program code (I,E,F, orP).RECCNT(positions 475–482, 8 digits): Record count in the batch.
-
Output specifications (
O) define four exception output operations (REL,EDIT,FORM,POST) to update theBBIBCHfile. -
Chain to Batch Record:
- The program uses the
BATCH#to perform aCHAINoperation on theBBIBCHfile to locate the batch record. -
If the record is not found (indicator
99on), the program skips processing and proceeds to termination. -
Process Based on Program Code (
PGM): -
If the batch record is found (indicator
99off), the program evaluates thePGMfield:- If
PGM = 'I'(Invoice Entry): - Writes an exception record (
REL) to update theBBIBCHfile, clearing positions 6–8 and updatingRECCNT. - If
PGM = 'E'(Edit): - Writes an exception record (
EDIT) to update theBBIBCHfile, clearing positions 6–8 and updatingRECCNT. - If
PGM = 'F'(Forms): - Checks the batch selection criteria (
KYALSL):- If
KYALSL = 'ALL', setsRTOPST(ready to post) to'Y'. - Otherwise, sets
RTOPSTto'N'.
- If
- Writes an exception record (
FORM) to update theBBIBCHfile, setting position 9 to'Y', updatingRECCNT, and settingRTOPST. - If
PGM = 'P'(Post): - Checks the record count (
RECCNT):- If
RECCNT = 0(all records posted), writes an exception record (POST), setting position 1 to'D'(delete), position 6 to'P'(posted), and updatingRECCNT. - Otherwise, writes an exception record (
REL), clearing positions 6–8 and updatingRECCNT.
- If
- For any other
PGMvalue: - Writes an exception record (
REL), clearing positions 6–8 and updatingRECCNT.
- If
-
Program Termination:
- The program sets the
LR(Last Record) indicator and ends, completing the batch update.
Business Rules¶
The program enforces the following business rules, inferred from the code and context:
- Batch Validation:
- The batch number (
BATCH#) must exist in theBBIBCHfile for processing to occur. -
If the batch is not found, no updates are performed.
-
Program Code Processing:
-
The
PGMfield determines the action:I: Indicates invoice entry, releasing the batch.E: Indicates edit processing, updating the batch status.F: Marks the batch for forms printing, setting readiness to post based on selection criteria.P: Posts the batch, marking it as deleted if all records are processed (RECCNT = 0).- Other values default to releasing the batch.
-
Forms Printing and Posting Readiness:
-
For
PGM = 'F', if all orders are selected (KYALSL = 'ALL'), the batch is marked ready to post (RTOPST = 'Y'); otherwise, it is marked not ready (RTOPST = 'N'). -
Batch Posting:
- For
PGM = 'P', the batch is marked as deleted ('D') and posted ('P') only if all records are processed (RECCNT = 0). -
If records remain (
RECCNT ≠ 0), the batch is released without marking it as posted. -
Integration with Order Entry:
-
The program is part of the
BB500order entry suite (called byBB502) and manages batch status updates for shipment processing, ensuring batches are properly released, edited, printed, or posted. -
Error Handling:
- If the batch record is not found, the program exits without error, relying on the calling program to handle the absence of a batch.
Tables (Files) Used¶
The program uses one file, as defined in the F (File) specification:
- BBIBCH: Batch control file (48 bytes, indexed, update-capable, key length 2 bytes). Contains fields:
KYALSL(batch selection criteria, e.g.,ALL).BATCH#(batch number).PGM(program code:I,E,F,P).RECCNT(record count).RTOPST(ready to post flag, used inFORMoutput).
External Programs Called¶
The program does not call any external programs. It is a self-contained utility that performs file updates based on input parameters and internal logic.
Summary¶
The BB055 RPG/36 program is a utility called from the BB502 OCL program to release or post batches in the BBIBCH file. It updates batch status based on the program code (PGM): releasing for invoice entry (I) or edit (E), marking for forms printing (F) with readiness to post based on KYALSL, or posting (P) if all records are processed (RECCNT = 0). The program uses one file (BBIBCH) and does not call external programs, ensuring proper batch management for order entry and shipment processing.
If you need further details on specific logic, integration with BB502, or additional analysis (e.g., X posts or web searches), let me know! Additionally, if you want to update the previous use cases or function requirement document to include BB055, please specify, and I can incorporate its functionality.