Skip to content

AP910P RPGLE

The RPGLE program AP910P.rpgle.txt is an IBM AS/400 or IBM i program designed for working with vendor records in an accounts payable (AP) system, specifically for maintaining vendor data related to 1099 forms. It is called from the OCL program AP910P99.ocl36.txt and provides an interactive interface for users to manage vendor records. Below, I’ll explain the process steps, business rules, tables used, and external programs called.


Process Steps of the RPGLE Program

The AP910P program is a display file-driven application that manages vendor records through a subfile interface. It supports maintenance (MNT) and inquiry (INQ) modes, allowing users to create, update, inactivate/reactivate, or display vendor records. Here’s a step-by-step breakdown of the process:

  1. Initialization (*inzsr Subroutine):
  2. Receives Parameters: The program accepts three parameters via the *entry PLIST:
    • p$mode (3A): Run mode, either MNT (maintenance) or INQ (inquiry).
    • p$file (10A): Vendor file name (e.g., APVN2025 for 1099 processing).
    • p$fgrp (1A): File group, either G or Z, to determine file overrides.
  3. Sets Up Fields: Initializes subfile control fields, message handling fields, and headers. Defines key lists (klsfl1, kls1s1, kls1r1) for file access and sets default values for flags and counters.
  4. Purpose: Prepares the program environment, including repositioning fields, subfile control, and message queue setup.

  5. Open Database Tables (opntbl Subroutine):

  6. File Overrides: Based on p$fgrp (G or Z), applies overrides to the APCONT, APVEND, and APVENDRD files using QCMDEXC to execute OVRDBF commands:
    • For p$fgrp = 'G': Overrides to GAPCONT and GAPVEND.
    • For p$fgrp = 'Z': Overrides to ZAPCONT and ZAPVEND.
    • If p$file is provided (e.g., APVN2025), uses it for APVEND and APVENDRD.
  7. Opens Files: Opens APCONT, APVEND, and APVENDRD with USROPN for dynamic access.
  8. Purpose: Ensures the correct vendor files are accessed, especially for year-specific 1099 files like APVNYYYY.

  9. Process Subfile (srsfl1 Subroutine):

  10. Clear Message Subfile: Calls clrmsg to clear any existing messages and wrtmsg to initialize the message subfile.
  11. Initialize Subfile Control: Sets default values for subfile control fields (e.g., c$co = company code, c$dlyn = 'N' for inactive records).
  12. Set Protection Mode: If p$mode = 'MNT', enables input fields (*in70 = *off); otherwise, protects fields for inquiry mode (*in70 = *on).
  13. Position File: Calls sf1rep to position the APVENDRD file based on user input (company code, vendor number, or search string).
  14. Main Loop (sf1agn):
    • Displays the command line and message subfile.
    • Checks for subfile records to set display indicators (*in41 for SFLDSP).
    • Displays the subfile control record (sflctl1) using EXFMT.
    • Processes user input based on function keys:
    • F3: Exits the program.
    • F4: Calls prompt (empty in this code, likely for future field-level help).
    • F5: Refreshes the subfile, clearing selection fields and repositioning.
    • Page Down: Loads additional subfile records (sf1lod).
    • Enter: Processes subfile changes (sf1prc) if records are modified.
    • F10: Repositions the cursor to the control record.
    • Handles direct access (sf1dir) if a specific vendor is selected (d$sel and d$vend).
    • Repositions the subfile if control fields change (sf1rep).
  15. Purpose: Manages the interactive subfile interface, allowing users to view and manipulate vendor records.

  16. Process Subfile on Enter (sf1prc Subroutine):

  17. Reads changed subfile records (readc sfl1) and processes each using sf1chg.
  18. Purpose: Handles user selections or modifications made in the subfile.

  19. Process Subfile Record Change (sf1chg Subroutine):

  20. Copies the selected vendor number (s1vend) to working fields (s$vend, a$vend).
  21. Based on the subfile selection option (s1sel):
    • Option 2: Calls sf1s02 (change vendor) if p$mode = 'MNT'.
    • Option 4: Calls sf1s04 (inactivate/reactivate vendor) if p$mode = 'MNT'.
    • Option 5: Calls sf1s05 (display vendor).
  22. Updates the subfile record after processing by chaining to APVEND, formatting the record (sf1fmt), applying color coding (sf1col), and updating sfl1.
  23. Purpose: Processes user-selected actions for specific vendor records.

  24. Reposition Subfile (sf1rep Subroutine):

  25. Clears the subfile (sf1clr) and resets the relative record number (rrn1).
  26. Validates control fields (sf1cte).
  27. Positions the APVENDRD file using setll based on the company code (c$co) and vendor number (c$vend).
  28. Retains control fields for repositioning and loads new subfile records (sf1lod).
  29. Purpose: Refreshes the subfile based on user-specified filters (company, vendor, search string, or inactive flag).

  30. Edit Subfile Control Input (sf1cte Subroutine):

  31. Validates the company code (c$co) by chaining to APCONT. If invalid or blank, sets error message ERR0000 and indicators *in50, *in51.
  32. Ensures c$dlyn (include inactive) is Y or N; if invalid, sets error message ERR0014 and indicators *in50, *in52.
  33. Purpose: Validates user input in the subfile control area to ensure correct data filtering.

  34. Load Subfile Records (sf1lod Subroutine):

  35. Loads up to pagsz1 (30) records into the subfile.
  36. Reads records from APVENDRD using reade with key list kls1r1.
  37. Filters records:
    • Skips inactive records (vndel = 'I') if c$dlyn = 'N'.
    • Applies search string filter (c$srch) using scan on vnname.
  38. Formats each record (sf1fmt) and applies color coding (sf1col).
  39. Writes records to the subfile (sfl1) and updates rrn1.
  40. Purpose: Populates the subfile with filtered vendor records for display.

  41. Format Subfile Line (sf1fmt Subroutine):

  42. Clears the subfile record and populates fields:
    • s1del: Vendor deletion flag (vndel).
    • s1vend: Vendor number (vnvend).
    • s1name: Vendor name (vnname).
    • s1tel#: Vendor phone (vnarea + vntele).
    • s1lpay: Last payment amount (vnlpay).
    • s1lpdt: Last payment date (vnlpd8, converted to MMDDYY).
  43. Purpose: Formats vendor data for display in the subfile.

  44. Subfile Color Coding (sf1col Subroutine):

    • Sets indicator *in71 to *on if the vendor is inactive (s1del = 'I'), likely for visual highlighting.
    • Purpose: Visually distinguishes inactive vendors in the subfile.
  45. Direct Access Processing (sf1dir Subroutine):

    • Validates direct selection (d$sel and d$vend):
    • For option 1 (create) in MNT mode, ensures d$vend is not zero (ERR0103 if zero).
    • Checks if the vendor exists in APVEND (klsfl1 setll):
      • For non-create options, errors if vendor does not exist (ERR0102).
      • For create, errors if vendor already exists (ERR0101).
    • Processes valid selections by calling sf1s01, sf1s02, sf1s04, or sf1s05.
    • Clears selection fields after processing.
    • Purpose: Handles direct vendor selection for create, change, inactivate, or display actions.
  46. Clear Subfile (sf1clr Subroutine):

    • Resets rrn1 and rrnsv1 to zero and clears the subfile (*in42 = *on, writes sflctl1).
    • Purpose: Prepares the subfile for reloading.
  47. Option Processing Subroutines:

    • Create (sf1s01):
    • Calls AP910 with MNT mode, passing company, vendor, file name, file group, and a return flag.
    • If successful (o$flag = '1' and o$vend non-zero), sends confirmation message (com(02) + vendor number) and triggers subfile repositioning.
    • Change (sf1s02):
    • Ensures the vendor is not deleted (vndel ≠ 'D'); if deleted, sets error com(08).
    • Calls AP910 with MNT mode.
    • If successful (o$flag = '1'), sends confirmation message (com(03) + vendor number).
    • Inactivate/Reactivate (sf1s04):
    • Calls AP9104, passing company, vendor, file name, file group, and return flag.
    • Based on o$flag, sends confirmation message:
      • I: Inactive (com(05) + vendor number).
      • A: Active (com(06) + vendor number).
    • Display (sf1s05):
    • Calls AP910 with INQ mode to display vendor details.
    • Purpose: Executes specific vendor actions based on user selection.
  48. Message Handling (addmsg, wrtmsg, clrmsg Subroutines):

    • Add Message (addmsg): Sends messages to the program message queue (QMHSNDPM) with error or confirmation text.
    • Write Message (wrtmsg): Displays the message subfile (msgctl).
    • Clear Message (clrmsg): Clears the message subfile using QMHRMVPM.
    • Purpose: Manages user feedback for errors and confirmations.
  49. Program Termination:

    • Closes all files (close *all), sets *inlr = *on, and returns.
    • Purpose: Ensures clean program exit.

Business Rules

  1. Mode-Based Access:
  2. In MNT mode, users can create (option 1), change (option 2), or inactivate/reactivate (option 4) vendor records.
  3. In INQ mode, users can only display vendor details (option 5), with input fields protected (*in70 = *on).

  4. File Overrides for 1099 Processing:

  5. When called from the 1099 process, the program overrides APVEND and APVENDRD to year-specific files (e.g., APVN2025) based on p$file and p$fgrp (G or Z).
  6. Ensures historical vendor data (from GAPVEND) is accessed correctly.

  7. Validation Rules:

  8. Company code (c$co) must exist in APCONT (ERR0000 if invalid).
  9. Inactive flag (c$dlyn) must be Y or N (ERR0014 if invalid).
  10. For create (option 1), vendor number must be non-zero (ERR0103) and must not already exist (ERR0101).
  11. For non-create options, vendor must exist (ERR0102).
  12. Deleted vendors (vndel = 'D') cannot be modified (ERR0000).

  13. Subfile Filtering:

  14. Users can filter vendors by company code, vendor number, search string (c$srch), or include inactive records (c$dlyn = 'Y').
  15. Inactive vendors are visually highlighted (*in71 = *on).

  16. User Interface:

  17. Supports function keys: F3 (exit), F4 (prompt, not implemented), F5 (refresh), F10 (position to control), Page Down (load more records), and Enter (process changes).
  18. Displays up to 30 records per subfile page (pagsz1).
  19. Maintains cursor position and subfile page for redisplay.

  20. Confirmation Messages:

  21. Provides feedback for successful create (com(02)), change (com(03)), inactivate (com(05)), or reactivate (com(06)) actions.

Tables (Files) Used

  1. AP910PD:
  2. Display file (CF, workstn) with a subfile (sfl1) for interactive vendor management.
  3. Used for user interface (input/output via sflctl1, sflcmd1, msgctl, msgclr).

  4. APCONT:

  5. Input-only file (IF, usropn) containing company data.
  6. Overridden to GAPCONT or ZAPCONT based on p$fgrp.
  7. Used to validate company code (c$co).

  8. APVEND:

  9. Input-only file (IF, usropn) containing vendor data.
  10. Overridden to GAPVEND, ZAPVEND, or a year-specific file (e.g., APVN2025) based on p$file and p$fgrp.
  11. Used for chaining vendor records during updates.

  12. APVENDRD:

  13. Input-only file (IF, usropn) with renamed record format (apvendpf to apvendpr).
  14. Overridden similarly to APVEND.
  15. Used for reading vendor records to populate the subfile.

External Programs Called

  1. AP910:
  2. Called for:
    • Create (sf1s01, MNT mode): Creates a new vendor record.
    • Change (sf1s02, MNT mode): Updates an existing vendor record.
    • Display (sf1s05, INQ mode): Displays vendor details.
  3. Parameters: o$co (company), o$vend (vendor), o$mode (MNT/INQ), o$file (file name), o$fgrp (file group), o$flag (return flag).

  4. AP9104:

  5. Called for inactivate/reactivate (sf1s04, MNT mode): Toggles vendor status between active and inactive.
  6. Parameters: o$co, o$vend, o$file, o$fgrp, o$flag (returns I for inactive, A for active).

  7. QCMDEXC:

  8. System program to execute file override commands (OVRDBF) for APCONT, APVEND, and APVENDRD.

  9. QMHSNDPM:

  10. System program to send messages to the program message queue for errors or confirmations.

  11. QMHRMVPM:

  12. System program to clear messages from the message subfile.

Summary

The AP910P RPGLE program is a core component of the accounts payable system, providing an interactive subfile interface for managing vendor records. It supports creating, updating, inactivating/reactivating, and displaying vendors, with specific handling for 1099 processing via year-specific file overrides. The program validates inputs, filters records, and provides user feedback through a message subfile. It integrates with the OCL program AP910P99 to allow manual updates to vendor payment totals for 1099 forms.

Tables/Files: AP910PD (display), APCONT, APVEND, APVENDRD (overridden to GAPCONT, GAPVEND, ZAPCONT, ZAPVEND, or APVNYYYY).
External Programs: AP910, AP9104, QCMDEXC, QMHSNDPM, QMHRMVPM.

If you need further details on the called programs (AP910, AP9104) or file structures, let me know, and I can provide additional analysis or search for relevant information!