BB9518 RPG36
The provided RPG/36 program, BB9518.rpg36.txt, is part 3 of 4 in the rack price list processing suite, called by the BB951.ocl36.txt OCL program. Its primary function is to gather tax information for each company on the rack price list and create a temporary tax print file (BB9518). Below, I’ll explain the process steps, business rules, tables/files used, and external programs called.
Process Steps of the RPG Program¶
The BB9518 RPG program processes product records from GSPRD4, retrieves tax-related data from GSTABL, BIPRT1, and BISLTX, and writes tax information to the BB9518 output file. Here’s a detailed breakdown of the process steps:
- File and Data Structure Definitions:
- Files:
GSPRD4: Primary input file (512 bytes, indexed, key length 8 bytes), contains product data (replacedGSTAB4per revision JK01).GSTABL: Input table file (256 bytes, indexed, key length 12 bytes), used for product group descriptions.BIPRT1: Input file (64 bytes, indexed, key length 8 bytes), an alternative index for product tax data (BIPRTX).BISLTX: Input file (80 bytes, indexed, key length 4 bytes), contains tax descriptions and rates.BB9518: Output file (512 bytes, indexed, key length 7 bytes), temporary file for tax print data.
- Arrays (per revision LT01):
TXC(10 elements, 4 bytes): Stores tax codes.TXD(10 elements, 30 bytes): Stores tax descriptions.TXR(10 elements, 5.5): Stores tax rates.
- Input Fields:
GSPRD4:TBDEL(delete flag),TBCODE(product code),TBCONO(company number),TBPRGP(product group).GSTABL:TXDEL(delete flag),TXDES1(complete description).BIPRT1:PTDEL(delete flag),PTCONO(company),PTSTAT(state),PTPROD(product code),PTDELV(delivery flag),TXC(tax codes, array).BISLTX:STTXNM(taxing name),STTXPC(taxing percentage).
-
Data Structure:
UDS(User Data Structure): ContainsLDACO(company number).
-
Main Processing Loop:
- Filter by Company (lines 0062–0063):
- Processes only records where
TBCONO(company inGSPRD4) equalsLDACO(company fromUDS).
- Processes only records where
- Filter Non-Deleted Records (lines 0065–0066):
- Processes only records where
TBDEL ≠ 'D'(not deleted).
- Processes only records where
- Filter by Product Group (lines 0068–0069):
- Processes only records with a non-blank product group (
TBPRGP).
- Processes only records with a non-blank product group (
-
Check Unique Product Group (lines 0071–0079):
- If
TBPRGP ≠ SVPRGP(saved product group from previous iteration): - Builds key
TBLKEYwith'PRODGR'andTBPRGP(prefixed byTBCONO). - Chains to
GSTABLusingTBLKEY. If not found (91on) orTXDEL = 'D', clearsTXDES1(description); else, retainsTXDES1. - Saves
TBPRGPtoSVPRGPto avoid reprocessing the same product group.
- If
-
Retrieve Tax Information (lines 0080–0116):
- Set Up Product Tax Search (lines 0082–0085):
- Moves
TBCODE(product code) toPROD. - Builds
PTLIM(key) withPRODand blanks. - Sets the file pointer for
BIPRT1toPTLIM(SETLLBIPRT1).
- Moves
- Process Product Tax Records (lines 0089–0116,
AGNPTloop):- Reads
BIPRT1records (READ BIPRT1, indicator09off if not EOF). - If
PTPROD = PRODandPTDEL ≠ 'D': - Clears
TXD(tax descriptions) andTXR(tax rates). - Loops through
TXCarray (1 to 10, per LT01):- If
TXC,X ≠ 'T'(ignores sales tax code): - Chains to
BISLTXusingTXC,X(tax code). - If found (
N90), movesSTTXNMtoTXD,X(description) andSTTXPCtoTXR,X(rate).
- If
- Sets indicator
40ifPTDELV = 'Y'(delivery flag). - Writes a record to
BB9518using theWRITITexception output. - Continues reading
BIPRT1records for the same product code (GOTO AGNPT).
- Reads
-
Save Product Group (line 0119):
- Updates
SVPRGPwith the currentTBPRGPto track processed groups.
- Updates
-
Write Output Record (lines 0127–0138):
-
If valid, writes to
BB9518using theWRITITexception:'A'(literal, pos 1).PTCONO(company, pos 2–3).PTSTAT(state, pos 4–5).TBPRGP(product group, pos 6–7).PTDELV(delivery flag, pos 8).TXDES1(complete description fromGSTABL, pos 9–23).'DELV'(if indicator40on, pos 24–27).TXC(tax codes array, pos 28–67).TXD(tax descriptions array, pos 68–367).TXR(tax rates array, pos 368–417).
-
Program Termination:
- The program processes all
GSPRD4records, looping until EOF, and terminates after writing relevant tax records toBB9518.
Business Rules¶
The RPG program enforces the following business rules for generating tax information for the rack price list:
- Company Filter:
-
Processes only records where the company (
TBCONO) matches the input company (LDACO). -
Non-Deleted Records:
-
Excludes records marked as deleted (
TBDEL = 'D'). -
Product Group Filter:
- Processes only records with a non-blank product group (
TBPRGP). -
Processes each product group only once, tracking with
SVPRGP. -
Product Group Description:
- Retrieves the complete description (
TXDES1) fromGSTABLusing the product group (TBPRGP) and company (TBCONO). -
If not found or deleted (
TXDEL = 'D'), uses a blank description. -
Tax Information Retrieval:
- For each product code (
TBCODE), retrieves tax records fromBIPRT1wherePTPRODmatches andPTDEL ≠ 'D'. - Retrieves up to 10 tax codes (
TXC), descriptions (TXD), and rates (TXR) fromBISLTX, ignoring codes equal to'T'(sales tax). -
Includes delivery flag (
PTDELV) in the output. -
Output Record:
- Writes tax records to
BB9518with company, state, product group, delivery flag, group description, tax codes, descriptions, and rates. - Outputs
'DELV'if delivery is applicable (PTDELV = 'Y').
Tables/Files Used¶
The RPG program uses the following files:
1. GSPRD4 (?9?GSPRD4): Primary input product file, containing company (TBCONO), product code (TBCODE), product group (TBPRGP), and delete flag (TBDEL).
2. GSTABL (?9?GSTABL): Input table file, used for product group descriptions (TXDES1).
3. BIPRT1 (?9?BIPRT1): Input file (alternative index for BIPRTX), containing company (PTCONO), state (PTSTAT), product code (PTPROD), delivery flag (PTDELV), tax codes (TXC), and delete flag (PTDEL).
4. BISLTX (?9?BISLTX): Input file, containing tax names (STTXNM) and tax percentages (STTXPC).
5. BB9518 (?9?BB9518): Output temporary file, containing tax information for the rack price report.
External Programs Called¶
The RPG program does not explicitly call any external programs. It performs file operations (CHAIN, READ, SETLL, EXCPT) but does not invoke other programs. It is called by the BB951.ocl36.txt OCL program as part of the rack price list process.
Summary¶
- Process Overview: The
BB9518RPG program processes product records fromGSPRD4, filters by company and non-deleted records, retrieves product group descriptions fromGSTABL, and tax codes, descriptions, and rates fromBIPRT1andBISLTX. It writes tax information to theBB9518temporary file for the rack price report. - Business Rules: Filters by company, non-deleted records, and unique product groups; retrieves tax data (excluding sales tax code
'T') and delivery flags; writes enriched tax records. - Files/Tables:
GSPRD4(input),GSTABL(input table),BIPRT1(input),BISLTX(input),BB9518(output). - External Programs: None called directly.
If you need further details (e.g., file structures, output format WRITIT, or interactions with BB951 or other programs), please provide them, or I can search for related information if desired!