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
BBIBCH
file as an update file (48 bytes, indexed, key length 2 bytes, disk-based). - Input specifications (
I
) map fields from theBBIBCH
file and the User Data Structure (UDS
):KYALSL
(positions 103–105): Batch selection criteria (ALL
or 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 theBBIBCH
file. -
Chain to Batch Record:
- The program uses the
BATCH#
to perform aCHAIN
operation on theBBIBCH
file to locate the batch record. -
If the record is not found (indicator
99
on), the program skips processing and proceeds to termination. -
Process Based on Program Code (
PGM
): -
If the batch record is found (indicator
99
off), the program evaluates thePGM
field:- If
PGM = 'I'
(Invoice Entry): - Writes an exception record (
REL
) to update theBBIBCH
file, clearing positions 6–8 and updatingRECCNT
. - If
PGM = 'E'
(Edit): - Writes an exception record (
EDIT
) to update theBBIBCH
file, 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
RTOPST
to'N'
.
- If
- Writes an exception record (
FORM
) to update theBBIBCH
file, 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
PGM
value: - 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 theBBIBCH
file for processing to occur. -
If the batch is not found, no updates are performed.
-
Program Code Processing:
-
The
PGM
field 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
BB500
order 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 inFORM
output).
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.