BB714A RPG36
The provided BB714A.rpg36.txt
is an RPG program (for IBM System/36 or AS/400) called by the BB715.ocl36.txt
OCL program as part of the preprocessing for the "Daily Requirements Report." Its primary function is to enhance the BB713M
file by adding sort codes (CNTY
and CSRT
) based on container and product data from GSCNTR1
and GSPROD
, using GSTABL
for additional validation. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.
Process Steps of the RPG Program¶
The BB714A
RPG program updates records in BB713M
by retrieving container type (TCCNTY
) from GSCNTR1
and sort code (TBCSRT
) from GSTABL
, based on product class (TPPRCL
from GSPROD
). Here’s a step-by-step breakdown:
- Program Initialization:
- Header (H-spec): Line 0002 defines the program name (
BB714A
) and page length (P064
). - File Definitions (F-spec):
BB713M
: Update file (input/output, 530 bytes, disk, Line 0008).GSTABL
: Input file (256 bytes, indexed with 12 keys, disk, Line 0008).GSCNTR1
: Input file (512 bytes, indexed with 3 keys, disk, Line JK01).GSPROD
: Input file (512 bytes, indexed with 6 keys, disk, Line JK02).
- Input Definitions (I-spec):
BB713M
(Lines 0017–0029):BDDEL
(1): Delete flag ('D' for deleted).BDCO
(2–3): Company number.BDORD#
(4–9): Order number.BDSEQ
(10–12): Detail line sequence.BDLOC
(22–24): Location.BDPROD
(25–28): Product code.BDTANK
(29–32): Tank code.BDQTY
(35–41): Container quantity.BDPRCE
(42–50): Price.BDUM
(51–53): Unit of measure.BDCSTK
(54–73): Customer stock number.BDDESC
(75–104): Description.BDCNTR
(121–123): Container code.GSTABL
(Lines 0035–0041):TBDEL
(1): Delete flag.TBTYPE
(2–7): Type code.TBCODE
(8–13): Code.TBPRGP
(89–90): Product group.TBICOL
(94–95): Item color.TBPRCL
(127–129): Product class.TBSELL
(155): Sell product indicator ('Y').TBCSRT
(178–179): Customer sort code.GSCNTR1
(Line JK01):TCCNTY
(180): Container type ('B' for bulk, 'P' for packaged).GSPROD
(Line JK02):TPDEL
(1): Delete flag.TPPRCL
(127–129): Product class.
-
Indicators:
01
: Triggers record processing.02
: Skips to program end.97
: Indicates chain failure onGSPROD
.98
: Indicates chain failure onGSTABL
.99
: Indicates chain failure onGSCNTR1
.
-
One-Time Setup (ONETIM Subroutine):
- Condition:
ONCE = 0
(Line 0043). -
Steps (Lines post-0043):
- Increments
ONCE
to 1 to prevent re-execution (Line inONETIM
). - Sets
PRODCL
to 'PRODCL' (Line inONETIM
, used as a key type forGSTABL
). - The commented
PRODCD
line suggests a prior version used a different key type.
- Increments
-
Main Processing Loop (Lines 0043–end of C-specs):
- Condition: Indicator 02 on skips to
END
tag, terminating the program (Line 0046). -
Processing for Indicator 01 (Line 0047):
- Container Type Lookup (Lines JK01):
- Chains
GSCNTR1
usingBDCNTR
(container code, Line JK01). - If found (
N99
), movesTCCNTY
(container type, 'B' or 'P') toCNTY
(Line JK01). - Product Class and Sort Code Lookup:
- Builds a 6-character key (
PRK6
) combiningBDCO
(company number) andBDPROD
(product code, Lines post-JK01). - Moves
PRK6
toKLPROD
(Line JK02). - Chains
GSPROD
usingKLPROD
to getTPPRCL
(product class, Line JK02). - If found (
N97
):- Builds a 5-character key (
KEY5
) combiningBDCO
andTPPRCL
(Lines post-JK02). - Chains
GSTABL
usingKEY5
withPRODCL
as the type to getTBCSRT
(customer sort code, Lines post-JK02). - If found (
N98
), movesTBCSRT
toCSRT
(Line post-JK02).
- Builds a 5-character key (
- Output Update:
- Updates the
BB713M
record with:CNTY
(position 521, bulk/packaged indicator).CSRT
(position 523, customer sort code).
- If either chain fails (
97
or98
), no sort code is updated, butCNTY
may still be set ifGSCNTR1
chain succeeds.
-
Program Termination:
- The
END
tag is reached when indicator 02 is set or all records are processed, ending the program.
Business Rules¶
- Container Type Assignment:
- For each
BB713M
record, the container code (BDCNTR
) is used to look up the container type (TCCNTY
, 'B' for bulk or 'P' for packaged) inGSCNTR1
. -
If found,
TCCNTY
is written to position 521 (CNTY
) inBB713M
. -
Sort Code Assignment:
- The product code (
BDPROD
) and company number (BDCO
) are used to look up the product class (TPPRCL
) inGSPROD
. - If found,
TPPRCL
andBDCO
are used to look up the customer sort code (TBCSRT
) inGSTABL
with type 'PRODCL'. - If found,
TBCSRT
is written to position 523 (CSRT
) inBB713M
. -
If either lookup fails, no sort code is assigned.
-
Record Processing:
- Only non-deleted records (
BDDEL ≠ 'D'
) are processed (implied by10NC9
inBB713M
input spec). -
Records with missing
GSCNTR1
orGSPROD
/GSTABL
entries may receive partial updates (CNTY
but notCSRT
). -
One-Time Initialization:
- The
ONETIM
subroutine runs once to setPRODCL = 'PRODCL'
, ensuring the correct key type forGSTABL
lookups.
Tables (Files) Used¶
- Input Files:
BB713M
: Update file (530 bytes), contains order data to be enhanced.- Fields:
BDDEL
(1),BDCO
(2–3),BDORD#
(4–9),BDSEQ
(10–12),BDLOC
(22–24),BDPROD
(25–28),BDTANK
(29–32),BDQTY
(35–41),BDPRCE
(42–50),BDUM
(51–53),BDCSTK
(54–73),BDDESC
(75–104),BDCNTR
(121–123).
- Fields:
GSTABL
: Input file (256 bytes, indexed with 12 keys), contains table data for sort codes.- Fields:
TBDEL
(1),TBTYPE
(2–7),TBCODE
(8–13),TBPRGP
(89–90),TBICOL
(94–95),TBPRCL
(127–129),TBSELL
(155),TBCSRT
(178–179).
- Fields:
GSCNTR1
: Input file (512 bytes, indexed with 3 keys), contains container type data.- Field:
TCCNTY
(180, 'B' or 'P').
- Field:
-
GSPROD
: Input file (512 bytes, indexed with 6 keys), contains product data.- Fields:
TPDEL
(1),TPPRCL
(127–129).
- Fields:
-
Output File:
BB713M
: Updated with:CNTY
(position 521, container type 'B' or 'P').CSRT
(position 523, customer sort code).
External Programs Called¶
- None: The
BB714A
program does not explicitly call other programs. It performs all processing internally using file I/O and exception outputs.
Notes¶
- Integration with OCL: The
BB715.ocl36.txt
callsBB714A
afterBB714
to add sort codes toBB713M
, preparing it for sorting by#GSORT
in the next step. - Change History:
- 04/18/16 (JK01): Replaced
GSTABL
for container type withGSCNTR1
(alpha key). - 01/18/23 (JK02): Replaced
GSTABL
for product code withGSPROD
for product class lookup. - Error Handling: Uses indicators 97, 98, and 99 to handle chain failures. Missing records in
GSCNTR1
orGSPROD
/GSTABL
result in partial or no updates for the affected fields. - Sort Code Purpose: The
CNTY
(bulk/packaged) andCSRT
(customer sort code) fields are added to support the sorting criteria in#GSORT
(e.g., positions 521 and 522–523).
Summary¶
The BB714A
RPG program enhances BB713M
records by adding container type (CNTY
) from GSCNTR1
and customer sort code (CSRT
) from GSTABL
, based on product class (TPPRCL
) from GSPROD
. It processes non-deleted records, updates positions 521 and 523, and relies on chained lookups. The program uses BB713M
, GSTABL
, GSCNTR1
, and GSPROD
files, and calls no external programs.
Files Used: BB713M
, GSTABL
, GSCNTR1
, GSPROD
.
External Programs: None.
If you need further details (e.g., field formats, subsequent programs like #GSORT
), or additional files, let me know!