Skip to content

AR490 RPG36

The provided document, AR490.rpg36.txt, is an RPG III (RPG/36) program used on IBM midrange systems (e.g., System/36 or AS/400) to generate a credit limit grouping list. This program is called by the OCL program AR490.ocl36.txt after sorting data with #GSORT. Below, I explain the process steps, business rules, tables/files used, and external programs called.


Process Steps of the RPG Program

The AR490 RPG program processes sorted input data from the ARCLGR file, retrieves additional data from ARCONT and ARCUST, and produces a formatted report on the printer file PRINT. The steps are as follows:

  1. Program Initialization:
  2. Header Specification:
    • H P064 B AR490: Specifies program name AR490 with a program identifier P064 and batch mode (B).
  3. File Declarations:
    • ARCLGR: Primary input file (240 bytes, disk, no key).
    • ARCONT: Input file (256 bytes, indexed, key at position 2, record length 256).
    • ARCUST: Input file (384 bytes, indexed, key at position 8, record length 384).
    • PRINT: Output printer file (165 bytes, with overflow indicator OF).
  4. Data Structures:
    • SEP: Array of 82 elements (2 bytes each) for separator lines in the report.
    • ARC: Array of 25 elements (6 bytes each, numeric) to store credit limit group numbers (CGCL01 to CGCL25).
  5. Variables:

    • TIMDAT (12 bytes): Stores system time and date.
    • TIME (6 bytes): Formatted time.
    • DATE (6 bytes): Formatted date.
    • PAGE (implied): Page number for the report.
  6. Read Primary File (ARCLGR):

  7. The program reads records from ARCLGR sequentially (primary file, level L1).
  8. Each record contains:
    • CGDEL (position 1): Delete code ('D' for deleted).
    • CGCONO (positions 2-3): Company number.
    • CGCUST (positions 4-9): Customer number.
    • CGCL01 to CGCL25 (positions 10-159): Up to 25 credit limit group numbers.
    • ARKEY (positions 2-9): Composite key (company number + customer number) for chaining to ARCUST.
  9. Records marked with CGDEL = 'D' are processed but not explicitly filtered out in the code (business rule may assume sorting excluded them).

  10. Retrieve Company Name (ARCONT):

  11. Logic:
    • At level L1 (for each ARCLGR record), chain to ARCONT using CGCONO (company number) as the key (line 0048).
    • If the record is not found (indicator 44 on), set ACNAME to blanks (line 0049).
  12. Fields:

    • ACNAME (positions 4-33): Company name retrieved from ARCONT.
  13. Retrieve Customer Name (ARCUST):

  14. Logic:
    • Chain to ARCUST using ARKEY (company number + customer number, positions 2-9) as the key (line 0057).
    • If the record is not found (indicator 99 on), set ARNAME to blanks (line 0058).
  15. Fields:

    • ARCO (positions 2-3): Company number (for validation, not used here).
    • ARNAME (positions 10-39): Customer name.
  16. Report Header Processing:

  17. Logic (lines 0051-0055):
    • If not already processed (indicator 11 off):
    • Set SEP to '* ' (separator line).
    • Capture system time and date into TIMDAT (12 bytes).
    • Move TIMDAT to TIME (first 6 bytes) and DATE (last 6 bytes).
    • Set indicator 11 on to prevent reprocessing.
  18. Output (lines 0061-0083, detail lines at L1):

    • Write header lines when overflow (OF) or at level L1:
    • Line 1: ACNAME (company name, 30 characters), "PAGE", and page number (PAGE, zero-suppressed).
    • Line 2: "CREDIT LIMIT GROUPING LIST", "TIME", and formatted time (TIME).
    • Line 3: Separator line (SEP).
    • Line 4: "CUSTOMER" and "GROUPING" labels.
    • Line 5: Separator line (SEP).
  19. Detail Line Processing:

  20. Logic (lines 0084-0104, detail lines at level 01):
    • For each ARCLGR record:
    • Write detail line 1:
      • CGCUST (customer number, zero-suppressed, 6 characters).
      • ARNAME (customer name, 40 characters, left-justified).
    • Write detail line 2:
      • Credit limit group numbers (ARC,1 to ARC,15, corresponding to CGCL01 to CGCL15, zero-suppressed, 9-character spacing).
  21. Output:

    • Lists customer number, name, and up to 15 credit limit group numbers per customer (though ARCLGR supports up to 25, only 15 are printed).
  22. Program Termination:

  23. The program ends when ARCLGR reaches end-of-file, closing all files and terminating.

Business Rules

The program enforces the following business rules for generating the credit limit grouping list:

  1. Data Source:
  2. Processes sorted records from ARCLGR, which contains company numbers, customer numbers, and up to 25 credit limit group numbers per customer.
  3. Assumes ARCLGR is pre-sorted by company and customer number (handled by #GSORT in AR490.ocl36.txt).

  4. Company Validation:

  5. Retrieves company name (ACNAME) from ARCONT using CGCONO.
  6. If the company is not found, prints a blank company name.

  7. Customer Validation:

  8. Retrieves customer name (ARNAME) from ARCUST using ARKEY (company + customer number).
  9. If the customer is not found, prints a blank customer name.

  10. Report Formatting:

  11. Groups output by company, printing the company name in the header.
  12. Lists each customer’s number, name, and up to 15 credit limit group numbers.
  13. Includes page number, date, and time in the header.
  14. Uses separator lines (* * *) for readability.

  15. Deletion Handling:

  16. Processes records with CGDEL (delete code), but does not explicitly filter out deleted records (CGDEL = 'D'). The sorting step in AR490.ocl36.txt likely excludes deleted records.

  17. Output Limitation:

  18. Prints only the first 15 credit limit groups (CGCL01 to CGCL15) out of 25 possible groups in ARCLGR, potentially omitting data if more than 15 groups exist.

Tables/Files Used

The program uses the following files: 1. ARCLGR: - Primary input file (240 bytes, disk). - Contains: - CGDEL (1 byte): Delete code. - CGCONO (2 bytes): Company number. - CGCUST (6 bytes): Customer number. - CGCL01 to CGCL25 (6 bytes each): Credit limit group numbers. - ARKEY (8 bytes): Composite key (company + customer). - Sorted by company and customer number by #GSORT. 2. ARCONT: - Input file (256 bytes, indexed, key at position 2). - Contains: - ACNAME (30 bytes, positions 4-33): Company name. - Used to retrieve company names. 3. ARCUST: - Input file (384 bytes, indexed, key at position 8). - Contains: - ARCO (2 bytes, positions 2-3): Company number. - ARNAME (30 bytes, positions 10-39): Customer name. - Used to retrieve customer names. 4. PRINT: - Output printer file (165 bytes). - Used to generate the report with headers and detail lines.


External Programs Called

The RPG program does not explicitly call any external programs using CALL or similar operations. It is invoked by the OCL program AR490.ocl36.txt and relies on the sorted input from #GSORT, but no additional programs are called within the RPG code.


Summary

  • Process Steps: The program reads sorted records from ARCLGR, retrieves company names from ARCONT and customer names from ARCUST, and generates a printer report (PRINT) with headers (company name, date, time, page) and detail lines (customer number, name, up to 15 credit limit group numbers). It formats the report with separator lines and handles missing data by printing blanks.
  • Business Rules: Processes sorted ARCLGR data, validates company and customer numbers, prints up to 15 credit limit groups per customer, and formats the report with headers and separators. Assumes pre-filtered data (e.g., non-deleted records) from sorting.
  • Tables/Files: ARCLGR (input data), ARCONT (company names), ARCUST (customer names), PRINT (report output).
  • External Programs: None called within the RPG program.

If you need further details (e.g., sample report output or file record layouts), please provide additional information or requirements.