BI920 RPG36
Process Steps¶
The BI920 RPG program is an interactive screen-based maintenance utility for the Product Tax Master file (BIPRTX). It allows users to add, update, or delete tax configurations for products by company and state, with validation against related files. The program uses two main screens: BI920S01 for initial criteria input and BI920S02 for multi-record editing (up to 7 lines per screen, expanded from 5 to 10 tax codes per record). It operates in a loop until exit conditions are met (e.g., F3 or end of data). Below is a step-by-step breakdown of the program's flow :
- Initialization (Main Routine):
- Clear error messages (MSG1, MSG2) and set off indicators (81, 82, 90, 98).
- Handle function key KA: Set off indicators 01/02 and set on 81 (likely to enable/disable screen fields or modes).
- Handle function key KG: Execute RCDCHK subroutine (cleanup orphaned records), set on LR (last record, to exit program), and set off indicators 01/02.
- If indicator 09 is on (likely from prior validation), set on 81 (error mode).
-
Branch to screen handling: Execute S1 subroutine for screen 1 (criteria input) or S2 for screen 2 (data editing), based on indicators 01 or 02.
-
Screen 1 Processing (S1 Subroutine - BI920S01):
- Retrieve company name from BICONT using company code (CO) as key.
- If not found (indicator 99 on), display error message "INVALID COMPANY NUMBER ENTERED" and set on indicators 81/90; exit subroutine.
- Validate delivered code (DELV): Must be blank or 'Y'; otherwise, display "DELIVERED MUST BE 'Y' OR BLANK" and set on 81/90; exit.
- Clear arrays for product codes (PCD), descriptions (PDS), tax code arrays (CD1-CD0), and delete flags (DEL).
- Prepare key for reading products: Use 'PRODCD' type (commented out for GSTABL, now uses GSPROD). If start product (SPRD) is blank, use ' 01'; else use SPRD.
- Position file pointer (SETLL) on GSPROD using prepared key (KLPROD).
- Set 'FIRST' flag to 'Y' for handling special 'MISC' product on first page.
- Execute FILARA subroutine to populate arrays for display on screen 2.
-
End subroutine, returning to main loop for screen display/output.
-
Screen 2 Processing (S2 Subroutine - BI920S02):
- Loop through up to 7 array entries (Y from 1 to 7):
- If product code (PCD,Y) is blank, skip to next (bypass).
- Execute EDTXCD subroutine to validate tax codes for the entry.
- If error (90 on), exit loop early.
- Build key (PRTXKY) using company (CO), state (STAT), product (XXPROD from PCD,Y), and delivered (DELV).
- Check delete flag (DEL,Y = 'D'): Set indicator 94 on if deleting.
- Chain to BIPRTX using PRTXKY:
- If not found (99 on), not delete (N94), and not all blanks (N95): Add new record (EXCPT ADDPTX).
- If found (N99), not delete (N94), not all blanks (N95): Update record (EXCPT UPDPTX).
- If found (N99), not delete (N94), all blanks (95): No action (implicit delete by not writing).
- If found (N99) and delete (94): Delete record (EXCPT DELPTX).
- Clear all S2 arrays (PCD, PDS, CD1-CD0, DEL) for next batch.
- Check if more records: If X (counter from FILARA) = 8 (end of page batch), read previous record from GSPROD and refill arrays via FILARA; else set on 81 (end of data).
-
End subroutine, returning to main loop.
-
Tax Code Editing/Validation (EDTXCD Subroutine):
- Check if all tax codes (CD1,Y to CD0,Y) are blank: Set 95 on if yes; skip further validation and exit (record will be ignored/deleted).
- If company invoice style (BCINST from BICONT) is '2' (no sales tax allowed):
- Collect any 'T' tax codes into CODES error field.
- If CODES not blank, display "SALES TAX NOT ALLOWED IF INVOICE STYLE 2" with offending codes; set on 82/90; exit.
- Validate each tax code (CD1,Y to CD0,Y) exists in BISLTX (CHAIN using STTXCD):
- If not found (98 on), add to CODES error field.
- If CODES not blank, display "TAX CODES NOT IN 'SALES TAX MASTER FILE'" with offending codes; set on 82/90; exit.
- For 'MISC' product (PCD,Y = 'MISC'):
- Collect any non-'T' starting tax codes into CODES.
- If CODES not blank, display "TAX CODE MUST BEGIN WITH 'T'" with offending codes; set on 82/90; exit.
-
End subroutine.
-
Array Filling for Display (FILARA Subroutine):
- Initialize counter X to 0.
- Loop until X=8 (max 7 display lines + check for more):
- If first page ('FIRST'='Y'): Add 'MISC' as first entry with description "MISCELLANEOUS INVOICE LINES"; chain to BIPRTX for existing tax codes; set 'FIRST' to 'N'; bypass to next.
- Read next record from GSPROD (formerly GSTABL).
- Skip if end of file (70 on) or company mismatch (TPCONO != CO).
- Skip if not sellable product (TPSELL != 'Y').
- If X=8, exit loop (page full).
- Increment X; populate PCD,X with product code (TPPROD), PDS,X with description (TPDESC), XXPROD with TPPROD.
- Chain to BIPRTX: If found, populate tax code arrays (CD1,X to CD0,X) from record.
- If X > 0 after loop, set on 82 (data available for display).
-
End subroutine.
-
Record Cleanup (RCDCHK Subroutine - Called on F3/Exit):
- Position BIPRTX to beginning (SETLL with blank key).
- Loop reading BIPRTX records:
- Skip if end (71 on).
- For non-'MISC' products: Build key from PTCONO + PTPROD; chain to GSPROD.
- If not found in GSPROD (99 on), delete the BIPRTX record (EXCPT DELPTX).
-
End subroutine and program.
-
Output Handling:
- Screen outputs use EXFMT (implied by workstation file) with indicators controlling formats (81 for S01, 82 for S02).
- File updates use EXCPT to add/update/delete BIPRTX records.
- Program ends on LR (last record indicator).
Business Rules¶
- Company Validation: Must exist in BICONT; retrieves name (BCNAME) and invoice style (BCINST).
- Delivered Code: Must be blank (not delivered) or 'Y' (delivered); used in BIPRTX key.
- Product Selection: Only sellable products (TPSELL='Y' in GSPROD) are displayed/processed. Starts from specified product (SPRD) or ' 01'. 'MISC' is a special non-product entry for miscellaneous invoice lines, always shown first.
- Tax Codes (Up to 10 per Product): Stored in PTTXC1 to PTTXC0 in BIPRTX. Must exist in BISLTX (sales tax master). Blanks are allowed but if all blank, record is not added/updated (implicit delete).
- Invoice Style Restriction: If BCINST='2', no tax codes starting with 'T' (sales tax) allowed.
- 'MISC' Product Restriction: Tax codes must start with 'T'.
- Paging: Handles up to 7 products per screen; pages forward if more available.
- Delete Handling: 'D' in DEL array flags record for deletion. Cleanup on exit removes BIPRTX entries without matching GSPROD products.
- Error Handling: Displays specific messages for invalid inputs; sets error indicators (81,82,90) to highlight fields and prevent processing.
- Key Structure: BIPRTX keyed on company (PTCONO), state (PTSTAT), product (PTPROD), delivered (PTDELV).
Tables Used¶
The program uses the following files as tables/datasets: - BIPRTX: Product Tax Master (update file; key: company + state + product + delivered; used for add/update/delete). - GSPROD: Product Master (input file; key: company + product; replaces GSTABL; provides product codes, descriptions, sellable flag). - BICONT: Billing Control (input file; key: implied by company; provides company name, invoice style). - BISLTX: Sales Tax Master (input file; key: tax code; validates tax codes). - SCREEN: Workstation file (display file for interactive screens BI920S01 and BI920S02). - MSG: Internal array of 6 error messages (e.g., "INVALID COMPANY NUMBER ENTERED").
External Programs Called¶
None. The program does not use CALL opcodes or reference any external programs/subroutines beyond its own internal subroutines (S1, S2, EDTXCD, FILARA, RCDCHK). All operations are self-contained, with file I/O handled via CHAIN, READ, SETLL, and EXCPT.