Skip to content

BB910 RPGLE

The RPG program BB910 is designed for the maintenance and inquiry of the National Diesel Fuel Index within the Brandford Order Entry/Invoices system. It uses subfiles (SFL1 and SFL2) to display and manage data interactively, supporting both inquiry (INQ) and maintenance (MNT) modes. Below is a detailed explanation of the process steps, followed by a list of external programs called and tables used.


Process Steps of the BB910 RPG Program

  1. Program Initialization (*INZSR):
  2. Receives Entry Parameters:
    • a$co: Company code (2 characters).
    • p$mode: Run mode, either 'MNT' (maintenance) or 'INQ' (inquiry).
    • p$fgrp: File group, either 'Z' or 'G', determining which file overrides to apply.
  3. Sets Initial Values:

    • Moves the company code to the control field c1co if valid.
    • Initializes subfile relative record numbers (rrn1, rrn2, rrnsv1, rrnsv2) to zero.
    • Sets subfile page sizes (pagsz1, pagsz2) to 28 records.
    • Configures the program header (c$hdr1) based on the mode ('Maintenance' or 'Inquiry').
    • Sets global protection indicator (*IN70) based on mode (on for INQ, off for MNT).
    • Initializes date and time fields using the system date (ps#mdy) and time (time12).
  4. Open Database Tables (opntbl):

  5. Applies file overrides based on the file group (p$fgrp):
    • For 'G', overrides point to gbicont, ggstabl, gbbndfi, gbbndfi1, gbbndfih.
    • For 'Z', overrides point to zbicont, zgstabl, zbbndfi, zbbndfi1, zbbndfih.
  6. Executes the QCMDEXC system command to apply overrides.
  7. Opens files: bicont, gstabl, bbndfi, bbndfi1, bbndfird, and bbndfih.

  8. Process Subfile 1 (srsfl1):

  9. Clear Message Subfile: Calls clrmsg to clear any existing messages and wrtmsg to display the message subfile.
  10. Default Company: Sets c1co to 10 if zero.
  11. Initial Display:
    • Clears error indicators and suppresses errors on the first display (w$frst).
    • Repositions the subfile (sf1rep) to load initial records.
  12. Main Loop:
    • Writes the command line (sflcmd1) and displays the message subfile if needed.
    • Checks if subfile records exist to enable display control (*IN41).
    • Displays the subfile control record (sflctl1) using exfmt.
    • Determines cursor location (csrloc) and sets the subfile record number (rcdnb1) to the lowest displayed record (pagrrn).
    • Processes user input:
    • F03 (Exit): Exits the loop and program.
    • F05 (Refresh): Resets positioning fields (r$emdy, c1emdy, d1opt, d1emdy, d1eftm) and repositions the subfile.
    • Direct Access: If d1opt, d1emdy, or d1eftm is non-zero, calls sf1dir for direct processing.
    • Page Down: Loads more subfile records (sf1lod).
    • Enter: Processes subfile changes (sf1prc).
    • User Positioning: If the company (c1co) or effective date (c1emdy) changes, repositions the subfile.
    • F10: Clears cursor position (row1, col1) to reposition to the control record.
  13. Continues until the user exits (sf1agn = *off).

  14. Subfile 1 Processing (sf1prc):

  15. Reads changed subfile records (readc sfl1) and processes them (sf1chg).
  16. sf1chg:

    • Copies selected values (s1efdt, s1eftm, s1emdy) to control fields (c2efdt, c2eftm, c2emdy).
    • Processes options:
    • Option 2 (Change): Calls sf1s02 for maintenance mode.
    • Option 5 (Display): Calls sf1s05 for inquiry mode.
    • Updates the subfile record after processing, clearing the option field and updating occurrence count (s1occr).
  17. Subfile 1 Repositioning (sf1rep):

  18. Clears the subfile (sf1clr) and resets rrn1 and rrnsv1.
  19. Validates control input (sf1cte):
    • Checks if the company (c1co) exists in bicont. If not, sets error ERR0021.
    • Validates the effective date (c1emdy) using GSDTEDIT. If invalid, sets error ERR0020.
  20. If no errors, positions the file (bbndfi1) using kls1s1 (company and effective date) and loads the subfile (sf1lod).

  21. Subfile 1 Loading (sf1lod):

  22. Sets the relative record number (rrn1) to the last saved number (rrnsv1).
  23. Loads up to pagsz1 (28) records:
    • Reads records from bbndfi1 using kls1r1 or klnxt1.
    • Formats each record (sf1fmt) with effective date (s1efdt), time (s1eftm), and occurrence count (s1occr).
    • Writes the record to sfl1 and increments rrn1.
  24. Sets the subfile end indicator (*IN43) if no more records are available.
  25. Saves the last record number (rrnsv1).

  26. Direct Access Processing (sf1dir):

  27. Validates the effective date (d1emdy) using GSDTEDIT and time (d1eftm) for valid hours and minutes.
  28. Checks for required values in create mode (d1opt = 1). Sets errors if missing.
  29. Verifies record existence in bbndfi:
    • For non-create options, errors if the record doesn’t exist (ERR0102).
    • For create, errors if the record already exists (ERR0101).
  30. If no errors, processes options:
    • Option 1 (Create): Calls sf1s01.
    • Option 2 (Change): Calls sf1s02.
    • Option 5 (Display): Calls sf1s05.
  31. Clears option and cursor fields if successful.

  32. Subfile 1 Options:

  33. sf1s01 (Create): Saves indicators and subfile state, sets s2mode to 'MNT', calls srsfl2, and triggers repositioning.
  34. sf1s02 (Change): Similar to sf1s01, but for updating existing records.
  35. sf1s05 (Display): Sets s2mode to 'INQ' and calls srsfl2 for inquiry.

  36. Process Subfile 2 (srsfl2):

  37. Initializes the subfile based on mode:
    • In 'MNT', sets s2all to on and F6=Review Mode.
    • In 'INQ', sets s2all to off and F6=All Mode.
  38. Retrieves the occurrence count (rtvent#) and sets c2occr.
  39. Clears and repositions the subfile (sf2rep).
  40. Main Loop:

    • Displays the command line (sflcmd2) and message subfile.
    • Checks for subfile records to enable display (*IN41).
    • Displays the subfile control record (sflctl2).
    • Processes user input:
    • F03 (Exit): Exits both subfiles and the program.
    • F05 (Refresh): Triggers repositioning.
    • F06 (Toggle Mode): Switches between All and Review modes, updating the F6 label.
    • F09 (History Inquiry): Calls GB730P with parameters for history inquiry.
    • F12 (Cancel): Exits the subfile loop.
    • Page Down: Loads more records (sf2lod).
    • Enter: Processes subfile changes (sf2prc).
    • User Positioning: If c2regn is non-zero, repositions the subfile.
    • F10: Clears cursor position (row2, col2).
  41. Subfile 2 Processing (sf2prc):

    • Reads changed subfile records (readc sfl2) and processes them (sf2chg).
    • sf2chg:
    • Edits input (sf2edt).
    • Clears errors in inquiry mode.
    • Updates the database (sf2upd) if no errors and in maintenance mode.
    • Updates the subfile record (sf2pro).
  42. Subfile 2 Update (sf2upd):

    • Checks if the record exists in bbndfi:
    • Create: If no record exists and s2rprc is non-zero, writes a new record to bbndfpf with company, effective date, time, region, and price.
    • Update: If the record exists and s2rprc is non-zero, updates the price (bnrprc).
    • Delete: If s2rprc is zero, deletes the record and marks it in the history file.
    • Writes history record (writehist) for create, update, or delete actions.
    • Updates the occurrence count (c2occr).
  43. Subfile 2 Repositioning (sf2rep):

    • Clears the subfile (sf2clr) and resets rrn2 and rrnsv2.
    • Validates control input (sf2cte).
    • Positions the file (gstabl or bbndfird) based on All or Review mode.
    • Loads the subfile (sf2lod).
  44. Subfile 2 Loading (sf2lod):

    • Loads up to pagsz2 (28) records:
    • In All mode, reads from gstabl using kls2a2.
    • In Review mode, reads from bbndfird using kls2r2.
    • Formats records (sf2fmt) with region (s2regn), description (s2desc), and price (s2rprc).
    • Writes to sfl2 and increments rrn2.
    • Sets the subfile end indicator (*IN43) if no more records are available.
  45. Message Handling:

    • addmsg: Sends error messages to the program message queue using QMHSNDPM.
    • wrtmsg: Writes the message subfile (msgctl).
    • clrmsg: Clears the message subfile using QMHRMVPM.
  46. History Writing (writehist):

    • Clears the history record (bbndfihpf).
    • Sets fields: deletion flag (lhdel), company (lhco), effective date (lhefdt), time (lheftm), region (lhregn), price (lhrprc), date (lhchd8), time (lhchtm), and user (lhuser).
    • Writes the record to bbndfih.
  47. Program Termination:

    • Closes all files.
    • Sets *INLR to *ON and returns.

External Programs Called

  1. GSDTEDIT:
  2. Purpose: Validates the effective date (p#mdy) and returns a converted date (p#cymd) or an error flag (p#err).
  3. Called in: sf1dir and sf1cte.

  4. GB730P:

  5. Purpose: Displays history inquiry for a selected record.
  6. Parameters: x$hist data structure (file, file group, company, effective date, time, region).
  7. Called in: srsfl2 when F09 is pressed.

  8. QCMDEXC:

  9. Purpose: Executes file override commands (ovg or ovz).
  10. Called in: opntbl.

  11. QMHSNDPM:

  12. Purpose: Sends error messages to the program message queue.
  13. Called in: addmsg.

  14. QMHRMVPM:

  15. Purpose: Clears the message subfile.
  16. Called in: clrmsg.

Tables (Files) Used

  1. bb910d:
  2. Type: Display file (workstation).
  3. Usage: Defines the user interface with subfiles sfl1 and sfl2, and control records sflctl1 and sflctl2.
  4. Access: Input/Output.

  5. bicont:

  6. Type: Input file (database).
  7. Usage: Stores company information, used to validate c1co.
  8. Access: Read-only, user-opened.

  9. gstabl:

  10. Type: Input file (database).
  11. Usage: Stores region codes and descriptions for All mode display in `s unofficially.
  12. Access: Read-only, user-opened.

  13. bbndfi:

  14. Type: Update file (database).
  15. Usage: Primary file for storing National Diesel Fuel Index data (company, effective date, time, region, price).
  16. Access: Read/Write/Add, user-opened.

  17. bbndfi1:

  18. Type: Input file (database).
  19. Usage: Renamed format of bbndfi for subfile 1 processing.
  20. Access: Read-only, user-opened.

  21. bbndfird:

  22. Type: Input file (database).
  23. Usage: Renamed format of bbndfi for subfile 2 processing.
  24. Access: Read-only, user-opened.

  25. bbndfih:

  26. Type: Output file (database).
  27. Usage: Stores history records for create, update, and delete actions.
  28. Access: Write-only, user-opened.

Summary

The BB910 program provides an interactive interface for managing the National Diesel Fuel Index, allowing users to create, update, or delete records in maintenance mode, or view them in inquiry mode. It uses two subfiles (sfl1 for effective date/time, sfl2 for region/price) with navigation via function keys (F03, F05, F06, F09, F10, F12, Page Down, Enter). It validates inputs, manages database updates, logs history, and handles errors with a message subfile. The program interacts with multiple database files and calls external programs for date validation, history inquiry, and system commands.