BB003 RPG36
The BB003.rpg36.txt
document is an RPG III (System/36 style) program called from the BB101.ocl36.txt
OCL program in an IBM System/36 or AS/400 (now IBM i) environment. Its primary function is to delete records from order transaction files when a batch is deleted. The program was enhanced in revision DC01
(03/10/10 by Dave Capo) to include additional files for deletion. Below is a detailed explanation of the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG Program¶
The BB003
RPG program deletes records from specific order transaction files (BBORCL
, BBOTHS1
, BBOTDS1
, BBOTA1
) based on a company and order number key. The process is straightforward and focuses on identifying and removing records associated with a deleted batch. The steps are as follows:
- Program Initialization:
- The program is defined with a header specification (
H P064
) and identified asBB003
. - It defines the following files:
BBORTR
: Input primary file (512 bytes, indexed, key length 11, access mode 2) for reading order transaction records.BBORCL
: Update-capable file (256 bytes, record length 256, indexed, key length 14, access mode 2) for order close records.BBOTHS1
: Update-capable file (512 bytes, indexed, key length 8, external key) for order transaction history supplemental records (added in DC01).BBOTDS1
: Update-capable file (512 bytes, indexed, key length 11, external key) for order detail supplemental records (added in DC01).BBOTA1
: Update-capable file (512 bytes, indexed, key length 13, external key) for order transaction alternate records (added in DC01).
- Input specifications define fields for
BBORTR
,BBORCL
,BBOTHS1
,BBOTDS1
, andBBOTA1
:BBORTR
: Fields includeTCOORD
(company/order#, positions 2-9),TKEY
(key, positions 2-12),TSEQ
(sequence, positions 10-12),TDDEL
(delete code, position 1),TDCO
(company#, positions 2-3),TDORD#
(order#, positions 4-9),TDCUST
(customer#, positions 13-18).BBORCL
,BBOTHS1
,BBOTDS1
,BBOTA1
: Key fields for company/order# (TCOORD
,BOCOOR
,BDCOOR
,BACOOR
, positions 2-9).
-
A data structure (
BBKEY
) is defined to hold the key fields:TDCO
(company#, positions 1-2),TDCUST
(customer#, positions 3-8),TDORD#
(order#, positions 9-14). -
Main Processing Logic:
- The program operates under indicator 11 (likely set by the calling OCL program when
SWITCH1-1
is active for batch deletion). - A
DO
loop (B1
toE1
, lines DC01) processes the deletion of records:- BBORCL Deletion:
- Chains to
BBORCL
usingBBKEY
(company/order#, line C* BBORCL). - If a record is found (
N99
), executes theDELETE
exception output to delete the record. - BBOTHS1 Deletion (DC01):
- Sets the file pointer to the start of
BBOTHS1
usingTCOORD
(SETLL
, line DC01). - Reads records in a loop (
RDAGN1
, lines DC01). - Compares
TCOORD
withBOCOOR
(company/order#); if matching (N99
), deletes the record (EXCPTDELOTS
) and continues reading until no more matching records are found. - BBOTDS1 Deletion (DC01):
- Moves
Tcoord
toKL11
(11-byte key) and sets the file pointer toBBOTDS1
(SETLL
, line DC01). - Reads records in a loop (
RDAGN2
, lines DC01). - Compares
Tcoord
withBDCOOR
; if matching (N99
), deletes the record (EXCPTDELOTD
) and continues reading. - BBOTA1 Deletion (DC01):
- Moves
Tcoord
toKL13
(13-byte key) and sets the file pointer toBBOTA1
(SETLL
, line DC01). - Reads records in a loop (
RDAGN3
, lines DC01). - Compares
Tcoord
withBACOOR
; if matching (N99
), deletes the record (EXCPTDELOTA
) and continues reading.
-
The loop ends after processing all relevant files (
END
, line DC01). -
Output Operations:
- Exception outputs are defined for deletion:
DELETE
(forBBORCL
): Deletes the matched record.DELOTS
(forBBOTHS1
): Deletes the matched supplemental history record.DELOTD
(forBBOTDS1
): Deletes the matched supplemental detail record.DELOTA
(forBBOTA1
): Deletes the matched alternate transaction record.
Business Rules¶
The program enforces the following business rules related to batch deletion:
- Batch Deletion Scope:
- When a batch is deleted (indicated by
SWITCH1-1
in the OCL program), all associated records in the transaction files (BBORCL
,BBOTHS1
,BBOTDS1
,BBOTA1
) for the specified company and order number (TCOORD
) must be deleted. -
The program processes only records matching the company/order# key (
TCOORD
,BOCOOR
,BDCOOR
,BACOOR
). -
File Access and Deletion:
- The
BBORTR
file is read to obtain the company/order# (Tcoord
) for identifying records to delete. - The
BBORCL
,BBOTHS1
,BBOTDS1
, andBBOTA1
files are update-capable, allowing records to be deleted. -
Deletion is performed only if records are found (
N99
condition). -
Sequential Deletion:
- The program processes each file sequentially, ensuring all matching records are deleted before moving to the next file.
-
For
BBOTHS1
,BBOTDS1
, andBBOTA1
, all records with matching company/order# keys are deleted by reading and comparing in a loop. -
No Validation or Error Messaging:
- The program does not perform additional validations or display error messages, assuming the calling OCL program (
BB101.ocl36.txt
) has already validated the batch deletion request. - Deletion is unconditional for matched records.
Tables (Files) Used¶
The program interacts with the following files:
- BBORTR: Input primary file for order transactions (512 bytes, indexed, key length 11).
- Fields:
TCOORD
(company/order#, positions 2-9),TKEY
(key, positions 2-12),TSEQ
(sequence, positions 10-12),TDDEL
(delete code, position 1),TDCO
(company#, positions 2-3),TDORD#
(order#, positions 4-9),TDCUST
(customer#, positions 13-18). - BBORCL: Update-capable file for order close records (256 bytes, indexed, key length 14).
- Key field: Not explicitly defined in the code, but implied to use
BBKEY
(company/order#). - BBOTHS1: Update-capable file for order transaction history supplemental records (512 bytes, indexed, key length 8, external key, added in DC01).
- Key field:
BOCOOR
(company/order#, positions 2-9). - BBOTDS1: Update-capable file for order detail supplemental records (512 bytes, indexed, key length 11, external key, added in DC01).
- Key field:
BDCOOR
(company/order#, positions 2-9). - BBOTA1: Update-capable file for order transaction alternate records (512 bytes, indexed, key length 13, external key, added in DC01).
- Key field:
BACOOR
(company/order#, positions 2-9).
External Programs Called¶
The BB003
RPG program does not call any external programs. All processing is handled internally through file operations and deletion logic.
Summary¶
The BB003
RPG program, called from the BB101.ocl36.txt
OCL program, is responsible for deleting records from order transaction files (BBORCL
, BBOTHS1
, BBOTDS1
, BBOTA1
) when a batch is deleted. It reads the company/order# from BBORTR
and deletes matching records in the specified files using a key-based approach. The program was enhanced in revision DC01 to include BBOTHS1
, BBOTDS1
, and BBOTA1
in the deletion process. Business rules ensure that only records matching the company/order# are deleted, with no additional validations or error messaging. The program interacts with five files and does not call external programs, relying solely on internal logic for record deletion.