Skip to content

BI907 RPGLE

The provided RPGLE program, BI907, is a core component of the Bradford Order Entry/Invoices system, designed for customer and ship-to file maintenance and inquiry. It is called by the BI907C CLP program, which sets up a temporary work file and passes parameters to BI907. This program manages a subfile-based interface to allow users to maintain or inquire about customer/ship-to product descriptions and freight terms. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.


Process Steps of the BI907 RPGLE Program

The BI907 program is an interactive workstation program that uses a display file (bi907d) with a subfile (sfl1) to present and manage customer/ship-to data. It operates in either maintenance (MNT) or inquiry (INQ) mode, with functionality to add, update, or delete records, and includes features like field prompting, history inquiry, and copy functionality. The process steps are as follows:

  1. Initialization (*inzsr Subroutine):
  2. Receives input parameters: p$co (company number), p$cst (customer number), p$shp (ship-to number), p$mode (run mode: MNT or INQ), and p$fgrp (file group: Z or G).
  3. Retrieves the local data area (lda) to access environment information (e.g., tstprd for test/production indicator).
  4. Sets the header (c$hdr1) based on the mode: "Customer & Ship To File Maint" for MNT, or "Customer & Ship To File Inquiry" for INQ.
  5. Sets global protection indicator (*in71) to protect input fields in inquiry mode (INQ).
  6. Initializes subfile control fields (rrn1, rrnsv1), page size (pagsz1 = 12), and mode flags (c1mode, s1updt, s1f10d).
  7. Checks if a record exists in arcupr using the key list kls1s1 (company, customer, ship-to):
    • If found, sets to "Update Mode" (*in87 = *on, s1f10d = "F10=All Mode", c1mode = "Update Mode").
    • If not found, sets to "All Mode" or "Add Mode" based on p$mode and protection settings.
  8. Sets the current date and time using the TIME operation, formatting it into the t#cymd data structure.

  9. Open Database Tables (opntbl Subroutine):

  10. Applies file overrides based on the p$fgrp parameter (Z or G) for files gstabl, arcupr, bicont, gsprod, arcust, shipto, and arcuphs using the QCMDEXC API.
  11. Opens these files with the usropn option for input or update, and opens bi907w without override (as it is in QTEMP).
  12. Files are opened for read-only (if) or read/write (uf) access as needed.

  13. Subfile Processing (srsfl1 Subroutine):

  14. Clear Message Subfile: Calls clrmsg to clear messages and wrtmsg to write the message control record.
  15. Default Values: Sets the default company number (c1cono = 10).
  16. Position File: Calls sf1rep to position the file cursor based on input parameters.
  17. Suppress Initial Errors: Clears error indicators and messages on the first display (w$frst = *on).
  18. Main Loop (sf1agn):

    • Repositions the subfile if needed (repsfl = *on) by updating control fields (c1prod, c1cnty) and calling sf1rep.
    • Sets cursor position for add mode (row1 = 10, col1 = 02, *in75 = *on) or clears it for other modes.
    • Displays the command line (sflcmd1) and message subfile (msgctl or msgclr).
    • Checks if the subfile has records (rrn1 > 0) to enable display (*in41).
    • Writes and formats the subfile control record (sflctl1) using exfmt.
    • Clears message subfile if errors are present.
    • Processes user input via function keys or direct access:
    • F03: Exits the program.
    • F04: Prompts for field input (calls prompt for control or subfile fields).
    • F05: Refreshes the subfile by clearing r$cnty and repositioning.
    • F08: Copies alternate descriptions (sf1cpy).
    • F09: Calls history inquiry (histinq).
    • F10: Toggles between "Add Mode," "Update Mode," and "All Mode" (c1mode, s1updt, *in87, s1f10d).
    • ENTER: Processes subfile changes (sf1pro).
    • Updates cursor location (row1, col1) and subfile record number (rcdnb1) for redisplay.
  19. Field Prompting (prompt Subroutine):

  20. Handles prompting for fields in SFLCTL1 or SFL1:
    • For C1CUST or C1SHIP: Calls LARCUST or LCSTSHP to select customer or ship-to.
    • For S1PROD or C1PROD: Calls LGSPROD to select a product.
    • For S1FRCD: Calls LTABLE to select a freight code.
    • For S1CNTY: Calls LTABLE to select a container type.
  21. Updates fields with selected values and sets *in19 for input change.

  22. Subfile Processing (sf1pro Subroutine):

  23. Reads changed subfile records (readc sfl1) if rrn1 > 0.
  24. Validates input (sf1val) for fields like freight code (s1frcd), container type (s1cnty), and separate freight (s1sfrt).
  25. Updates or adds records to arcupr or bi907w based on the mode (s1updt).
  26. Writes history records to arcuphs for changes or deletions.
  27. Updates the subfile with formatted data (sf1fmt) and applies color coding (sf1col).

  28. Reposition Subfile (sf1rep Subroutine):

  29. Clears the subfile (sf1clr) and resets rrn1.
  30. Loads records into the subfile (sf1lod) based on key lists (kls1s1, kls1s2).
  31. Filters records by company, customer, ship-to, product, and container type.

  32. Load Subfile Records (sf1lod Subroutine):

  33. Reads records from arcupr or bi907w based on key lists.
  34. Filters records based on mode and user input (e.g., c1prod, c1cnty).
  35. Formats each record (sf1fmt) and applies color coding (sf1col).
  36. Writes records to the subfile, incrementing rrn1.

  37. Validate Subfile Input (sf1val Subroutine):

  38. Validates freight code (s1frcd) against gstabl (table type BBFRCD).
  39. Validates container type (s1cnty) against gstabl (table type CNTRTY).
  40. Enforces business rules for freight codes (e.g., C requires s1sfrt and s1cafr to be Y, N, or blank; A requires s1sfrt = 'Y').
  41. Sets error indicators and messages for invalid inputs.

  42. Copy Alternate Description (sf1cpy Subroutine):

  43. Copies product descriptions from an alternate customer/ship-to pair to the current record.
  44. Updates the subfile and writes history records.

  45. History Inquiry (histinq Subroutine):

    • Calls GB730P to display historical data for the selected customer/ship-to/product.
  46. Message Handling:

    • Add Message (addmsg): Sends error messages to the program message queue using QMHSNDPM.
    • Write Message Subfile (wrtmsg): Displays the message subfile.
    • Clear Message Subfile (clrmsg): Clears messages using QMHRMVPM.
  47. Program Termination:

    • Closes all open files.
    • Sets *inlr = *on and returns.

Business Rules

The BI907 program enforces the following business rules:

  1. Mode-Based Processing:
  2. In MNT mode, users can add, update, or delete records; input fields are editable (*in71 = *off).
  3. In INQ mode, fields are protected (*in71 = *on), allowing only viewing of records.

  4. Freight Code Validation (JB01, JB02 Revisions):

  5. Freight code (s1frcd) must exist in gstabl (table type BBFRCD).
  6. For freight code C (freight collect):
    • Separate freight (s1sfrt) and calculate freight (s1cafr) must be Y, N, or blank.
  7. For freight code A (non-Bradford location, e.g., Anchor):
    • Separate freight (s1sfrt) must be Y.
  8. For freight code CYY (freight collect with service fee, JB02):

    • Represents a situation where shipping is arranged by ARG but billed to the customer by the carrier, with a $100 service fee charged to the customer.
  9. Container Type Validation:

  10. Container type (s1cnty) must exist in gstabl (table type CNTRTY).

  11. Record Existence and Deletion:

  12. Prevents adding a record if it already exists or is marked as deleted.
  13. Allows reactivation of deleted records.
  14. Records deleted or reactivated are logged in arcuphs for history.

  15. Mode Toggling:

  16. Users can toggle between "Add Mode," "Update Mode," and "All Mode" using F10, controlling whether new records can be added or existing records updated.

  17. File Group Flexibility:

  18. Supports different file sets (Z or G) via overrides, allowing the program to work with different data environments.

  19. Error Handling:

  20. Validates all user inputs and displays specific error messages (e.g., "Invalid Freight Code," "Must Enter At Least One Product Code in ADD Mode").
  21. Ensures at least one product code is entered in add mode.

Tables Used

The program uses the following database files, opened with the usropn option and overridden based on the file group (Z or G): 1. gstabl: - Purpose: Stores table data for freight codes (BBFRCD) and container types (CNTRTY). - Used in: sf1val to validate s1frcd and s1cnty. - Override: ggstabl (G group) or zgstabl (Z group). - Access: Input (if).

  1. arcupr:
  2. Purpose: Stores customer/ship-to cross-reference data.
  3. Used in: sf1rep, sf1lod, sf1pro for reading, adding, or updating records.
  4. Override: garcupr (G group) or zarcupr (Z group).
  5. Access: Update (uf a).

  6. bicont:

  7. Purpose: Stores company information.
  8. Used in: Validates company number (c1cono).
  9. Override: gbicont (G group) or zbicont (Z group).
  10. Access: Input (if).

  11. gsprod:

  12. Purpose: Stores product information.
  13. Used in: sf1fmt to retrieve product descriptions (tpdesc).
  14. Override: ggsprod (G group) or zgsprod (Z group).
  15. Access: Input (if).

  16. arcust:

  17. Purpose: Stores customer master data.
  18. Used in: sf1val to validate customer numbers.
  19. Override: garcust (G group) or zarcust (Z group).
  20. Access: Input (if).

  21. shipto:

  22. Purpose: Stores ship-to data.
  23. Used in: sf1val to validate ship-to codes.
  24. Override: gshipto (G group) or zshipto (Z group).
  25. Access: Input (if).

  26. arcuphs:

  27. Purpose: Stores history records for customer/ship-to changes.
  28. Used in: sf1pro to log changes or deletions.
  29. Override: garcuphs (G group) or zarcuphs (Z group).
  30. Access: Output (o).

  31. bi907w:

  32. Purpose: Temporary work file in QTEMP for processing customer/ship-to data.
  33. Used in: sf1pro, sf1lod for temporary storage and processing.
  34. Access: Update (uf a).

External Programs Called

The BI907 program calls the following external programs: 1. LARCUST: - Purpose: Prompts for customer selection. - Called in: prompt subroutine for C1CUST. - Parameters: o$co (company), o$cust (customer), o$fgrp (file group).

  1. LCSTSHP:
  2. Purpose: Prompts for ship-to selection.
  3. Called in: prompt subroutine for C1SHIP.
  4. Parameters: x$cstshp (data structure with company, search, customer, ship-to, flag, file group).

  5. LGSPROD:

  6. Purpose: Prompts for product selection.
  7. Called in: prompt subroutine for S1PROD and C1PROD.
  8. Parameters: o$co (company), o$prod (product), o$fgrp (file group).

  9. LTABLE:

  10. Purpose: Prompts for table codes (freight code or container type).
  11. Called in: prompt subroutine for S1FRCD and S1CNTY.
  12. Parameters: o$tbcd (table code), o$tbty (table type), o$flag (flag).

  13. GB730P:

  14. Purpose: Displays historical data for customer/ship-to/product.
  15. Called in: histinq subroutine.
  16. Parameters: x$arcuprhist (data structure with file, file group, company, customer, ship-to, product, container type).

  17. QCMDEXC:

  18. Purpose: Executes file override commands.
  19. Called in: opntbl subroutine.
  20. Parameters: dbov## (override command), dbol## (command length).

  21. QMHSNDPM:

  22. Purpose: Sends messages to the program message queue.
  23. Called in: addmsg subroutine.
  24. Parameters: m@id (message ID), m@msgf (message file), m@data (message data), m@l (data length), m@type (message type), m@pgmq (program queue), m@scnt (stack counter), m@key (message key), m@errc (error code).

  25. QMHRMVPM:

  26. Purpose: Removes messages from the program message queue.
  27. Called in: clrmsg subroutine.
  28. Parameters: m@pgmq (program queue), m@scnt (stack counter), m@rmvk (message key), m@rmv (remove option), m@errc (error code).

Summary

The BI907 RPGLE program is a comprehensive tool for maintaining and inquiring about customer/ship-to data within the Bradford Order Entry/Invoices system. It provides a subfile-based interface for adding, updating, or viewing records, with robust validation for freight codes, container types, and other fields. The program supports special freight scenarios (e.g., non-Bradford locations, freight collect with service fees) and logs changes to a history file. It integrates with multiple database files and external programs for prompting and history inquiry, ensuring flexibility and user interaction. The temporary work file in QTEMP (set up by BI907C) supports processing, and file overrides allow operation across different data environments (Z or G).