AR906P RPGLE

Process Steps of RPG Program AR906P

This is a classic "Work With" interactive subfile maintenance program (AR906P) that allows users to view, create, change, inactivate/reactivate, and display commission charge entries stored in file ARCOMM. It supports two modes: MNT (maintenance) and INQ (inquiry-only). The program uses a single subfile (SFL1) driven by control format SFLCTL1 and a message subfile.

Here is the high-level flow:

  1. Program Initialization (*INZSR)
  2. Receives two parameters:
    • p$mode = 'MNT' (maintenance) or 'INQ' (inquiry)
    • p$fgrp = 'G' or 'Z' (determines which library set to use)
  3. Builds file overrides for G or Z libraries and executes them via QCMDEXC.
  4. Opens all database files.
  5. Sets up key lists, subfile sizes, date/time stamps, and message handling structures.

  6. Main Subfile Processing (srsfl1)

  7. Clears the message subfile.
  8. Initializes subfile control fields and global protection (*IN70 = on for inquiry mode).
  9. Positions the subfile at the first record (sf1rep).
  10. Enters the main DO loop that runs until F3 is pressed.

  11. Display Cycle

  12. Writes command line (SFLCMD1) and message subfile.
  13. Loads/ redisplays the subfile (SFL1).
  14. Determines folded/unfolded mode.
  15. Executes EXFMT SFLCTL1 (user sees the subfile and can enter options or control fields).

  16. User Input Processing (before and after subfile read)

  17. F3 → Exit program.
  18. F4 → Field prompting (calls lookup programs).
  19. F5 → Refresh (reload subfile).
  20. F8 → Toggle Include/Exclude Inactive records (w$inact).
  21. F15 → Call print program for Commission Charge Listing.
  22. Direct Access fields (in control record) → Validate and process option 1/2/4/5 immediately (sf1dir).
  23. ENTER → Process changed subfile records (sf1prcsf1chg).

  24. Subfile Loading (sf1lod)

  25. Reads next record from ARCOMM (via logical ARCOMMRD).
  26. Skips deleted/inactive records (acdel = 'D' or 'I') if the exclude-inactive filter is active.
  27. Formats each subfile line (sf1fmt).
  28. Applies color coding (sf1col – deleted/inactive records appear in blue).
  29. Writes record to subfile and continues until a full page is loaded or end-of-file.

  30. Subfile Option Processing (sf1chg / sf1dir)

  31. Option 2 (Change) → calls detail program (cannot change deleted records).
  32. Option 4 (Inactivate/Reactivate) → calls AR9064.
  33. Option 5 (Display) → calls detail program in inquiry mode.
  34. Option 1 (Create) → handled only via direct access.
  35. After each action, the subfile line is refreshed from the database.

  36. Detail Maintenance Calls

  37. All create/change/display actions call the same detail program (AR906) with different mode flags.
  38. Inactivate/reactivate uses a dedicated program (AR9064).
  39. On successful completion, a confirmation message is sent and the subfile is repositioned/reloaded.

  40. Validation & Messaging

  41. All direct-access and control-field entries are validated against master files.
  42. Errors are sent to the message subfile using QMHSNDPM.
  43. Messages are cleared with QMHRMVPM.

  44. Cleanup

  45. Closes all files.
  46. Returns to caller.

External Programs Called

Program Called When Purpose
AR906 Option 1 (Create), 2 (Change), 5 (Display) Full maintenance / inquiry detail screen for a single commission charge record
AR9064 Option 4 (In/Activate) Inactivate or reactivate a commission charge record
AR9065 F15 Print Commission Charge Listing
LARCUST F4 on Customer field Customer lookup / prompt
LINLOC F4 on Location field Location lookup / prompt
LGSPROD F4 on Product field Product master lookup / prompt
QCMDEXC Startup Execute file overrides
QMHSNDPM / QMHRMVPM Throughout Program message queue handling

Tables / Files Used

File (Logical / Physical) Usage Description
ARCOMM Main file (maintenance) Commission Charge master file
ARCOMMRD Read-only (renamed format) Sequential read of ARCOMM for subfile load
BICONT Validation Business control / company master
GSPROD Validation Product master (field TPFIL5 renamed to x@fil5)
ARCUST Validation Customer master
INLOC Validation Inventory / warehouse location master

All files are overridden at program start to either the G (general) or Z (zone-specific) library set based on the p$fgrp parameter.

The program follows standard IBM i "Work With" design patterns: subfile load on demand, option processing on changed records, direct-access support, field prompting, and full message subfile support.