Skip to content

BB800E RPGLE

The BB800E.rpgle.txt is an RPGLE (RPG IV) program named BB800E, designed for the Customer Order Entry system on an IBM AS/400 (iSeries) platform. It serves as a "Customer Order Instructions Inquiry" program, providing an interactive interface to query accessorial and marks instructions for customer orders or ship-to master records, using a subfile (SFL) to display data. Below, I will explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code.

Process Steps

The program follows a structured flow to manage the inquiry process for customer order instructions, organized into subroutines executed in a specific sequence:

  1. Initialization (*inzsr Subroutine):
  2. Parameters: Receives four input parameters:
    • p$co (2 characters): Company number.
    • p$csor (6 characters): Customer or order number.
    • p$ship (3 characters): Ship-to number (zero for order mode, non-zero for ship-to mode).
    • p$fgrp (1 character): File group identifier ('G' or 'Z') for file overrides.
  3. Field Setup: Initializes subfile control fields (rrn1, rrnsv1, pagsz1 set to 32), output parameters (o$mode = 'INQ', o$flag = '0'), and message handling fields (dspmsg, m@pgmq, m@key).
  4. Key Lists: Defines key lists (klc1s1, klc1s2, klc1r1, klc1r2, klordh, klcus1, klcus2, klship) for file access.
  5. File Overrides: Prepares for file overrides based on p$fgrp ('G' or 'Z').

  6. Error Handling (*pssr Subroutine):

  7. Checks for parameter errors using the program status data structure (psds##). If ps#err = 221 (invalid number of parameters), sets return = '*detc' and exits.

  8. Process Parameters (@parms Subroutine):

  9. Assigns input parameters to control fields:
    • If at least 1 parameter, sets c$co = p$co.
    • If at least 2 parameters, sets c$csor = p$csor.
    • If at least 3 parameters, sets c$ship = p$ship.
  10. Includes commented-out test values for c$co, c$csor, and c$ship for order and ship-to modes.

  11. Open Database Tables (opntbl Subroutine):

  12. Applies file overrides for arcust, bbora1, bbordh, bbshsa1, and shipto based on p$fgrp ('G' for g* files, 'Z' for z* files) using the QCMDEXC API.
  13. Opens the files with usropn for input-only access.

  14. Retrieve Data (rtvdta Subroutine):

  15. Clears display fields (c$csnm, c$shnm).
  16. Order Mode (c$ship = 0):
    • Sets header c$hdr1 to "Open Order Accessorials/Marks Inquiry" (hd1(01)).
    • Chains to bbordh using klordh to validate the order.
    • Chains to arcust using klcus1 to retrieve customer name (arname) into c$csnm.
  17. Ship-to Mode (c$ship ≠ 0):

    • Sets header c$hdr1 to "ShipTo Master Accessorials/Marks Inq." (hd1(02)).
    • Sets *in79 to indicate ship-to mode.
    • Chains to arcust using klcus2 to retrieve customer name (arname) into c$csnm.
    • Chains to shipto using klship to retrieve ship-to name (csname) into c$shnm.
  18. Process Subfile (srsfl1 Subroutine):

  19. Subfile Setup: Initializes subfile mode (sfmod1 = '1', folded, *in45 = *on), clears message subfile (clrmsg), and writes it (wrtmsg).
  20. Repositioning: Calls sf1rep to position the file and load initial records.
  21. Overlay: Writes an assume-overlay record (wdwovr).
  22. Main Loop (sf1agn):
    • Repositions the subfile if repsfl is on, using r$rcid (sf1rep).
    • Displays the message subfile if errors exist (wrtmsg).
    • Sets *in41 (SFLDSP) based on whether subfile records exist (rrn1 > 0).
    • Sets folded/unfolded mode (*in45) based on sfmod1.
    • Writes the command line (sflcmd1), sets *in40 (SFLDSPCTL), and displays the subfile control format (sflctl1) using exfmt.
    • Clears message subfile (clrmsg, msgclr) if errors exist.
    • Clears format indicators (*in50-69, *in21-39).
    • Sets the subfile record number (rcdnb1) to pagrrn for proper page redisplay.
  23. User Input Handling:

    • F03 (Exit): Exits the loop (sf1agn = *off).
    • F12 (Return): Exits the loop (sf1agn = *off).
    • Enter Key: Processes subfile selections (sf1prc).
    • User Positioning: If c$rcid ≠ 0, repositions the subfile (sf1rep).
    • F10: Clears cursor position (row1, col1) and sets *in69.
    • Page Down: Commented out, but would load additional records (sf1lod).
  24. Subfile Processing (sf1prc Subroutine):

  25. If rrn1 > 0, reads subfile records (readc sfl1) and processes changes (sf1chg) for each record (*in81 = *off).

  26. Subfile Record Change (sf1chg Subroutine):

  27. Currently empty, with commented-out logic for processing option 5 (s1sel = 5) via sf1s05, suggesting limited or disabled selection functionality.

  28. Subfile Repositioning (sf1rep Subroutine):

  29. Clears the subfile (sf1clr) and validates control fields (sf1cte).
  30. If no errors (*in50 = *off):

    • In order mode (c$ship = 0), positions bbora1 using klc1s1.
    • In ship-to mode, positions bbshsa1 using klc1s2.
    • Retains c$rcid in r$rcid and clears c$rcid.
    • Loads subfile records (sf1lod).
  31. Control Field Validation (sf1cte Subroutine):

    • Empty, with commented-out validation for a model field (c$modl) against inmodl, suggesting potential for future validation (e.g., error 'ERR0900').
  32. Subfile Loading (sf1lod Subroutine):

    • Sets rrn1 to the last saved record number (rrnsv1) and rcdnb1 to rrn1 + 1.
    • Loads up to pagsz1 (32) records:
    • In order mode, reads bbora1 using klc1r1.
    • In ship-to mode, reads bbshsa1 using klc1r2.
    • If end of file (*in43 = *on), adjusts rcdnb1 and exits the loop.
    • Formats each record (sf1fmt) and writes to the subfile.
    • Saves the last record number (rrnsv1) and clears cursor position (row1, col1).
  33. Subfile Formatting (sf1fmt Subroutine):

    • Clears the subfile record and populates fields from bbora1 or bbshsa1:
    • s1rcid: Record ID (barcid).
    • s1qty: Quantity (baqty).
    • s1desc: Description (badesc).
    • s1tcst: Total cost (batcst).
    • s1rccd: Reason code (barccd).
    • s1pick: Pick flag (bapick = 'Y').
    • s1dsph: Dispatch flag (badsph = 'Y').
    • s1bol: Bill of lading flag (babol = 'Y').
    • s1inv: Invoice flag (bainv = 'Y').
    • s1cost: Cost indicator (batcst ≠ 0, sets *in71).
  34. Subfile Protection (sf1pro Subroutine):

    • Empty, indicating no specific protection logic (though *in70 is defined for global protect in inquiry mode).
  35. Message Handling:

    • Add Message (addmsg): Sends error messages to the program message queue using QMHSNDPM.
    • Write Message (wrtmsg): Displays the message subfile (msgctl).
    • Clear Message (clrmsg): Clears the message subfile using QMHRMVPM, preserving rcdnam and pagrrn.
  36. Program Termination:

    • Closes all files (close *all).
    • Sets *inlr = *on and returns.

Business Rules

  1. Operation Modes:
  2. Order Mode (p$ship = 0): Queries accessorial/marks instructions for a customer order using bbora1. Displays header "Open Order Accessorials/Marks Inquiry."
  3. Ship-to Mode (p$ship ≠ 0): Queries instructions for a customer ship-to using bbshsa1. Displays header "ShipTo Master Accessorials/Marks Inq." and sets *in79.

  4. Data Validation:

  5. Validates customer (bocust or c$csor) against arcust to retrieve arname.
  6. In order mode, validates order (c$csor) against bbordh.
  7. In ship-to mode, validates ship-to (c$ship) against shipto to retrieve csname.
  8. Commented-out validation for c$modl suggests potential for model-specific checks.

  9. Subfile Management:

  10. Displays up to 32 records per page (pagsz1).
  11. Supports folded/unfolded display modes (*in45).
  12. No "No Results" message logic, unlike BI890P.

  13. Navigation and Input:

  14. F03: Exits the program.
  15. F12: Returns, exiting the loop.
  16. F10: Positions cursor to the control record and sets *in69.
  17. Enter: Processes subfile selections (though sf1chg is currently empty).
  18. Positioning: Repositions the subfile if c$rcid ≠ 0.
  19. Page Down: Commented out, but would load additional records.

  20. Inquiry-Only:

  21. Operates in inquiry mode (o$mode = 'INQ'), with *in70 defined for global field protection.
  22. No update or create functionality (no options like 1, 2, or 3 as in BI890P).

  23. Error Handling:

  24. Displays errors in a message subfile (msgctl) using QMHSNDPM.
  25. Clears messages after each display cycle (clrmsg).
  26. Parameter errors (ps#err = 221) trigger program exit.

Tables (Files) Used

The program uses the following database files (tables) with input-only access (if and usropn): 1. arcust: Customer master file (contains customer data, e.g., arname). 2. bbora1: Order accessorial/marks file (contains order instructions, e.g., barcid, baqty, badesc, batcst, barccd, bapick, badsph, babol, bainv). 3. bbordh: Order header file (contains order data, e.g., bocust). 4. bbshsa1: Ship-to accessorial/marks file (contains ship-to instructions, similar fields to bbora1). 5. shipto: Ship-to master file (contains ship-to data, e.g., csname). 6. bb800ed: Display file (workstation file with subfile sfl1 and formats sflctl1, sflcmd1, msgctl, msgclr, wdwovr).

External Programs Called

The program calls the following external programs (all system APIs): 1. QCMDEXC: Executes file override commands (ovrdbf) for arcust, bbora1, bbordh, bbshsa1, and shipto. 2. QMHSNDPM: Sends error messages to the program message queue. 3. QMHRMVPM: Clears messages from the program message queue.

Summary

The BB800E program is an inquiry-only tool for displaying accessorial and marks instructions for customer orders (bbora1) or ship-to master records (bbshsa1). It: - Operates in order or ship-to mode based on p$ship. - Uses a subfile to display up to 32 records, with navigation via function keys (F03, F10, F12). - Validates customer and order/ship-to data, retrieving names for display. - Applies file overrides based on p$fgrp ('G' or 'Z'). - Includes minimal error handling and no update functionality.

The program integrates with arcust, bbora1, bbordh, bbshsa1, and shipto files, using system APIs for file and message handling. The commented-out logic suggests potential for additional features (e.g., search, selection options) that are currently disabled.

If you need further analysis or have additional context (e.g., related programs like BI9002), please let me know!