Skip to content

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:

  1. File and Data Structure Definitions:
  2. Files:
    • GSPRD4: Primary input file (512 bytes, indexed, key length 8 bytes), contains product data (replaced GSTAB4 per 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.
  3. 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.
  4. 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).
  5. Data Structure:

    • UDS (User Data Structure): Contains LDACO (company number).
  6. Main Processing Loop:

  7. Filter by Company (lines 0062–0063):
    • Processes only records where TBCONO (company in GSPRD4) equals LDACO (company from UDS).
  8. Filter Non-Deleted Records (lines 0065–0066):
    • Processes only records where TBDEL ≠ 'D' (not deleted).
  9. Filter by Product Group (lines 0068–0069):
    • Processes only records with a non-blank product group (TBPRGP).
  10. Check Unique Product Group (lines 0071–0079):

    • If TBPRGP ≠ SVPRGP (saved product group from previous iteration):
    • Builds key TBLKEY with 'PRODGR' and TBPRGP (prefixed by TBCONO).
    • Chains to GSTABL using TBLKEY. If not found (91 on) or TXDEL = 'D', clears TXDES1 (description); else, retains TXDES1.
    • Saves TBPRGP to SVPRGP to avoid reprocessing the same product group.
  11. Retrieve Tax Information (lines 0080–0116):

  12. Set Up Product Tax Search (lines 0082–0085):
    • Moves TBCODE (product code) to PROD.
    • Builds PTLIM (key) with PROD and blanks.
    • Sets the file pointer for BIPRT1 to PTLIM (SETLLBIPRT1).
  13. Process Product Tax Records (lines 0089–0116, AGNPT loop):
    • Reads BIPRT1 records (READ BIPRT1, indicator 09 off if not EOF).
    • If PTPROD = PROD and PTDEL ≠ 'D':
    • Clears TXD (tax descriptions) and TXR (tax rates).
    • Loops through TXC array (1 to 10, per LT01):
      • If TXC,X ≠ 'T' (ignores sales tax code):
      • Chains to BISLTX using TXC,X (tax code).
      • If found (N90), moves STTXNM to TXD,X (description) and STTXPC to TXR,X (rate).
    • Sets indicator 40 if PTDELV = 'Y' (delivery flag).
    • Writes a record to BB9518 using the WRITIT exception output.
    • Continues reading BIPRT1 records for the same product code (GOTO AGNPT).
  14. Save Product Group (line 0119):

    • Updates SVPRGP with the current TBPRGP to track processed groups.
  15. Write Output Record (lines 0127–0138):

  16. If valid, writes to BB9518 using the WRITIT exception:

    • '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 from GSTABL, pos 9–23).
    • 'DELV' (if indicator 40 on, pos 24–27).
    • TXC (tax codes array, pos 28–67).
    • TXD (tax descriptions array, pos 68–367).
    • TXR (tax rates array, pos 368–417).
  17. Program Termination:

  18. The program processes all GSPRD4 records, looping until EOF, and terminates after writing relevant tax records to BB9518.

Business Rules

The RPG program enforces the following business rules for generating tax information for the rack price list:

  1. Company Filter:
  2. Processes only records where the company (TBCONO) matches the input company (LDACO).

  3. Non-Deleted Records:

  4. Excludes records marked as deleted (TBDEL = 'D').

  5. Product Group Filter:

  6. Processes only records with a non-blank product group (TBPRGP).
  7. Processes each product group only once, tracking with SVPRGP.

  8. Product Group Description:

  9. Retrieves the complete description (TXDES1) from GSTABL using the product group (TBPRGP) and company (TBCONO).
  10. If not found or deleted (TXDEL = 'D'), uses a blank description.

  11. Tax Information Retrieval:

  12. For each product code (TBCODE), retrieves tax records from BIPRT1 where PTPROD matches and PTDEL ≠ 'D'.
  13. Retrieves up to 10 tax codes (TXC), descriptions (TXD), and rates (TXR) from BISLTX, ignoring codes equal to 'T' (sales tax).
  14. Includes delivery flag (PTDELV) in the output.

  15. Output Record:

  16. Writes tax records to BB9518 with company, state, product group, delivery flag, group description, tax codes, descriptions, and rates.
  17. 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 BB9518 RPG program processes product records from GSPRD4, filters by company and non-deleted records, retrieves product group descriptions from GSTABL, and tax codes, descriptions, and rates from BIPRT1 and BISLTX. It writes tax information to the BB9518 temporary 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!