Skip to content

AP910 RPGLE

The RPGLE program AP910.rpgle.txt is part of an IBM AS/400 or IBM i accounts payable system, designed for vendor master maintenance and inquiry. It is called from the OCL program AP910P99.ocl36.txt via AP910P and is used to create, update, or display vendor records, with specific support for 1099 form processing. Below, I’ll explain the process steps, business rules, tables used, and external programs called.


Process Steps of the RPGLE Program

The AP910 program is a display file-driven application that manages vendor master records through a single-panel interface (fmt01). It supports maintenance (MNT) and inquiry (INQ) modes, allowing users to add, update, or view vendor details. The program includes validations for 1099-related fields and integrates with an SQL vendor table for synchronization. Here’s a step-by-step breakdown of the process:

  1. Initialization (*inzsr Subroutine):
  2. Receives Parameters: The program accepts five parameters via the *entry PLIST:
    • p$co (company code).
    • p$vend (vendor number).
    • p$mode (3A): Run mode, either MNT (maintenance) or INQ (inquiry).
    • p$file (10A): Vendor file name for 1099 processing (e.g., APVN2025).
    • p$fgrp (1A): File group, either G or Z, for file overrides.
    • p$flag (1A): Return flag to indicate success (1) or failure.
  3. Sets Up Fields: Initializes display file fields (f$co, f$vend), key lists (klvend, klglms, klcaid, etc.), and message handling fields. Defines data structures for date conversion (d#cymd), time conversion (time12), and vendor record storage (wkds01, svds).
  4. Purpose: Prepares the program environment for processing vendor data.

  5. Open Database Tables (opntbl Subroutine):

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

  9. Retrieve Data (rtvdta Subroutine):

  10. Fetch Company Data: Chains to APCONT using f$co to retrieve the company name (acname) into f$conm. If not found, clears f$conm.
  11. Fetch Vendor Data: Chains to APVEND using klvend (f$co, f$vend). If the vendor exists (*in99 = *off), loads the record; otherwise, clears apvendpf.
  12. Set Mode and Header: Sets protection indicator *in70 (*off for MNT, *on for INQ) and header (c$hdr1) to “Vendor Master Maintenance” or “Vendor Master Inquiry” based on p$mode.
  13. Purpose: Loads existing vendor data or prepares for a new record.

  14. Process Panel Formats (srfmt Subroutine):

  15. Clear Screen: Writes clrscr to reset the display.
  16. Initialize Panel: Calls f01mov to set up fields for fmt01 and sets w$fmt = 'FMT01'.
  17. Main Loop (fmtagn):
    • Displays the message subfile if needed (wrtmsg).
    • Displays fmt01 using EXFMT.
    • Clears error indicators (*in50*in69, *in76*in79) and message subfile (clrmsg).
    • Processes user input based on the current format (f01sr for fmt01).
  18. Purpose: Manages the interactive display of the vendor maintenance/inquiry panel.

  19. Process Format (f01sr Subroutine):

  20. Handle Function Keys:
    • F04: Calls prompt to handle field-level prompting (e.g., lookup for GL account, terms, or 1099 code).
    • F05: Calls AP915P for vendor contact maintenance/inquiry (commented out in this version).
    • F10: Repositions the cursor to the top of the screen.
    • F12: Exits the program (fmtagn = *off).
  21. Inquiry Mode: If p$mode = 'INQ', calls f01nxt to determine the next format (though only fmt01 is active).
  22. Enter Key: Validates input (f01edt), updates the database if in MNT mode (upddbf), and processes the next format (f01nxt).
  23. Purpose: Handles user interactions with the fmt01 panel.

  24. Determine Next Format (f01nxt Subroutine):

  25. If no input changes are detected (*in19 = *off), exits the main loop (fmtagn = *off).
  26. Purpose: Controls whether to continue or exit the panel loop (only fmt01 is used in this version).

  27. Edit Format Input (f01edt Subroutine):

  28. Validates fields in fmt01:
    • Name (vnname): Must not be blank (ERR0012, *in51).
    • Name Overflow (vnnovf): Must be Y or N (ERR0014, *in52).
    • ACH Fields (commented out): If bank account (vnabk#) is non-blank, validates:
    • vnacos: Must be C or S (com(05), *in77).
    • vnacls: Must be CCD (com(06), *in78).
    • vnarte: Must be non-zero (com(07), *in79).
    • ACH Hold Validation: If vnhold = 'A' and vnabk# is blank, errors (com(08), *in76*in79).
    • Sort Field (vnsort): Must not be blank (ERR0012, *in53).
    • Hold (vnhold): Must be H, A, W, E, U, or blank (com(01), *in54).
    • Single Payee (vnsngl): Must be S or blank (com(02), *in55).
    • Expense GL (vnexgl): Must exist in GLMAST, not deleted or inactive (ERR0010, *in56), and not a special account (ERR0015).
    • Carrier (vncaid): Must exist in BBCAID and not be deleted (ERR0010, *in57).
    • Inactive Code (vndel): Sets f$inac to “INACTIVE” if vndel = 'I'.
    • Terms (vnterm): Must exist in GSTABL and not be deleted (ERR0010, *in58).
    • Gal/Rcpts Required (vngrrq): Commented out validation for GSTABL lookup (ERR0010, *in71).
    • Category (vncatg): Must exist in GSTABL (no deleted check, *in62 commented out).
    • 1099 Code (vn1099):
    • Must not be blank (ERR0010, *in59).
    • Must exist in GSTABL and not be deleted (ERR0010, *in59).
    • If M or N, requires:
      • IRS Name Control (vnnmct) non-blank (com(04), *in61).
      • IRS EIN (vnidno) non-blank (com(10), *in64).
      • IRS Box 1 (vnbox1) non-zero (com(11), *in65).
    • Zip Code (vnzip5): Required if vnctry = 'US' and vn1099 ≠ 'X' and vnhold ≠ 'E' (com(09), *in63).
    • Payees (vnpyn2): If non-blank, vnpyn1 must also be non-blank (com(03), *in60).
  29. Inquiry Mode: Clears errors and messages if p$mode = 'INQ'.
  30. Purpose: Ensures valid input before updating the database.

  31. Initialize Format Fields (f01mov Subroutine):

  32. Calls f01edt to validate and populate display fields.
  33. Clears errors if validation fails.
  34. Calls f01pro (empty in this version) for format protection.
  35. Purpose: Prepares the fmt01 panel with validated data.

  36. Update Database (upddbf Subroutine):

  37. Saves current vendor record (wkds01) to svds.
  38. Checks if the vendor exists in APVEND (klvend chain):
    • If exists (*in80 = *off) and fields changed, restores svds to wkds01, updates apvendpf, sets p$flag = '1', and calls updSQLvn (commented out).
    • If not exists, clears apvendpf, populates with svds, sets vnco and vnvend, writes a new record, sets p$flag = '1', and calls updSQLvn.
  39. Purpose: Updates or creates vendor records in APVEND.

  40. Update SQL Vendor Master (updSQLvn Subroutine):

    • Commented out code to call a PC program (UpdateVendor.EXE) via STRPCOCLP and QCMDEXC to synchronize the AS/400 vendor table with an SQL version.
    • Purpose: Intended to keep an external SQL vendor table in sync (disabled per MG01).
  41. Field Prompting (prompt Subroutine):

    • Determines cursor position for window return.
    • For fmt01, handles field lookups:
    • VNEXGL: Calls LGLMAST to select a GL account, updates vnexgl if valid.
    • VNCAID: Calls LBBCAID to select a carrier, updates vncaid.
    • VNTERM: Calls LGSTABL to select terms, updates vnterm.
    • VNGRRQ: Calls LGSTABL for gal/rcpts required (commented out).
    • VNCATG: Calls LGSTABL to select a category, updates vncatg.
    • VN1099: Calls LGSTABL to select a 1099 code, updates vn1099.
    • Sets *in19 to indicate a format change.
    • Purpose: Provides interactive lookup for key fields.
  42. Message Handling (addmsg, wrtmsg, clrmsg Subroutines):

    • Add Message (addmsg): Sends error or confirmation messages to the program message queue (QMHSNDPM).
    • Write Message (wrtmsg): Displays the message subfile (msgctl).
    • Clear Message (clrmsg): Clears the message subfile (QMHRMVPM).
    • Purpose: Manages user feedback for errors and confirmations.
  43. 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 or update vendor records, with input fields enabled (*in70 = *off).
  3. In INQ mode, users can only view vendor details, with input fields protected (*in70 = *on).

  4. File Overrides for 1099 Processing:

  5. Overrides APVEND to year-specific files (e.g., APVN2025) based on p$file and p$fgrp (G or Z) to support 1099 processing, as noted in revision JB01.
  6. Similarly overrides APCONT, GLMAST, GSTABL, and BBCAID.

  7. Validation Rules:

  8. Mandatory Fields:
    • Vendor name (vnname) and sort field (vnsort) must not be blank (ERR0012).
    • If second payee (vnpyn2) is non-blank, first payee (vnpyn1) must be non-blank (com(03)).
  9. Valid Values:
    • Name overflow (vnnovf): Y or N (ERR0014).
    • Hold (vnhold): H (check), A (ACH), W (wire), E, U (utility auto-pay, per MG03), or blank (com(01)).
    • Single payee (vnsngl): S or blank (com(02)).
    • ACH fields (commented out): If vnabk# non-blank, vnacos (C/S), vnacls (CCD), and vnarte (non-zero) are required. If vnhold = 'A' and vnabk# blank, errors (com(08)).
  10. Reference File Checks:
    • Expense GL (vnexgl): Must exist in GLMAST, not deleted or inactive (ERR0010), and not special (ERR0015).
    • Carrier (vncaid): Must exist in BBCAID and not deleted (ERR0010).
    • Terms (vnterm): Must exist in GSTABL and not deleted (ERR0010).
    • Category (vncatg): Must exist in GSTABL (no deleted check).
    • 1099 Code (vn1099): Must exist in GSTABL, not deleted, and not blank (ERR0010).
  11. 1099-Specific Validations (per MG02, JK01):

    • If vn1099 = 'M' (MISC) or 'N' (NEC):
    • IRS Name Control (vnnmct) must be non-blank (com(04)).
    • IRS EIN (vnidno) must be non-blank (com(10)).
    • IRS Box 1 (vnbox1) must be non-zero (com(11)).
    • If vnctry = 'US' and vn1099 ≠ 'X' and vnhold ≠ 'E', zip code (vnzip5) must be non-zero (com(09)).
  12. Database Updates:

  13. In MNT mode, updates or creates records in APVEND and sets p$flag = '1' on success.
  14. Synchronization with an SQL vendor table is commented out (MG01).

  15. User Interface:

  16. Supports function keys: F04 (field prompting), F05 (vendor contacts, commented out), F10 (cursor home), F12 (exit), and Enter (process input).
  17. Displays a single panel (fmt01) with vendor details and validation messages.

Tables (Files) Used

  1. AP910D:
  2. Display file (CF, workstn) for the vendor maintenance/inquiry interface (fmt01, clrscr, msgctl).
  3. Used for user input/output.

  4. APCONT:

  5. Input-only file (IF, usropn) for company data.
  6. Overridden to GAPCONT or ZAPCONT based on p$fgrp.
  7. Used to validate company code (f$co) and retrieve company name (acname).

  8. GLMAST:

  9. Input-only file (IF, usropn) for general ledger accounts.
  10. Overridden to GGLMAST or ZGLMAST.
  11. Used to validate expense GL account (vnexgl).

  12. GSTABL:

  13. Input-only file (IF, usropn) for reference data (terms, category, 1099 codes).
  14. Overridden to GGSTABL or ZGSTABL.
  15. Used to validate vnterm, vncatg, vn1099, and commented-out vngrrq.

  16. BBCAID:

  17. Input-only file (IF, usropn) for carrier data (replaces GSTABL for carrier lookup per JK03).
  18. Overridden to GBBCAID or ZBBCAID.
  19. Used to validate carrier (vncaid).

  20. APVEND:

  21. Update file (UF, usropn) for vendor master data.
  22. Overridden to GAPVEND, ZAPVEND, or a year-specific file (e.g., APVN2025) based on p$file and p$fgrp.
  23. Used for reading, updating, or creating vendor records.

External Programs Called

  1. LGLMAST:
  2. Called in prompt for GL account lookup (VNEXGL).
  3. Parameters: o$co (company), o$acct (account), o$sub (sub-account), o$spec (special accounts flag), o$fgrp (file group).

  4. LBBCAID:

  5. Called in prompt for carrier lookup (VNCAID, per JK03).
  6. Parameters: o$co (company), o$caid (carrier ID), o$fgrp (file group).

  7. LGSTABL:

  8. Called in prompt for lookup of terms (VNTERM), category (VNCATG), and 1099 code (VN1099).
  9. Parameters: k$apterm/k$apcatg/k$ap1099 (table type), k$term/k$catg/k$1099 (code), o$fgrp (file group).

  10. QCMDEXC:

  11. System program to execute file override commands (OVRDBF) for APCONT, GLMAST, GSTABL, BBCAID, and APVEND.

  12. QMHSNDPM:

  13. System program to send messages to the program message queue.

  14. QMHRMVPM:

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

  16. AP915P (commented out)**:

  17. Intended for vendor contact maintenance/inquiry (per JK02).
  18. Parameters: o$co# (company), o$vend (vendor), o$mode (MNT/INQ), o$fgrp (file group).

  19. STRPCOCLP and UpdateVendor.EXE (commented out)**:

  20. Intended to synchronize the AS/400 vendor table with an SQL table (per JB05, disabled per MG01).

Summary

The AP910 RPGLE program is a critical component of the accounts payable system, providing an interactive interface for maintaining or viewing vendor master records. It supports creating and updating vendor data in MNT mode and viewing in INQ mode, with robust validations for 1099-related fields (e.g., IRS Name Control, EIN, Box 1, zip code). The program integrates with the OCL program AP910P99 and AP910P to manage vendor data for 1099 processing, using year-specific files like APVNYYYY. It includes field lookups and error handling to ensure data integrity.

Tables/Files: AP910D (display), APCONT, GLMAST, GSTABL, BBCAID, APVEND (overridden to GAPCONT, GGLMAST, GGSTABL, GBBCAID, GAPVEND, or APVNYYYY).
External Programs: LGLMAST, LBBCAID, LGSTABL, QCMDEXC, QMHSNDPM, QMHRMVPM, AP915P (commented out), STRPCOCLP/UpdateVendor.EXE (commented out).

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