Skip to content

AR500P RPGLE

The provided document is an RPGLE (Report Program Generator Language Extended) program, AR500P.rpgle.txt, which is called by the OCL program AR500P.ocl36.txt to generate an Accounts Receivable (A/R) Aged Trial Balance report. This program handles user input, validates parameters, and prepares data for the report. Below, I’ll explain the process steps, business rules, tables used, and external programs called.

Process Steps of the RPGLE Program

The AR500P RPGLE program is an interactive program that prompts users for input via a workstation display file, validates the input, and sets up parameters for generating the A/R Aged Trial Balance report. Here’s a detailed breakdown of the process steps:

  1. Program Initialization:
  2. Header Specifications:
    • H DFTACTGRP(*NO): Runs in a named activation group, allowing better resource management.
    • H FIXNBR(*ZONED:*INPUTPACKED): Ensures zoned and packed numeric fields are handled correctly during input.
    • H DFTNAME(AR500P): Sets the default program name.
  3. Data Structures:

    • msg: A 40-character array with 19 predefined error messages (loaded via CTDATA).
    • dco: A 35-character array to store company names (up to 3 companies).
    • uds: A data structure defining user input fields (e.g., kydate, kyalco, kyco1, etc.) for report parameters like date, company selection, and report options.
    • y2kcen and y2kcmp: Variables for Y2K date handling (century and comparison year).
  4. File Declarations:

  5. AR500PD (Workstation File):
    • Defined as CF E WORKSTN with a handler (PROFOUNDUI(HANDLER)), indicating a modernized display file for user interaction, likely using a web-based interface.
  6. ARCONT (Accounts Receivable Control File):
    • Defined as UF F 256 2AIDISK KEYLOC(2): A 256-byte file with a 2-byte key (company number acco), used for update (UF) and accessed by key.
  7. GSCONT (General System Control File):

    • Defined as IF F 512 2AIDISK KEYLOC(2): A 512-byte input file with a 2-byte key (company number gxcono), likely used for system-wide settings.
  8. Main Processing Logic:

  9. Initial Workstation File Read:
    • Checks qsctl (control flag). If blank, sets indicators *IN09 (initial screen) and *IN01 (display screen), and sets qsctl to 'R'.
    • Otherwise, reads the display file ar500pfm and returns if the last record indicator (*INLR) is on.
  10. Indicator and Message Initialization:
    • Clears msg40 (error message field) and resets indicators 50-62, 81, and 90 to *OFF.
  11. Cancel Check:
    • If *INKG (cancel key) is on, sets kycanc to 'CANCEL', turns off *IN01 and *IN09, sets *INLR to *ON, and exits.
  12. One-Time Setup (Subroutine onetim):
    • Executed if *IN09 is on (initial run).
    • Captures current time and date, stores in kydate.
    • Reads ARCONT to populate dco array with up to three company numbers (acco) and names (acname), skipping deleted records (acdel = 'D').
    • Initializes default parameters:
    • kyds = 'D' (detail report).
    • kyalco = 'ALL' or 'CO ' (based on GSCONT company number gxcono).
    • kyalcs = 'ALL' (all customers).
    • kyalsl = 'ALL' (all salesmen).
    • kyjobq = 'N' (no job queue).
    • kycopy = 01 (one copy).
    • kyouts = 'O' (outstanding invoices).
    • kynod = 'N' (no NOD report).
    • kyslcy = 'N' (no salesman copies).
    • kyrept = 'C' (customer sequence).
    • kyclyn = 'N' (no credit limit).
    • Releases any locked ARCONT records using a blank key (nulkey).
  13. Screen Processing (Subroutine screen1):
    • Executed if *IN01 is on and *IN15 is off.
    • Validates user input parameters:
    • Date Validation: Calls @dtedt to validate kydate (MMDDYY format).
    • Company Selection:
      • Ensures kyalco is 'ALL' or 'CO '.
      • If 'CO ', validates kyco1, kyco2, kyco3 against ARCONT (non-zero, non-deleted records).
      • If 'ALL', ensures no company numbers are entered.
    • Customer Selection:
      • Ensures kyalcs is 'ALL' or 'SEL'.
      • If 'SEL', requires non-zero kycs01, kycs02, or kycs03.
    • Outstanding Invoices:
      • Ensures kyouts is 'O' or blank.
    • Report Sequence:
      • Ensures kyrept is 'C', 'N', or 'S'.
      • If kyslcy = 'Y', requires kyrept = 'S'.
    • Salesmen Selection:
      • Ensures kyalsl is 'ALL' or 'SEL'.
      • If 'SEL', requires kyrept = 'S' and valid kyfmsl/kytosl (from/to salesman, where kytosl > kyfmsl).
    • Job Queue:
      • Ensures kyjobq is 'Y' or 'N'.
    • Credit Limit:
      • Ensures kyclyn is 'Y' or 'N'.
    • NOD Report:
      • Ensures kynod is 'Y' or 'N'.
      • If kynod = 'Y', requires kyds = 'D'.
    • Salesman Copies:
      • Ensures kyslcy is 'Y' or 'N'.
    • Copy Count:
      • Ensures kycopy is non-zero (defaults to 1 if zero).
    • Displays error messages (msg40) from the msg array if validation fails, setting *IN81 and appropriate error indicators (50-62, 90).
    • Updates ARCONT with kydate for non-deleted records if validations pass.
    • Releases locked records using nulkey.
  14. Date Validation (Subroutine @dtedt):

    • Validates kydate (MMDDYY format):
    • Breaks down into month ($month), day ($day), and year ($yr).
    • Checks month (1-12).
    • Validates day based on month:
      • February: 29 days for leap years, 28 otherwise.
      • Months 4, 6, 9, 11: 30 days.
      • Others: 31 days.
    • Handles leap year calculations using y2kcen and y2kcmp for century and year checks.
    • Sets *IN79 if the date is invalid.
  15. Output and Termination:

  16. Writes to the display file (ar500pfm) if *IN81 is on, displaying errors or updated parameters.
  17. Sets *INLR to *ON to end the program if no further processing is needed.
  18. Updates ARCONT with the ageing date (kydate) for all records.

Business Rules

The program enforces the following business rules for generating the A/R Aged Trial Balance report: 1. Date Validation: - The ageing date (kydate) must be a valid date in MMDDYY format, with proper month, day, and leap year checks. 2. Company Selection: - Must be 'ALL' (all companies) or 'CO ' (specific companies). - If 'CO ', at least one valid company number (kyco1, kyco2, or kyco3) must exist in ARCONT and not be deleted (acdel ≠ 'D'). - If 'ALL', no company numbers should be specified. 3. Customer Selection: - Must be 'ALL' (all customers) or 'SEL' (selected customers). - If 'SEL', at least one customer number (kycs01, kycs02, or kycs03) must be non-zero. 4. Outstanding Invoices: - Must be 'O' (outstanding invoices only) or blank. 5. Report Sequence: - Must be 'C' (customer sequence), 'N' (name sequence), or 'S' (salesman sequence). - If salesman copies (kyslcy = 'Y'), report sequence must be 'S'. 6. Salesmen Selection: - Must be 'ALL' (all salesmen) or 'SEL' (selected salesmen). - If 'SEL', report sequence must be 'S', and valid from/to salesman numbers (kyfmsl, kytosl) must be provided, with kytosl > kyfmsl. 7. Job Queue: - Must be 'Y' (run in batch) or 'N' (run interactively). 8. Credit Limit: - Must be 'Y' (print credit limit) or 'N' (don’t print). 9. NOD Report: - Must be 'Y' (include NOD report) or 'N' (exclude). - If 'Y', report type must be detail (kyds = 'D'). 10. Salesman Copies: - Must be 'Y' (print salesman copies) or 'N' (don’t print). 11. Copy Count: - Must be non-zero; defaults to 1 if zero. 12. Report Type: - Must be 'D' (detail) or 'S' (summary); defaults to 'D' if blank.

Tables (Files) Used

  1. AR500PD:
  2. Type: Workstation file (CF E WORKSTN).
  3. Purpose: Display file for user interaction, likely a modernized interface using Profound UI.
  4. Fields: Outputs fields like kydate, kyds, kyalco, kyco1-3, dco, kyalcs, kycs01-03, kyouts, kyrept, kyjobq, kycopy, msg40, kyclyn, kyalsl, kyfmsl, kytosl, kynod, kyslcy, kycucl.
  5. ARCONT:
  6. Type: Disk file (UF F 256 2AIDISK KEYLOC(2)).
  7. Purpose: Accounts Receivable control file, storing company and customer data.
  8. Key: acco (company number, 2 bytes).
  9. Fields:
    • acdel (1 byte): Deletion flag ('D' for deleted).
    • acco (2 bytes): Company number.
    • acname (30 bytes): Company name.
    • acdate (6 bytes): Ageing date.
  10. GSCONT:
  11. Type: Disk file (IF F 512 2AIDISK KEYLOC(2)).
  12. Purpose: General system control file, likely for system-wide settings like default company number.
  13. Key: gxcono (2 bytes).
  14. Fields:
    • gxdel (1 byte): Deletion flag.
    • gxcono (2 bytes): Company number.

External Programs Called

The RPGLE program does not explicitly call external programs (e.g., via CALL operation). However, it interacts with: - Profound UI Handler (PROFOUNDUI(HANDLER)): Used by the AR500PD workstation file for rendering the user interface, indicating a modernized front-end. - The OCL program (AR500P.ocl36.txt) that calls this RPGLE program, passing parameters like ?9? and ?11?.

Additional Notes

  • Y2K Compliance:
  • The program includes Y2K date handling (y2kcen, y2kcmp) to ensure correct century calculations for leap years.
  • Error Handling:
  • Uses a predefined msg array for user-friendly error messages displayed via msg40.
  • Indicators (50-62, 79, 81, 90) control error display and program flow.
  • Record Locking:
  • The program releases locked ARCONT records using a blank key (nulkey) to prevent deadlocks.
  • Conversion Notes:
  • The program was converted using TARGET/400 on 04/11/23, with 221 lines added, 5 modified, and 441 processed, indicating modernization from older RPG/36 or RPG III code.
  • Integration with OCL:
  • The OCL program (AR500P.ocl36.txt) loads and runs AR500P, passing parameters (?9?, ?11?) that likely correspond to fields like kyalco, kyco1-3, or kyjobq.

This program sets up and validates parameters for the A/R Aged Trial Balance report, ensuring data integrity before report generation. If you need further analysis (e.g., specific field mappings, report output format, or additional files), please provide more details or related files!