Skip to content

IN805 RPGLE

The IN805.rpgle.txt document is an RPGLE (RPG IV) program called from the BB101.ocl36.txt OCL program in an IBM System/36 or AS/400 (now IBM i) environment. It is part of the Customer Orders and Inventory system, designed to perform inventory balances inquiry, displaying available inventory for products and containers and checking sufficiency for orders. Written by Dave Capo on 08/25/2014, it includes revisions for tank reading date validation (jk01), screen expansion (jk02), allocated totals calculation (jk04), and container weight file integration (jb05, jk05). Below is a detailed explanation of the process steps, business rules, tables (files) used, and external programs called.


Process Steps of the RPGLE Program

The IN805 program queries inventory balances for products and containers, displays results in subfiles on the in805d display file, and checks if sufficient inventory exists for an order based on the input mode (p$mode). The steps are as follows:

  1. Program Initialization:
  2. File Definitions:
    • in805d: Work station file (display file) with subfiles sfl1 and sfl2, user-opened.
    • in805w: Work file in qtemp for temporary data (user-opened).
    • bbordh: Input-only file for order headers (keyed, user-opened).
    • bborpx: Input-only file for order product cross-reference (keyed, user-opened).
    • gscntr: Input-only file for container data (keyed, user-opened).
    • gsctum: Input-only file for customer unit of measure data (keyed, user-opened).
    • gsctwt: Input-only file for container weight data (keyed, user-opened, added in jb05/jk05).
    • gsprod: Input-only file for product data (keyed, user-opened).
    • incont: Input-only file for inventory container data (keyed, user-opened).
    • inloc: Input-only file for inventory location data (keyed, user-opened).
    • inmtaj: Input-only file for inventory major adjustments (keyed, user-opened).
    • inmtrdy: Input-only file for inventory meter readings (keyed, user-opened).
    • intank: Input-only file for tank inventory data (keyed, user-opened).
    • intkrv: Input-only file for tank receiving data (keyed, user-opened).
    • sa5movd3: Input-only file for movement details (keyed, user-opened).
    • sa5shz: Input-only file for shipment history (keyed, user-opened).
    • gsumcv: Input-only file for unit measure conversion (keyed, user-opened).
    • bicont: Input-only file for bill of lading containers (keyed, user-opened).
    • arcust: Input-only file for customer data (keyed, user-opened).
    • shipto: Input-only file for ship-to data (keyed, user-opened).
    • bborcl: Input-only file for order close data (keyed, user-opened).
  3. Data Structures and Fields:
    • m@80: Array for message data (80 elements, 1 character each).
    • ovr, ovg, ovz: Arrays for file overrides for in805w (qtemp), and other files in production (g*) or alternate (z*) libraries.
    • com: Array for error messages (4 elements: "No Results", "Totl Gal In Trn---->", "Totl Alloc Gal/Ctn->", "Not enough Prod to fill order", COM,01-04).
    • Field prefixes: f$ (panel fields), c$ (subfile control), s1/s2 (subfile fields), k$ (key lists), p$ (input parameters), o$ (output parameters), r$ (reposition subfile), w$ (work fields).
  4. Key Lists:
    • klordh: For bbordh (company boco, customer bocust, order number bordno, jk08).
    • Other key lists (assumed, not shown) for chaining to inventory and order files.
  5. Indicators:

    • 19: Panel format input change.
    • 21-39, 50-69: Screen errors.
    • 40: Subfile clear.
    • 41: Subfile display control.
    • 42: Subfile display.
    • 43: Subfile end and next change.
    • 49: Message subfile display/control/initialize/end.
    • 70-79: Input field protect.
    • 80: Primary file chain.
    • 81: Read subfile.
    • 90-99: Secondary file chain/read.
  6. Parameter Input:

  7. Receives input parameters via *ENTRY PLIST (assumed, not shown) including:
    • p$mode (1 character): Mode of operation ("1", "2", "3").
    • p$co (company), p$prod (product), p$cntr (container), p$ord# (order number, jk04), p$qty (quantity).
  8. p$mode determines behavior:

    • "1": Always display inquiry (jk06).
    • "2": Display inquiry only if insufficient product exists for the order (jk06).
    • "3": Send message if insufficient product exists for the order (jb07).
  9. Inventory Inquiry Processing:

  10. Opens files (bbordh, bborpx, gscntr, gsctum, gsctwt, gsprod, incont, inloc, inmtaj, inmtrdy, intank, intkrv, sa5movd3, sa5shz, gsumcv, bicont, arcust, shipto, bborcl).
  11. Chains to bbordh using klordh to retrieve order details (company, customer, order number, jk08).
  12. Queries inventory files (incont, inloc, intank, intkrv, inmtrdy, inmtaj) to calculate available inventory for the product (p$prod) and container (p$cntr).
  13. Calculates in-transit totals from sa5movd3 (jk01).
  14. Calculates allocated totals from bborpx and bbordh, excluding the current order number (p$ord#) to avoid double-counting (jk04).
  15. Converts gallons to containers using gsctwt (jb05, jk05).
  16. Validates tank reading dates against system date (cannot be future-dated, jk01).

  17. Inventory Sufficiency Check:

  18. Compares available inventory (in gallons or containers) to the order quantity (p$qty).
  19. If insufficient:
    • For p$mode="2", displays inquiry with details (jk06).
    • For p$mode="3", sets output message "Not enough Prod to fill order" (COM,04, jb07).
  20. If sufficient or p$mode="1", proceeds to display inquiry regardless (jk06).

  21. Subfile Population and Display:

  22. Clears subfiles (*in40) and initializes relative record numbers (rrn1, rrn2).
  23. Populates subfiles:
    • sfl1: Displays inventory details (e.g., location, product, container, available quantity, in-transit totals [COM,02], allocated totals [COM,03]).
    • sfl2: Displays additional details (e.g., tank readings, adjustments).
  24. Writes subfile control formats and displays subfiles (*in41, *in42) using exfmt on the expanded 27x132 screen (jk02).
  25. Displays "No Results" (COM,01) if no inventory data is found.

  26. External Program Calls:

  27. Calls IN110C and IN805BC to retrieve additional inventory data or perform calculations (jk02, jk03).
  28. Passes relevant parameters (e.g., company, product, container, order number).

  29. Program Termination:

  30. Sets the last record indicator (LR) to exit the program.
  31. Returns output parameters (o$ fields, assumed), including messages for insufficient inventory (p$mode="3").

Business Rules

The program enforces the following business rules:

  1. Inventory Inquiry Modes:
  2. p$mode="1": Always displays inventory inquiry regardless of sufficiency (jk06).
  3. p$mode="2": Displays inquiry only if insufficient product exists for the order (jk06).
  4. p$mode="3": Sends a message ("Not enough Prod to fill order", COM,04) if insufficient product exists (jb07).

  5. Inventory Calculations:

  6. Calculates available inventory from incont, intank, intkrv, inmtrdy, and inmtaj.
  7. Includes in-transit totals from sa5movd3 (jk01).
  8. Calculates allocated totals from bborpx and bbordh, excluding the current order (p$ord#, jk04).
  9. Converts gallons to containers using gsctwt (jb05, jk05).

  10. Data Validation:

  11. Validates tank reading dates in inmtrdy to ensure they are not future-dated (jk01).
  12. Validates company, product, container, customer, and ship-to data using gsprod, gscntr, gsctum, arcust, and shipto.

  13. File Overrides:

  14. Uses override arrays (ovr, ovg, ovz) to redirect files to qtemp (in805w) or production (g*) or alternate (z*) libraries.
  15. Ensures correct file access based on the environment.

  16. Error Handling:

  17. Displays "No Results" (COM,01) if no inventory data is found.
  18. Displays in-transit and allocated totals (COM,02, COM,03) in the subfile.
  19. Sends "Not enough Prod to fill order" (COM,04) for insufficient inventory in p$mode="3".

  20. Inquiry Mode:

  21. Protects input fields (*in70) in inquiry mode, allowing only review of data.

Tables (Files) Used

The program interacts with the following files:

  1. in805d: Work station file (display file) with subfiles sfl1 and sfl2.
  2. Fields: f$ (panel), c$ (subfile control), s1/s2 (subfile data).
  3. in805w: Temporary work file in qtemp.
  4. Used for intermediate data storage.
  5. bbordh: Input-only order header file (keyed, user-opened).
  6. Fields: boco (company), bocust (customer), bordno (order number).
  7. bborpx: Input-only order product cross-reference file (keyed, user-opened).
  8. Used for allocated quantity calculations.
  9. gscntr: Input-only container file (keyed, user-opened).
  10. Contains container data.
  11. gsctum: Input-only customer unit of measure file (keyed, user-opened).
  12. Contains unit of measure data.
  13. gsctwt: Input-only container weight file (keyed, user-opened, jb05/jk05).
  14. Used for gallon-to-container conversion.
  15. gsprod: Input-only product file (keyed, user-opened).
  16. Contains product data.
  17. incont: Input-only inventory container file (keyed, user-opened).
  18. Contains container inventory data.
  19. inloc: Input-only inventory location file (keyed, user-opened).
    • Contains location data.
  20. inmtaj: Input-only inventory major adjustments file (keyed, user-opened).
    • Contains adjustment data.
  21. inmtrdy: Input-only inventory meter readings file (keyed, user-opened).
    • Contains tank reading data.
  22. intank: Input-only tank inventory file (keyed, user-opened).
    • Contains tank inventory data.
  23. intkrv: Input-only tank receiving file (keyed, user-opened).
    • Contains receiving data.
  24. sa5movd3: Input-only movement details file (keyed, user-opened).
    • Contains in-transit data.
  25. sa5shz: Input-only shipment history file (keyed, user-opened).
    • Contains shipment history data.
  26. gsumcv: Input-only unit measure conversion file (keyed, user-opened).
    • Contains conversion factors.
  27. bicont: Input-only bill of lading container file (keyed, user-opened).
    • Contains container data for BOL.
  28. arcust: Input-only customer file (keyed, user-opened).
    • Contains customer data.
  29. shipto: Input-only ship-to file (keyed, user-opened).
    • Contains ship-to data.
  30. bborcl: Input-only order close file (keyed, user-opened).
    • Contains order close status.

External Programs Called

The program calls the following external programs:

  1. IN110C:
  2. Called to retrieve additional inventory data or perform related calculations (jk02).
  3. Parameters: Assumed to include company, product, container, etc.
  4. IN805BC:
  5. Called for specific inventory balance calculations or data retrieval (jk02, jk03).
  6. Parameters: Assumed to include company, product, container, order number, etc.

Summary

The IN805 RPGLE program, called from the BB101.ocl36.txt OCL program, performs inventory balances inquiry for the Customer Orders and Inventory system. It checks product/container availability, calculates in-transit and allocated totals, and displays results in subfiles, with modes to always display (p$mode="1"), display on insufficiency (p$mode="2"), or send messages (p$mode="3"). Business rules enforce inventory calculations, date validation, and mode-specific behavior. The program interacts with 21 files and calls IN110C and IN805BC for additional processing, ensuring accurate inventory checks for order fulfillment.