Skip to content

BB850 RPG36

Process Steps of the RPG Program (BB850)

This RPG program (BB850) is an interactive inquiry tool for viewing historical rack pricing data for products, based on user-input keys like company, location, product code, container, and unit of measure. It runs on an IBM midrange system (e.g., AS/400), using a workstation file (SCREEN) for display and input, and chains to various database files for validation and data retrieval. The program handles multiple screens (S1 for input, S2 for history display, S5 for product lookup) and supports navigation (e.g., roll up/down for paging through history). It initializes arrays to hold up to 5 records per page and manages rolling through historical data.

The high-level process steps are as follows:

  1. Program Initialization ($SBLK Subroutine):
  2. Called on first run to blank the screen and set default values (e.g., company=10, location='001', container='001', unit='GAL').
  3. Initializes arrays for dates (DTE), times (TME), prices (PRC1-4), quantities (QTL1-4, MNQT), and flags (RKRQ for no rack price required, INAC for inactive).
  4. Sets cursor position to product field and prepares for Screen S1 display.

  5. Main Loop and Screen Handling:

  6. Loops until exit (DOWNE 'EJ' for end job).
  7. Determines the current screen (@SFID) and calls the appropriate subroutine ($S1, $S2, $S5) based on the screen just read.
  8. Handles exceptions ($XCPT) by displaying the next screen (@SFNEX), incrementing a counter (@CCNT), and clearing indicators.
  9. Reads the workstation file (SCREEN) for user input, with LR (last record) indicator for end-of-file handling.

  10. Input Screen Processing (S1 - $S1 Subroutine):

  11. Handles ENTER ($S1ENT) or command keys ($S1CK).
  12. Validates input fields:
    • Chains to BICONT for company validation (must exist and have invoicing style '5').
    • Chains to INLOC for location validation.
    • If product code is blank, triggers product lookup (S5) via $S5FIL.
    • Chains to GSPROD for product validation (replaces old GSTABL chain).
    • For non-fluid products (TPFLCD='N'), ensures container is blank.
    • Chains to GSCTUM for container/unit of measure validation against the product.
  13. If validation fails, displays error messages (e.g., "INVALID COMPANY") and sets indicators (e.g., 90 for error, cursor positioning).
  14. If valid, resets file pointer (SETLL on BBPRCE using a limit key RKLIM), clears fields ($CLRFLD), fills history arrays ($S2FIL), and switches to S2.

  15. History Display Screen Processing (S2 - $S2 Subroutine):

  16. Handles ENTER/roll up ($S2ENT - fetches next 5 records), roll down ($S2RBW - fetches previous 5 records), or command keys ($S2CK).
  17. In $S2FIL: Reads previous records (READP on BBPRCE), skips deleted records (RKDEL='D'), populates arrays with date/time, prices, quantities, and flags. Stops at 5 records per page or end-of-file.
  18. Manages paging with hold arrays (HDT/HTM) for date/time tracking across pages.
  19. If no more records, switches back to S1.

  20. Product Lookup Screen Processing (S5 - $S5 Subroutine):

  21. Called if product code is blank in S1.
  22. In $S5FIL: Prepares parameters (company, customer=0, ship=0, product='D* ', description from input) and calls external program BB1016 to populate lookup arrays (S5L for line, S5P for product, S5D for description, S5A for alt description, S5F flag).
  23. Handles ENTER ($S5ENT): If a line is selected (LINE# >0), copies selected product to KYPROD and returns to S1; else, fetches next page via BB1016.
  24. Handles command keys ($S5CK): KA returns to S1 with fields cleared.

  25. Command Key and Exit Handling:

  26. KG (likely F3 or similar) sets 'EJ' to exit the main loop.
  27. KA returns to S1 with fields cleared.
  28. Clears indicators and messages ($CLRIND) before each display.

  29. Output and Termination:

  30. Outputs to SCREEN via EXCPT for each format (S1, S2, S5), including key fields, names/descriptions, array data, and messages.
  31. Program ends when main loop exits (e.g., via KG), with LR set on final read.

The program is interactive and stateful, relying on user input for inquiries and navigation. It does not update data—only reads and displays.

Business Rules

The program enforces several business logic rules, primarily around data validation and display for price history inquiries:

  • Key Composition and Validation:
  • Inquiry key is composite: Company (2 digits), Location (3), Product (4), Container (3), Unit of Measure (3).
  • Company must exist in BICONT and have invoicing style '5' (BCINST='5'); otherwise, invalid.
  • Location must exist in INLOC for the company.
  • Product must exist in GSPROD; description is displayed from TPDESC.
  • Container/Unit must match product in GSCTUM (via CTUMKY chain).
  • For non-fluid products (TPFLCD='N' in GSPROD), container must be blank (enforced post-JK02 change).

  • Product Lookup:

  • If product code is blank, invoke lookup (S5) using partial description (KYPRDS).
  • Lookup supports up to 15 lines (S5L array), with product code, description, and customer alt description.
  • Selection via LINE# copies product code back to input.

  • Price History Retrieval and Display:

  • History from BBPRCE, keyed by RKKEY (company+location+product+container+unit).
  • Skips deleted records (RKDEL='D').
  • Displays up to 5 records per page, with fields: Date (CYMD converted to MM/DD/YY), Time (HH:MM), Rack Prices (4 levels, decimal), Qty Levels (4 levels + min qty), Flags (RKRQ='N' for no rack price, INAC='I' for inactive).
  • Paging: Roll up for next, roll down for previous; tracks position with hold arrays (HDT/HTM up to 200 pages).
  • End-of-file displays message "END OF FILE HAS BEEN REACHED".

  • Error Handling:

  • Specific messages for invalid inputs (e.g., "INVALID PRODUCT", "CONTAINER CODE MUST BE BLANK FOR NF").
  • Sets indicators (e.g., 90 for general error, 71-74 for field-specific cursor positioning).
  • No data modifications—read-only inquiry.

  • Y2K Compliance:

  • Uses UDS fields for century (Y2KCEN='19') and compliance (Y2KCMP='80'), likely for date handling.

  • Changes from Modifications:

  • VV04: Enforces blank container for non-fluid.
  • JB05: Adds display for 'NO RACK PRICE' (RKRQ) and inactive flags (INAC).
  • JB06: Enlarges price fields.
  • JK01: Adds S5F parameter to BB1016 call.
  • JK02: Switches product validation from GSTABL to GSPROD.

Tables Used

In RPG, "tables" refer to database files (physical or logical) used for input/output. The program defines the following files (all input-only 'IF' except SCREEN as workstation 'CD'):

  • SCREEN: Workstation file for interactive display/input (formats: BB850S1, BB850S2, BB850S5).
  • BBPRCE: Price history file (keyed, used for chaining and reading historical records).
  • BICONT: Company file (keyed, for company name and invoicing style validation).
  • INLOC: Location file (keyed, for location name validation).
  • GSCTUM: Customer unit master file (keyed, for container/unit validation against product).
  • GSPROD: Product file (keyed, for product description and fluid code; replaced GSTABL per JK02).
  • GSTABL: Commented out (old product table, replaced by GSPROD).

External Programs Called

  • BB1016: Called for product description lookup in $S5FIL. Parameters include company, customer, ship-to, product wildcard, description search, arrays for results, flag (S5F), and program name ('BB850'). It populates the S5 lookup arrays.