BB055 RPG36
The BB055.rpg36.txt
RPG program is called by the main OCL program (likely BB600.ocl36.txt
) within the invoice posting workflow on an IBM System/36 environment. Its primary function is to manage the release or posting of batches by updating the batch control file (BBIBCH
) based on the program mode (PGM
) and batch status. The program handles different batch processing stages (invoice entry, edit, forms, and posting) and updates the batch record accordingly. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BB055 RPG Program¶
The BB055
program processes a batch record in BBIBCH
, updates its status based on the input program mode (PGM
), and handles specific logic for forms and posting stages.
- File Initialization:
- Opens the following file:
- BBIBCH: Update file (
UF
), 48 bytes, 2-byte alternate index, 2-byte key, disk-based. Stores batch control records.
- BBIBCH: Update file (
-
Defines input fields for
BBIBCH
:KYALSL
(103–105): Selection criteria (ALL
or company-specific).BATCH#
(490–491): Batch number (numeric).PGM
(504): Program mode (I
,E
,F
,P
for invoice entry, edit, forms, or post).RECCNT
(475–482): Record count (numeric).RTOPST
(defined in output, 1 character): Ready-to-post flag (Y
orN
).
-
Batch Record Retrieval:
- Chains to
BBIBCH
usingBATCH#
as the key (C BATCH# CHAINBBIBCH 99
). -
If the record is found (
N99
), proceeds with processing; otherwise, skips to the end. -
Conditional Processing Based on Program Mode:
-
Checks the
PGM
field to determine the batch processing stage:- Invoice Entry (
PGM = 'I'
): - Executes exception output
REL
(EXCPTREL
). - Updates
BBIBCH
with:- Positions 6–7: Blanks (
' '
, likely status or flag). - Position 8: Blanks (
' '
). RECCNT
at position 39: Updates record count.
- Positions 6–7: Blanks (
- Edit (
PGM = 'E'
): - Executes exception output
EDIT
(EXCPTEDIT
). - Updates
BBIBCH
with the same fields asREL
:- Positions 6–7: Blanks.
- Position 8: Blanks.
RECCNT
at position 39.
- Forms (
PGM = 'F'
): - Checks
KYALSL
for selection criteria:- If
KYALSL = 'ALL'
, setsRTOPST = 'Y'
(ready to post). - Otherwise, sets
RTOPST = 'N'
(not ready to post).
- If
- Executes exception output
FORM
(EXCPTFORM
). - Updates
BBIBCH
with:- Positions 6–7: Blanks.
- Position 8: Blanks.
- Position 9:
'Y'
(indicates forms processed). RECCNT
at position 39.RTOPST
at position 42.
- Post (
PGM = 'P'
): - Checks
RECCNT
:- If
RECCNT = 0
(all records posted), executesPOST
(EXCPTPOST
): - Updates
BBIBCH
with:- Position 1:
'D'
(delete flag, marks batch as posted). - Position 6:
'P'
(posted status). RECCNT
at position 39.
- Position 1:
- If
RECCNT ≠ 0
, executesREL
(EXCPTREL
): - Updates
BBIBCH
with:- Positions 6–7: Blanks.
- Position 8: Blanks.
RECCNT
at position 39.
- If
- Default (Other
PGM
Values): - Executes
REL
(EXCPTREL
) with the same updates as above.
- Invoice Entry (
-
Cycle Completion:
- Sets the last record indicator (
LR
) to terminate the RPG cycle (SETON LR
). - Closes the
BBIBCH
file and ends the program.
Business Rules¶
- Batch Status Update:
-
Updates
BBIBCH
based on the program mode (PGM
):I
(Invoice Entry): Clears status fields and updates record count.E
(Edit): Same as invoice entry.F
(Forms): Sets forms flag ('Y'
) and ready-to-post flag (RTOPST
) based onKYALSL
('Y'
forALL
,'N'
otherwise).P
(Post): Marks batch as posted ('D'
,'P'
) if all records are processed (RECCNT = 0
); otherwise, reverts to release status.
-
Forms Processing:
-
For
PGM = 'F'
, checks if all orders are selected (KYALSL = 'ALL'
) to setRTOPST = 'Y'
(ready to post) or'N'
(not ready). -
Posting Validation:
-
Only marks a batch as posted (
'D'
,'P'
) ifRECCNT = 0
, ensuring all records in the batch are processed. -
Default Behavior:
-
For unrecognized
PGM
values, defaults to release status (REL
), clearing status fields and updating record count. -
No Error Handling:
-
Assumes the batch record exists in
BBIBCH
and input fields are valid. If the batch is not found (99
on), no updates are performed. -
Integration with ARGLMS:
- Part of the invoice posting workflow, managing batch status to track progress through invoice entry, editing, forms printing, and posting.
Tables (Files) Used¶
- BBIBCH:
- Description: Batch control file.
- Attributes: Update file (
UF
), 48 bytes, 2-byte alternate index, 2-byte key, disk-based. - Fields Used:
KYALSL
(103–105): Selection criteria (ALL
or company-specific).BATCH#
(490–491): Batch number (key).PGM
(504): Program mode (I
,E
,F
,P
).RECCNT
(475–482): Record count.RTOPST
(output, position 42): Ready-to-post flag (Y
orN
).
- Purpose: Stores batch control information for invoice processing.
- Usage: Chained for retrieval (
CHAINBBIBCH
) and updated via exception outputs (REL
,EDIT
,FORM
,POST
).
External Programs Called¶
The BB055
RPG program does not explicitly call any external programs. It is called by the main OCL (e.g., BB600.ocl36.txt
) and operates solely on the BBIBCH
file to manage batch status.
Summary¶
The BB055
RPG program, called by the main OCL (e.g., BB600.ocl36.txt
), manages batch status by:
- Retrieving a batch record from BBIBCH
using BATCH#
.
- Updating BBIBCH
based on PGM
:
- I
(Invoice Entry): Clears status fields, updates RECCNT
(REL
).
- E
(Edit): Same as invoice entry (EDIT
).
- F
(Forms): Sets forms flag, RTOPST
(Y
for ALL
, N
otherwise), and updates RECCNT
(FORM
).
- P
(Post): Marks batch as posted ('D'
, 'P'
) if RECCNT = 0
(POST
); otherwise, reverts to REL
.
- Defaulting to REL
for unrecognized PGM
values.
- Terminating with SETON LR
after processing.
Tables Used: BBIBCH
(batch control).
External Programs Called: None.
This program ensures accurate batch status management in the ARGLMS invoice posting workflow, tracking progress through various processing stages.