Skip to content

AR300P RPGLE

The provided document is an RPGLE (RPG IV) program, AR300P.rpgle.txt, which is called from the OCL program AR300P.ocl36.txt. This RPG program is designed to prompt users for input parameters to generate monthly statements for accounts receivable (AR). It validates user input, checks data against files, and displays error messages if validation fails. Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called.

Process Steps of the AR300P RPGLE Program

  1. Program Initialization:
  2. Header Specifications:
    • H DFTACTGRP(*NO): Runs in a named activation group (not the default), allowing better control over resources.
    • H DFTNAME(AR300P): Specifies the default program name as AR300P.
    • H FIXNBR(*ZONED:*INPUTPACKED): Handles numeric fields with zoned or packed decimal formats during conversion.
  3. File Declarations:
    • AR300PD CF E WORKSTN: Defines a workstation file (AR300PD) for interactive screen input/output, using Profound UI (Handler('PROFOUNDUI(HANDLER)')) for the user interface.
    • ARCONT IF F 256 2AIDISK KEYLOC(2): Defines an input file (ARCONT) with a record length of 256 bytes, keyed on position 2 (company number, acco), used for accounts receivable control data.
    • GSCONT IF F 512 2AIDISK KEYLOC(2): Defines another input file (GSCONT) with a record length of 512 bytes, also keyed on position 2 (company number, gxcono), likely for global system control data.
  4. Data Structures and Variables:
    • dco: A 35-character array (10 elements) to store company numbers and names.
    • com: A 40-character array (7 elements) initialized with compile-time data (CTDATA) for error messages (e.g., "INVALID STATEMENT DATE").
    • uds: A data structure for job parameters, including:
    • kyalco (ALL/CO selection), kyco1, kyco2, kyco3 (company numbers), kydate (statement date), kycmtd (month-to-date flag), kycytd (year-to-date flag), kycopy (number of copies), y2kcen (Y2K century), y2kcmp (Y2K comparison year).
  5. Indicators: Used extensively for controlling program flow and screen output (e.g., *IN01, *IN09, *IN81, *IN90).

  6. Main Processing Logic:

  7. Workstation File Read:
    • Checks qsctl (a control field, likely from the screen or job).
    • If qsctl is blank, sets *IN09 (initial screen display) and qsctl to 'R', then proceeds.
    • Otherwise, sets *IN01 (process input), reads the screen file (AR300PD), and returns if the last record indicator (LR) is set.
  8. Indicator Setup:
    • Resets indicators (*IN20, *IN81, *IN90, *IN30*IN37) to ensure a clean state.
    • Clears the msg field (40 characters) for error messages.
  9. F3 Key Handling:
    • If *INKG (F3 key) is pressed, sets *INU1 and *INLR (program termination), clears *IN01 and *IN09, and jumps to the end tag to exit.
  10. Initial Screen Display:
    • If *IN09 is on, sets *IN81 (write screen) and executes the onetim subroutine for one-time initialization.
  11. Input Processing:
    • If *IN01 is on, executes the edit subroutine to validate user input.
  12. Screen Output:

    • If *IN81 is off, sets *INLR to terminate the program.
    • Writes to the AR300PD screen file if *IN81 is on, displaying the input prompt or error messages.
  13. Edit Subroutine (edit):

  14. Security Code Validation:
    • Chains to ARCONT using key 01 (company number).
    • Compares kysec (input security code) with acsecr (security code in ARCONT).
    • If mismatched, sets *IN30, *IN81, *IN90, and displays error message com(7) ("INVALID SECURITY CODE").
  15. Date Validation:
    • Moves kydate to mmddyy and calls @dtedt to validate the date.
    • If *IN79 (date error) is set, displays com(1) ("INVALID STATEMENT DATE") and sets *IN31, *IN81, *IN90.
  16. ALL/CO Selection Validation:
    • Checks if kyalco is 'ALL' or 'CO '.
    • If kyalco is 'ALL' or 'CO ', validates further:
    • If kyalco is neither 'ALL' nor 'CO', displays com(2) ("ENTER ALL OR CO") and sets *IN32, *IN81, *IN90.
  17. Company Number Validation:
    • If kyalco is 'CO', checks kyco1, kyco2, kyco3:
    • If all are zero, displays com(3) ("IF CO, THEN ENTER VALID COMPANIES") and sets *IN32, *IN81, *IN90.
    • If kyalco is 'ALL' and any company numbers are non-zero, displays com(4) ("IF ALL, THEN DO NOT ENTER COMPANIES") and sets *IN32, *IN81, *IN90.
    • For each non-zero kyco1, kyco2, kyco3:
    • Positions the ARCONT file using SETLL.
    • Reads the record and checks if it’s deleted (acdel = 'D') or if the company number (acco) matches.
    • If no valid record is found, displays com(5) ("INVALID COMPANY NUMBER") and sets *IN33, *IN34, or *IN35 (for kyco1, kyco2, kyco3) plus *IN81, *IN90.
  18. Month-to-Date/Year-to-Date Flags:
    • Validates kycmtd and kycytd (must be 'Y', 'N', or blank).
    • If invalid, displays com(6) ("INVALID PARAMETER") and sets *IN81, *IN90.
  19. Number of Copies:
    • If kycopy is zero, sets it to 1.
  20. Final Setup:

    • Sets *IN11 to indicate successful validation.
  21. One-Time Subroutine (onetim):

  22. Initialize Company Array:
    • Clears the dco array and sets index x to 1.
    • Positions ARCONT at the beginning (aclim = 00).
    • Reads ARCONT records, skipping deleted records (acdel = 'D').
    • Stores company number (acco) and name (acname) in dco(x) until 10 companies are loaded or end of file is reached.
    • Moves dco elements to individual fields (DCO1DCO10) for screen display.
  23. Default Parameters:

    • Chains to GSCONT with key 00.
    • If a record is found and gxcono is non-zero, sets kyalco to 'CO ' and kyco1 to gxcono.
    • Otherwise, sets kyalco to 'ALL'.
    • Sets defaults: kycmtd = 'Y', kycytd = 'N', kycopy = 01, kyco1, kyco2, kyco3 = 0.
    • Sets *IN10 to indicate completion.
  24. Date Edit Subroutine (@dtedt):

  25. Validates the input date (mmddyy):

    • Breaks down into month ($month), day ($day), and year ($yr).
    • Checks if month is valid (1–12).
    • For February, validates days (28 or 29 for leap years) using century (y2kcen) and year calculations.
    • For other months, checks days (30 or 31 based on month).
    • Sets *IN79 if any validation fails.
  26. Output Specifications:

  27. Writes to AR300PD if *IN81 is on, outputting fields like kysec, kydate, kyalco, kyco1, kyco2, kyco3, dco, kycmtd, kycytd, kycopy, and msg.

Business Rules

  1. Security Code:
  2. The input security code (kysec) must match the security code (acsecr) in the ARCONT file for the company.
  3. Statement Date:
  4. The date (kydate) must be valid (checked via @dtedt for month, day, and leap year).
  5. ALL/CO Selection:
  6. kyalco must be 'ALL' (process all companies) or 'CO ' (specific companies).
  7. If 'CO ', at least one of kyco1, kyco2, kyco3 must be non-zero.
  8. If 'ALL', kyco1, kyco2, kyco3 must be zero.
  9. Company Numbers:
  10. Each non-zero kyco1, kyco2, kyco3 must exist in ARCONT, not be deleted (acdel ≠ 'D'), and match the company number (acco).
  11. Month-to-Date/Year-to-Date:
  12. kycmtd and kycytd must be 'Y', 'N', or blank.
  13. Number of Copies:
  14. kycopy defaults to 1 if zero.
  15. Error Handling:
  16. Displays specific error messages (com(1)com(7)) for validation failures.
  17. Returns to the screen for correction if errors occur.
  18. Initialization:
  19. Defaults are set based on GSCONT (company number or 'ALL') and hardcoded values (kycmtd, kycytd, kycopy).
  20. Up to 10 companies are loaded for display.

Tables/Files Used

  1. AR300PD:
  2. Workstation file (display file) for user interaction via Profound UI.
  3. Contains fields like kysec, kydate, kyalco, kyco1, kyco2, kyco3, dco, kycmtd, kycytd, kycopy, msg.
  4. ARCONT:
  5. Accounts receivable control file (256 bytes, keyed on company number at position 2).
  6. Fields:
    • acdel (1): Delete flag ('D' for deleted).
    • acco (2–3): Company number.
    • acname (4–33): Company name.
    • acsecr (84–91): Security code for statements.
  7. GSCONT:
  8. Global system control file (512 bytes, keyed on company number at position 2).
  9. Fields:
    • gxdel (1): Delete flag.
    • gxcono (77–78): Company number.

External Programs Called

  • None:
  • The RPG program does not explicitly call external programs (e.g., via CALL or QCMDEXC).
  • It interacts with the Profound UI handler (PROFOUNDUI(HANDLER)) for screen processing, but this is a runtime environment, not a program call.
  • The OCL program (AR300P.ocl36.txt) calls AR300P, but within AR300P.rpgle, no further programs are invoked.

Additional Notes

  • Conversion Context: The program was converted on 04/07/23 using TARGET/400, with 161 lines added, 5 modified, and 297 processed. Prefixes (T4A, T4M, T4O) indicate added, modified, or original lines.
  • Y2K Handling: The @dtedt subroutine and fields like y2kcen, y2kcmp address Year 2000 date issues, ensuring correct leap year calculations.
  • Profound UI: The use of Handler('PROFOUNDUI(HANDLER)') indicates a modernized user interface, likely a web-based front-end for the AS/400.
  • Error Messages: The com array provides clear, user-friendly error messages, enhancing usability.
  • Integration with OCL: The OCL program loads AR300P and provides the ARCONT file with a dynamic label (?9?ARCONT). The RPG program uses this file for validation.

If you need further details, such as a deeper dive into specific validations or integration with other system components, let me know!