Skip to content

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:

  1. Program Initialization:
  2. The program is defined with a header specification (H P064) and identified as BB003.
  3. 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).
  4. Input specifications define fields for BBORTR, BBORCL, BBOTHS1, BBOTDS1, and BBOTA1:
    • BBORTR: Fields include 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, BBOTHS1, BBOTDS1, BBOTA1: Key fields for company/order# (TCOORD, BOCOOR, BDCOOR, BACOOR, positions 2-9).
  5. 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).

  6. Main Processing Logic:

  7. The program operates under indicator 11 (likely set by the calling OCL program when SWITCH1-1 is active for batch deletion).
  8. A DO loop (B1 to E1, lines DC01) processes the deletion of records:
    • BBORCL Deletion:
    • Chains to BBORCL using BBKEY (company/order#, line C* BBORCL).
    • If a record is found (N99), executes the DELETE exception output to delete the record.
    • BBOTHS1 Deletion (DC01):
    • Sets the file pointer to the start of BBOTHS1 using TCOORD (SETLL, line DC01).
    • Reads records in a loop (RDAGN1, lines DC01).
    • Compares TCOORD with BOCOOR (company/order#); if matching (N99), deletes the record (EXCPTDELOTS) and continues reading until no more matching records are found.
    • BBOTDS1 Deletion (DC01):
    • Moves Tcoord to KL11 (11-byte key) and sets the file pointer to BBOTDS1 (SETLL, line DC01).
    • Reads records in a loop (RDAGN2, lines DC01).
    • Compares Tcoord with BDCOOR; if matching (N99), deletes the record (EXCPTDELOTD) and continues reading.
    • BBOTA1 Deletion (DC01):
    • Moves Tcoord to KL13 (13-byte key) and sets the file pointer to BBOTA1 (SETLL, line DC01).
    • Reads records in a loop (RDAGN3, lines DC01).
    • Compares Tcoord with BACOOR; if matching (N99), deletes the record (EXCPTDELOTA) and continues reading.
  9. The loop ends after processing all relevant files (END, line DC01).

  10. Output Operations:

  11. Exception outputs are defined for deletion:
    • DELETE (for BBORCL): Deletes the matched record.
    • DELOTS (for BBOTHS1): Deletes the matched supplemental history record.
    • DELOTD (for BBOTDS1): Deletes the matched supplemental detail record.
    • DELOTA (for BBOTA1): Deletes the matched alternate transaction record.

Business Rules

The program enforces the following business rules related to batch deletion:

  1. Batch Deletion Scope:
  2. 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.
  3. The program processes only records matching the company/order# key (TCOORD, BOCOOR, BDCOOR, BACOOR).

  4. File Access and Deletion:

  5. The BBORTR file is read to obtain the company/order# (Tcoord) for identifying records to delete.
  6. The BBORCL, BBOTHS1, BBOTDS1, and BBOTA1 files are update-capable, allowing records to be deleted.
  7. Deletion is performed only if records are found (N99 condition).

  8. Sequential Deletion:

  9. The program processes each file sequentially, ensuring all matching records are deleted before moving to the next file.
  10. For BBOTHS1, BBOTDS1, and BBOTA1, all records with matching company/order# keys are deleted by reading and comparing in a loop.

  11. No Validation or Error Messaging:

  12. 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.
  13. Deletion is unconditional for matched records.

Tables (Files) Used

The program interacts with the following files:

  1. BBORTR: Input primary file for order transactions (512 bytes, indexed, key length 11).
  2. 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).
  3. BBORCL: Update-capable file for order close records (256 bytes, indexed, key length 14).
  4. Key field: Not explicitly defined in the code, but implied to use BBKEY (company/order#).
  5. BBOTHS1: Update-capable file for order transaction history supplemental records (512 bytes, indexed, key length 8, external key, added in DC01).
  6. Key field: BOCOOR (company/order#, positions 2-9).
  7. BBOTDS1: Update-capable file for order detail supplemental records (512 bytes, indexed, key length 11, external key, added in DC01).
  8. Key field: BDCOOR (company/order#, positions 2-9).
  9. BBOTA1: Update-capable file for order transaction alternate records (512 bytes, indexed, key length 13, external key, added in DC01).
  10. 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.