Skip to content

AR890 RPGLE

The provided AR890.rpgle.txt is an RPGLE (Report Program Generator Language Enhanced) program used for a Customer Master Inquiry system on an IBM midrange platform (e.g., AS/400 or IBM i). It is called by the AR890.ocl36 OCL script previously analyzed. The program facilitates inquiry into customer data, including account details, supplemental information, product codes, and contacts, with support for multiple display formats. Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the source code.


Process Steps of the RPGLE Program

The AR890 RPGLE program is structured to handle interactive customer inquiries through a workstation display file (ar890d). It processes user inputs, retrieves data from various files, and displays results across five screen formats (AR890S01 to AR890S05). The main steps are:

  1. Program Initialization (*inzsr Subroutine):
  2. Initializes key fields (cocust, ship, o$co, o$cust, o$ship) to zeros, setting up the program for a fresh start.
  3. Defines the local data area (*lda) to access runtime parameters (e.g., ldacc for company/customer number, tstprd for library/file group).

  4. Read Workstation Input:

  5. Checks the control field qsctl. If blank, sets indicator *in09 and *in01 to 1, indicating a new session, and sets qsctl to 'R'.
  6. Reads input from one of five display formats (AR890S01 to AR890S05) based on indicators *in81 to *in85. If an invalid read occurs (indicator *in09), it calls the rollky subroutine to handle roll keys.

  7. Handle Function Keys:

  8. Clear Key (*inka): Clears all fields using the clear subroutine, resets indicators, and displays the initial screen (AR890S01).
  9. End of Job (*inkg): Sets the last record indicator (*inlr) to terminate the program and clears relevant indicators.
  10. Roll Keys (*in18, *in19): Handles roll forward (up) and roll backward (down) for navigating customer records using rollfw and rollbw subroutines.
  11. Command Keys (ke, kf, kh, 02, 03, 04): Trigger specific inquiries:

    • F2 (ke and 02): Customer history inquiry (ARCUST or ARCUSP).
    • F3 (ke and 03): Customer form type contacts inquiry (originally called AR915P, now commented out).
    • F4 (kf and 04): Customer product code history (originally called GB730P, now commented out; replaced by BI907AC for ARCUPR maintenance).
    • F2 (kh and 02): Supplemental file inquiry (ARCUSP).
  12. Screen Processing Subroutines:

  13. s1 (Screen 1 - AR890S01):
    • Validates company number (co) against ARCONT. If invalid, displays error message (msg1 = "INVALID COMPANY NUMBER ENTERED").
    • Chains to ARCUST and ARCUSP using arkey (company/customer number). If not found, displays "CUSTOMER NOT FOUND".
    • Checks for EFT (Electronic Funds Transfer) data and sets *in60 if valid.
    • Chains to BICONT to get invoicing style (bcinst) and sets the header (s4head) for screen 4.
    • Calls getcus to retrieve customer data and getsup for supplemental data.
    • Sets *in82 to display screen 2 (AR890S02).
  14. s2 (Screen 2 - AR890S02):
    • Sets *in83 to display screen 3 (AR890S03).
  15. s3 (Screen 3 - AR890S03):
    • Prepares to display customer ship-to products but skips direct ARCUPR processing, instead calling BI907AC (commented out in the code but referenced in comments).
    • Sets *in85 to display screen 5 (AR890S05).
  16. s4 (Screen 4 - AR890S04):
    • Clears arrays for product codes, descriptions, and related fields.
    • If array index x reaches 18, reads previous GSPROD record and fills arrays via filara.
    • If invoicing style (bcinst) is '5', displays screen 5; otherwise, calls s5.
  17. s5 (Screen 5 - AR890S05):

    • Clears fields using clear and sets *in81 to return to screen 1.
  18. Data Retrieval Subroutines:

  19. getcus:
    • Checks if the customer is deleted (ardel = 'D'). If so, displays "THIS CUSTOMER WAS PREVIOUSLY DELETED".
    • Moves customer data from ARCUST (e.g., name, address, financials) to display fields.
    • Retrieves descriptions for salesman (sls#), terms (term), group (grup), and class (cucl) from GSTABL.
  20. getsup:
    • Checks if the supplemental record is deleted (csdel = 'D'). If so, displays the deletion message.
    • Converts dates (csstdt, csfsdt, csicdt) to MMDDYY format.
    • Moves supplemental data (e.g., tax codes, comments, freight info) to display fields.
  21. filara:

    • Fills arrays for screen 4 (prcd, prds, glcd, stno, pfrc, psfr, pcfr) with product data from GSPROD and ARCUPR.
    • Stops when 17 records are filled or end of file is reached (*in70).
  22. Roll Key Handling:

  23. rollky: Detects roll forward (status = 01122) or backward (status = 01123) and clears function key indicators.
  24. rollfw: Moves to the next customer record in ARCUST and updates arkey.
  25. rollbw: Moves to the previous customer record in ARCUST and updates arkey.

  26. Write to Display:

  27. Writes to the appropriate screen format (AR890S01 to AR890S05) based on indicators *in81 to *in85.

  28. Termination:

  29. If *inu8 and *in81 are on, sets *inlr to terminate the program.

Business Rules

The program enforces the following business rules based on the code and comments:

  1. Customer Validation:
  2. Validates company number (co) against ARCONT. If invalid, displays "INVALID COMPANY NUMBER ENTERED".
  3. Checks if customer exists in ARCUST and ARCUSP. If not found, displays "CUSTOMER NOT FOUND".
  4. Checks for deletion status (ardel or csdel = 'D'). If deleted, displays "THIS CUSTOMER WAS PREVIOUSLY DELETED".

  5. EFT Validation:

  6. If areft = 'Y' (EFT participant), verifies that csarte (ACH bank routing code) and csabk# (ACH bank account number) are non-blank/zero, setting *in60 to indicate valid EFT data.

  7. Invoicing Style:

  8. Uses bcinst from BICONT to determine the header for screen 4 (s4head). If bcinst = '5', uses alternate header ("To Bill Gross Gallons Enter 'G'"); otherwise, uses default ("To Bill Net Gallons Enter 'N'").

  9. Product Code Handling:

  10. Originally processed ARCUPR directly for product codes but now calls BI907AC for maintenance (per revision JB06).
  11. Limits array filling to 17 records for product codes (prcd), descriptions (prds), and related fields.

  12. Navigation:

  13. Supports roll forward/backward to navigate customer records.
  14. Command keys (F2, F3, F4) trigger specific inquiries, with F3 and F4 linked to external programs (AR915P, BI907AC) for detailed processing.

  15. Data Display:

  16. Formats financial data (e.g., artotd, arcurd, arfin$) with specific decimal places.
  17. Converts dates (e.g., arhidt, csstdt) from YYMMDD to MMDDYY for display.
  18. Retrieves descriptive text for salesman, terms, group, and class codes from GSTABL.

  19. Error Handling:

  20. Displays error messages (msg1, msg2) for invalid inputs or missing records.
  21. Sets *in90 for error conditions, triggering error message display.

Tables (Files) Used

The program uses the following files, defined in the file specifications (F-specs):

  1. ar890d (Workstation File):
  2. Display file for interactive user interface, using formats AR890S01 to AR890S05.
  3. Handled by PROFOUNDUI(HANDLER) for modern UI rendering.

  4. arcust (Customer Master File):

  5. Input file, 384 bytes, keyed by company/customer number (keyloc(2)).
  6. Contains core customer data (e.g., name, address, financials, credit limit).

  7. arcusp (Customer Supplemental File):

  8. Input file, 1344 bytes, keyed by company/customer number.
  9. Stores supplemental data (e.g., tax codes, comments, freight details).

  10. arcupr (Customer Product Master):

  11. Input file, 80 bytes, keyed by company/customer/ship-to/product.
  12. Holds product-specific data (e.g., product code, freight codes).

  13. gsprod (Product File):

  14. Input file, 512 bytes, keyed by company/product code.
  15. Contains product codes and descriptions.

  16. arcont (Contact File):

  17. Input file, 256 bytes, keyed by company number.
  18. Stores ageing period limits (aclmt1 to aclmt4).

  19. bicont (Billing Contact File):

  20. Input file, 256 bytes, keyed by company number.
  21. Contains invoicing style (bcinst).

  22. gstabl (Table File):

  23. Input file, 256 bytes, keyed by table type/code.
  24. Stores descriptions for salesman, terms, group, and class codes.

  25. gscont (General Contact File):

  26. Input file, externally defined, keyed (assumed by company number).
  27. Provides default company number (gxcono).

External Programs Called

The program references the following external programs, though some calls are commented out, indicating they may be invoked conditionally or replaced:

  1. GB730P (Commented Out):
  2. Previously called for inquiries on ARCUST, ARCUSP, and ARCUPR.
  3. Parameters included parmst (data structure with file, company, customer, ship-to).

  4. AR915P (Commented Out):

  5. Previously called for customer form type contacts inquiry (ARCUFM, ARCUFMX).
  6. Parameters included company (a$co), customer (a$cust), mode ('INQ'), and file group (a$fgrp).

  7. BI907AC (Commented Out but Referenced):

  8. Called to maintain ARCUPR records instead of direct processing in s3 (per revision JB06).
  9. Parameters included company (@cpco), customer (@cpcus), ship-to (@cpshp), mode ('INQ'), and file group (@cpfgr).

Summary

The AR890 RPGLE program is an interactive customer inquiry application that retrieves and displays customer data across multiple screens. It: - Validates company and customer data, checks deletion status, and handles EFT data. - Supports navigation through roll keys and command keys for specific inquiries. - Retrieves data from multiple files (ARCUST, ARCUSP, ARCUPR, etc.) and formats it for display. - Calls external programs (BI907AC, potentially AR915P, GB730P) for specialized inquiries.

Tables Used: ar890d, arcust, arcusp, arcupr, gsprod, arcont, bicont, gstabl, gscont.
External Programs Called: GB730P (commented out), AR915P (commented out), BI907AC (commented out but referenced).

If you need further analysis of the screen formats, specific field mappings, or the logic of BI907AC or other called programs, please provide additional source code or context.