Skip to content

AP9104 RPGLE

The RPGLE program AP9104.rpgle.txt is part of an IBM AS/400 or IBM i accounts payable system, designed to handle the inactivation or reactivation of vendor master records. It is called from the OCL program AP910P99.ocl36.txt via AP910P (specifically for option 4 in the subfile interface) and provides a window-based interface (delwdw) to toggle a vendor's status between active (A) and inactive (I). The program supports 1099 processing by overriding vendor files to year-specific versions (e.g., APVN2012). Below, I’ll explain the process steps, business rules, tables used, and external programs called.


Process Steps of the RPGLE Program

The AP9104 program is a display file-driven application that presents a window (delwdw) for users to inactivate or reactivate vendor records. It operates in maintenance mode only, as it updates the vendor file (APVEND) and does not support inquiry mode explicitly. 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$file (10A): Vendor file name for 1099 processing (e.g., APVN2012).
    • p$fgrp (1A): File group, either G or Z, for file overrides.
    • p$flag (1A): Return flag to indicate the result (A for reactivated, D for inactivated).
  3. Sets Up Fields: Initializes display file fields (f$co, f$vend), key list (klvend), and message handling fields (dspmsg, m@pgmq, m@key). Defines a date conversion data structure (d#cymd) and a program status data structure (psds##).
  4. Purpose: Prepares the program environment by setting initial field values and key lists.

  5. Open Database Tables (opntbl Subroutine):

  6. File Overrides: Based on p$fgrp (G or Z), applies overrides to APCONT, APOPNH, INFIL4, and APVEND using QCMDEXC to execute OVRDBF commands:
    • For p$fgrp = 'G': Overrides to GAPCONT, GAPOPNH, GINFIL4, GAPVEND.
    • For p$fgrp = 'Z': Overrides to ZAPCONT, ZAPOPNH, ZINFIL4, ZAPVEND.
    • If p$file is provided (e.g., APVN2012), uses it for APVEND.
  7. Opens Files: Opens APCONT, APOPNH, INFIL4, and APVEND with USROPN for dynamic access.
  8. Purpose: Ensures access to the correct files, especially year-specific vendor files for 1099 processing (per revision JB01).

  9. Retrieve Data (rtvdta Subroutine):

  10. Fetch Company Data: Chains to APCONT using f$co to validate the company code (no action taken if not found, *in99 checked).
  11. Fetch Vendor Data: Chains to APVEND using klvend (f$co, f$vend). If the vendor exists (*in99 = *off):
    • If vndel = 'I' (inactive), sets header (f$hdr) to “Vendor Master Reactivate” and function key label (f$fkyd) to “F22=Reactivate” (*in72 = *on).
    • Otherwise, sets header to “Vendor Master Inactivate” and function key label to “F23=Inactivate” (*in73 = *on).
  12. Purpose: Loads vendor data and configures the window based on the vendor’s current status.

  13. Process Window (prcwdw Subroutine):

  14. Main Loop (winagn):
    • Displays the message subfile if needed (wrtmsg) or clears it (msgclr).
    • Displays the delwdw window using EXFMT.
    • Clears the message subfile (clrmsg) and error indicators (*in50*in69).
    • Processes user input based on function keys:
    • F12: Exits the program (winagn = *off).
    • F22 or F23: Validates input (winedt), checks balances if F23 (chkbal), and updates the database if no errors (winupd).
    • Other (Enter): Validates input (winedt) without updating.
  15. Purpose: Manages the interactive window for inactivating or reactivating vendors.

  16. Edit Window Input (winedt Subroutine):

  17. If F23 (inactivate) is pressed, calls chkbal to check for outstanding balances or history (though most checks are commented out).
  18. Purpose: Ensures valid conditions before allowing database updates.

  19. Check Balances (chkbal Subroutine):

  20. Commented out checks for:
    • Open invoices in APOPNH (ERR0000, com(01): “This Vendor Has Outstanding Invoices, Cannot Delete”).
    • Non-zero monthly balances (vnpurc, vnpay, vndmtd) in APVEND (ERR0000, com(01)).
    • Inventory history in INFIL4 (ERR0000, com(02): “This Vendor Has Inventory History, Cannot Delete”).
  21. Purpose: Originally intended to prevent inactivation if the vendor has outstanding activity, but currently allows inactivation without checks (noted as “never allowed to delete a vendor”).

  22. Update Database (winupd Subroutine):

  23. Reactivate (F22):
    • Chains to APVEND using klvend.
    • If the vendor exists (*in99 = *off) and is inactive (vndel = 'I'), sets vndel = 'A', updates apvendpf, and sets p$flag = 'A'.
  24. Inactivate (F23):
    • Chains to APVEND using klvend.
    • If the vendor exists (*in99 = *off) and is not inactive (vndel ≠ 'I'), sets vndel = 'I', updates apvendpf, and sets p$flag = 'D'.
  25. Purpose: Updates the vendor’s status in APVEND to active or inactive.

  26. Message Handling (addmsg, wrtmsg, clrmsg Subroutines):

  27. Add Message (addmsg): Sends error or confirmation messages to the program message queue (QMHSNDPM).
  28. Write Message (wrtmsg): Displays the message subfile (msgctl).
  29. Clear Message (clrmsg): Clears the message subfile (QMHRMVPM).
  30. Purpose: Manages user feedback for errors or confirmations.

  31. Program Termination:

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

Business Rules

  1. Vendor Status Toggle:
  2. The program toggles the vendor’s deletion flag (vndel) in APVEND:
    • F22 (Reactivate): Changes vndel from I (inactive) to A (active), sets p$flag = 'A'.
    • F23 (Inactivate): Changes vndel from non-I to I (inactive), sets p$flag = 'D'.
  3. The term “delete” in comments refers to marking a vendor as inactive (I), not physical deletion.

  4. Validation (Disabled):

  5. Originally, inactivation (F23) was restricted if the vendor had:
    • Open invoices in APOPNH.
    • Non-zero balances (vnpurc, vnpay, vndmtd) in APVEND.
    • Inventory history in INFIL4.
  6. These checks are commented out, allowing inactivation without validation (noted as “never allowed to delete a vendor”).

  7. File Overrides for 1099 Processing:

  8. Overrides APVEND to year-specific files (e.g., APVN2012) based on p$file and p$fgrp (G or Z) to support 1099 processing (per JB01).
  9. Similarly overrides APCONT, APOPNH, and INFIL4.

  10. User Interface:

  11. Uses a window (delwdw) with dynamic headers (“Vendor Master Reactivate” or “Vendor Master Inactivate”) and function key labels (F22=Reactivate or F23=Inactivate) based on the vendor’s current status.
  12. Supports function keys: F12 (exit), F22 (reactivate), F23 (inactivate), and Enter (validate input).
  13. Displays error messages if validation fails (though currently disabled).

  14. Database Updates:

  15. Updates APVEND only if the vendor exists and meets status conditions.
  16. Returns p$flag to indicate the action taken (A or D).

Tables (Files) Used

  1. AP9104D:
  2. Display file (CF, workstn) for the vendor inactivate/reactivate window (delwdw, msgctl, msgclr).
  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).

  8. APOPNH:

  9. Input-only file (IF, usropn) for open invoices.
  10. Overridden to GAPOPNH or ZAPOPNH.
  11. Used in commented-out balance checks (chkbal).

  12. INFIL4:

  13. Input-only file (IF, usropn) for inventory history.
  14. Overridden to GINFIL4 or ZINFIL4.
  15. Used in commented-out balance checks (chkbal).

  16. APVEND:

  17. Update file (UF, usropn) for vendor master data.
  18. Overridden to GAPVEND, ZAPVEND, or a year-specific file (e.g., APVN2012) based on p$file and p$fgrp.
  19. Used to update the vendor’s deletion flag (vndel).

External Programs Called

  1. QCMDEXC:
  2. System program to execute file override commands (OVRDBF) for APCONT, APOPNH, INFIL4, and APVEND.

  3. QMHSNDPM:

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

  5. QMHRMVPM:

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

Summary

The AP9104 RPGLE program is a specialized component of the accounts payable system, called from AP910P99 via AP910P to inactivate or reactivate vendor records by toggling the vndel flag in APVEND (A for active, I for inactive). It uses a window interface (delwdw) and supports 1099 processing through year-specific file overrides. Validation checks for outstanding invoices or balances are disabled, allowing unrestricted status changes. The program provides user feedback via a message subfile and integrates with the broader vendor maintenance workflow.

Tables/Files: AP9104D (display), APCONT, APOPNH, INFIL4, APVEND (overridden to GAPCONT, GAPOPNH, GINFIL4, GAPVEND, or APVNYYYY).
External Programs: QCMDEXC, QMHSNDPM, QMHRMVPM.

If you need further details on related programs, file structures, or the OCL integration, let me know, and I can provide additional analysis or search for relevant information!