BB620 RPG36
The BB620.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 remove posted invoices from the invoice transaction entry file (BBTRAN
) and associated files (BBTRHS1
, BBTRDS1
, BBTRA1
, BBTRANU
, BBTRTX
). It deletes header, detail, supplemental, and accessorial/marks records for posted invoices and writes records to an audit file (SA5SHA
). The program includes revisions to handle new fields and supplemental/accessorial data (per JB01
). Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BB610 RPG Program¶
The BB620
program processes invoice transaction records from BBTRAN
, identifies posted invoices, deletes associated records across multiple files, and logs deletions to SA5SHA
for auditing.
- File Initialization:
- The program opens the following files:
- Input/Update Files:
BBTRAN
: Primary input/update file (UP
), 512 bytes, 21-byte alternate index, 492-byte key, disk-based. Contains invoice transaction records (header, detail, marks, miscellaneous).BBTRHS1
: Update file (UF
), 512 bytes, 18-byte alternate index, externally keyed (EXTK
), disk-based. Stores supplemental header records.BBTRDS1
: Update file (UF
), 512 bytes, 21-byte alternate index, externally keyed (EXTK
), disk-based. Stores supplemental detail records.BBTRA1
: Update file (UF
), 512 bytes, 23-byte alternate index, externally keyed (EXTK
), disk-based. Stores accessorial/marks records.BBTRANU
: Update file (UF
), 512 bytes, 21-byte alternate index, 492-byte key, disk-based. Likely a duplicate or alternate invoice transaction file.BBTRTX
: Update file (UF
), 512 bytes, 11-byte alternate index, disk-based. Stores tax-related records.- Output File:
SA5SHA
: Output file (O
), 512 bytes, add capability (A
), disk-based. Used for audit logging of deleted records.
- Defines record formats for
BBTRAN
with condition indicators:01
(Header):C0
at positions 10–12.02
(Detail):NC9
at position 10.03
(Miscellaneous):C9
at position 10.04
(Order Marks):C9
,C6
,C0
at positions 10–12.05
(Invoice Marks):C9
,C6
,C1
at positions 10–12.06
(BOL Marks):C9
,C6
,C2
at positions 10–12.
-
Key fields:
COORD
(2–9): Order key (company + order number).ORKEY
(2–12): Extended order key.BOINV#
(95–101): Invoice number.BOSHDT
(108–113): Ship date.BOLKYH
(492–509): Header key for supplemental records.BOLKEY
(492–512): Transaction key.DEL
(1): Delete flag.
-
Record Processing (BBTRAN):
- Reads
BBTRAN
records sequentially using the RPG cycle (NS 01
,OR 02
,OR 03
,OR 04
,OR 05
,OR 06
). - Identifies record type (header, detail, marks, miscellaneous) using condition indicators (
C0
,C9
,C6
,C1
,C2
). -
Processes records at level break
L1
(likely company or order level). -
Deletion of Posted Invoices:
-
For each posted invoice (criteria not specified, likely based on status or
BOINV#
):- Header Deletion:
- Chains to
BBTRANU
usingBOLKEY
to locate the header record (C L1 BOLKEY CHAINBBTRANU 90
). - If found (
N90
), executes exception outputDELHDR
to delete the header fromBBTRANU
(EDEL DELHDR
). - Chains to
BBTRHS1
usingBOLKYH
to locate the supplemental header (C L1 BOLKYH CHAINBBTRHS1 91
). - If found (
N91
), executesDELHS
to delete fromBBTRHS1
(EDEL DELHS
). - Detail Deletion:
- Deletes detail records from
BBTRAN
(EDEL DELREC
). - Deletes supplemental detail records from
BBTRDS1
(EDEL DELDS
). - Deletes tax records from
BBTRTX
(EDEL DELDTX
). - Accessorial/Marks Deletion:
- Sets lower limit for
BBTRA1
usingXXKY23
(constructed fromBOLKYH
+'00000'
) (C L1 XXKY23 SETLLBBTRA1
). - Reads
BBTRA1
records sequentially (C L1 READ BBTRA1 91EOF
). - Compares
ACOORR
(accessorial order key) withBOLKYH
(C L1 N91ACOORR COMP BOLKYH 9191
). - If matching (
91
), executesRELA
to release or process (E RELA
). - If not matching, executes
DELA
to delete fromBBTRA1
(EDEL DELA
). - Continues until end of file (
91EOF
, jumps toENDA
).
-
Audit Logging:
- Writes deleted record details to
SA5SHA
(EADD DELA
):- Fields:
BAREC1
(1–256),BAREC2
(257–512),'BBTRA'
(constant, position 200),'BB620'
(program name, position 210),SVINV#
(invoice number, position 218),SVSHDT
(ship date, position 227).
- Fields:
-
Logs deletions for auditing purposes.
-
Error Checking:
- Checks if error count (
ERRCNT
) is zero (C L1 ERRCNT IFEQ *ZERO
). -
Proceeds with deletions only if no errors are detected.
-
Cycle Completion:
- Processes all
BBTRAN
records at level breakL1
. - Deletes associated records in
BBTRANU
,BBTRHS1
,BBTRDS1
,BBTRA1
,BBTRTX
. - Logs deletions to
SA5SHA
. - Terminates after processing, closing all files.
Business Rules¶
- Invoice Deletion:
- Removes posted invoices from
BBTRAN
, including header, detail, marks, and miscellaneous records. -
Deletes corresponding records from
BBTRANU
(header),BBTRHS1
(supplemental header),BBTRDS1
(supplemental detail),BBTRA1
(accessorial/marks), andBBTRTX
(tax). -
Supplemental and Accessorial Data (per JB01):
- Manages new fields for customer-owned product shipments and other data.
-
Adds, updates, or deletes records in
BBTRHS1
,BBTRDS1
, andBBTRA1
to handle supplemental header, detail, and accessorial/marks data. -
Audit Logging:
-
Logs all deletions to
SA5SHA
with invoice number (SVINV#
), ship date (SVSHDT
), and program metadata for tracking. -
Error Handling:
- Checks
ERRCNT
to ensure no errors before proceeding with deletions. -
Assumes input files contain valid data and output files can be written without issues.
-
Record Type Identification:
-
Uses condition indicators (
C0
,C9
,C6
,C1
,C2
) to distinguish header, detail, marks (order, invoice, BOL), and miscellaneous records. -
Key-Based Deletion:
- Uses
BOLKEY
andBOLKYH
for chaining toBBTRANU
andBBTRHS1
. -
Constructs
XXKY23
forBBTRA1
to process accessorial/marks records. -
Integration with ARGLMS:
- Part of the invoice posting workflow, ensuring posted invoices are removed from transaction files to maintain data integrity.
Tables (Files) Used¶
- BBTRAN:
- Description: Invoice transaction entry file.
- Attributes: Update file (
UP
), 512 bytes, 21-byte alternate index, 492-byte key, disk-based. - Fields Used:
COORD
(2–9, order key),ORKEY
(2–12, extended order key),BOINV#
(95–101, invoice number),BOSHDT
(108–113, ship date),DEL
(1, delete flag). - Purpose: Contains invoice transaction records (header, detail, marks, miscellaneous).
-
Usage: Read to identify posted invoices, deleted via
EDEL DELREC
. -
BBTRHS1:
- Description: Supplemental header file.
- Attributes: Update file (
UF
), 512 bytes, 18-byte alternate index, externally keyed (EXTK
), disk-based. - Fields Used:
BOLKYH
(492–509, header key). - Purpose: Stores supplemental header data.
-
Usage: Deleted via
EDEL DELHS
. -
BBTRDS1:
- Description: Supplemental detail file.
- Attributes: Update file (
UF
), 512 bytes, 21-byte alternate index, externally keyed (EXTK
), disk-based. - Purpose: Stores supplemental detail data.
-
Usage: Deleted via
EDEL DELDS
. -
BBTRA1:
- Description: Accessorial/marks file.
- Attributes: Update file (
UF
), 512 bytes, 23-byte alternate index, externally keyed (EXTK
), disk-based. - Fields Used:
ACOORR
(accessorial order key),XXKY23
(constructed key). - Purpose: Stores accessorial and marks data.
-
Usage: Processed (
E RELA
) or deleted (EDEL DELA
) based on key match. -
BBTRANU:
- Description: Alternate invoice transaction file.
- Attributes: Update file (
UF
), 512 bytes, 21-byte alternate index, 492-byte key, disk-based. - Fields Used:
BOLKEY
(492–512, transaction key). - Purpose: Contains invoice transaction headers (possibly a duplicate or staging file).
-
Usage: Deleted via
EDEL DELHDR
. -
BBTRTX:
- Description: Tax-related file.
- Attributes: Update file (
UF
), 512 bytes, 11-byte alternate index, disk-based. - Purpose: Stores tax-related records.
-
Usage: Deleted via
EDEL DELDTX
. -
SA5SHA:
- Description: Audit file.
- Attributes: Output file (
O
), 512 bytes, add capability (A
), disk-based. - Fields Used:
BAREC1
(1–256),BAREC2
(257–512),'BBTRA'
(constant),'BB620'
(program name),SVINV#
(invoice number),SVSHDT
(ship date). - Purpose: Logs deleted records for auditing.
- Usage: Written via
EADD DELA
.
External Programs Called¶
The BB620
RPG program does not explicitly call any external programs. It is a self-contained program that processes input from BBTRAN
and related files and writes to SA5SHA
.
Summary¶
The BB620
RPG program, called by the main OCL (e.g., BB600.ocl36.txt
), removes posted invoices by:
- Reading BBTRAN
to identify posted invoices (header, detail, marks, miscellaneous).
- Deleting records from BBTRAN
(EDEL DELREC
), BBTRANU
(EDEL DELHDR
), BBTRHS1
(EDEL DELHS
), BBTRDS1
(EDEL DELDS
), BBTRA1
(EDEL DELA
), and BBTRTX
(EDEL DELDTX
).
- Processing accessorial/marks records in BBTRA1
using XXKY23
for matching or deletion.
- Logging deletions to SA5SHA
with invoice and ship date details.
- Handling supplemental and accessorial data (per JB01
).
- Checking ERRCNT
to ensure error-free processing.
- Terminating after processing all records.
Tables Used: BBTRAN
(invoice transactions), BBTRHS1
(supplemental header), BBTRDS1
(supplemental detail), BBTRA1
(accessorial/marks), BBTRANU
(alternate transactions), BBTRTX
(tax records), SA5SHA
(audit log).
External Programs Called: None.
This program ensures data integrity in the ARGLMS system by removing posted invoices from transaction files and logging deletions for audit purposes.