Skip to content

AR901 RPG36

The provided document, AR901.rpg36.txt, is an RPG II program for the IBM System/36, called from the main OCL program (AR901P.ocl36.txt). It generates a "Customer Master File List," a report listing customer details. Below, I’ll explain the process steps, business rules, tables (files) used, and any external programs called.


Process Steps of the RPG II Program

The RPG II program AR901 processes customer data from multiple files to produce a formatted printed report. It uses fixed-format specifications (F, I, C, O) typical of RPG II on System/36. Here’s a detailed breakdown of the process steps:

  1. Program Initialization:
  2. Header Specification:
    • H P014: Specifies program identifier P014 for AR901.
  3. File Declarations:
    • FARCUST IP F 384 384R I DISK: Primary input file ARCUST (customer master file), 384 bytes, indexed.
    • FAR901S IR F 30 3 3IT EDISK: Input file AR901S, 30 bytes, likely a selection or parameter file, externally described.
    • FARCONT IC F 256 256R 2AI 2 DISK: Input file ARCONT (company master file), 256 bytes, indexed, keyed on position 2 (ARCO, company number).
    • FARCUSP IC F 1344 1344R 8AI 2 DISK: Input file ARCUSP (customer supplemental file), 1344 bytes, indexed, keyed on position 2.
    • FGSTABL IF F 256 256 12AI 2 DISK: Input file GSTABL (table file), 256 bytes, indexed, keyed on position 2.
    • FPRINTER O F 164 164 OF PRINTER: Output file PRINTER, 164 bytes, for generating the printed report.
  4. Extension Specification:
    • E AR901S ARCUST: Links the externally described file AR901S to ARCUST for field definitions.
  5. Input Specifications:

    • IARCUST NS 01: Defines fields for ARCUST:
    • ARCOCU (positions 2-9): Customer number.
    • ARCO (positions 2-3, level L1): Company number.
    • ARCUST (positions 4-9): Customer number (subset of ARCOCU).
    • ARNAME (positions 10-39): Customer name.
    • ARADR1-4 (positions 40-69, 70-99, 100-129, 130-159): Address lines 1-4.
    • ARAREA (positions 257-258, packed): Area code.
    • ARTELE (positions 259-262, packed): Telephone number.
    • ARTERM (positions 265-266): Terms code.
    • IARCONT NS 02: Defines fields for ARCONT:
    • ACNAME (positions 4-33): Company name.
    • IARCUSP NS: Defines fields for ARCUSP:
    • CSCNCT (positions 267-291): Contact name.
    • IGSTABL NS 01: Defines fields for GSTABL:
    • TBDEL (position 1): Deletion flag ('D' for deleted).
    • TBTYPE (positions 2-7): Table type.
    • TBCODE (positions 8-13): Table code.
    • TBDESC (positions 14-43): Table description.
  6. Main Processing Logic (Calculation Specifications):

  7. Level 1 (L1) Processing:

    • Triggered for each ARCUST record matching the company number (ARCO, level indicator L1).
    • Company Lookup:
    • ARCO CHAIN ARCONT 99: Chains (looks up) the company number in ARCONT.
    • If not found (*in99 = *on), sets ACNAME to blanks.
    • Time and Date Setup:
    • TIME TIME12 120: Retrieves the system time into TIME12 (12 digits).
    • MOVEL TIME12 TIME 60: Moves the time to a 6-character field.
    • MOVE TIME12 DATE 60: Moves the date portion to a 6-character field (formatted as YYMMDD).
    • Z-ADD *ZEROS PAGE: Initializes the page number to 0.
    • Customer Data Processing:
    • Z-ADD ARAREA AREA 30: Moves the area code to AREA (3 digits, zoned).
    • Z-ADD ARTELE TELE 70: Moves the telephone number to TELE (7 digits, zoned).
    • ARCOCU CHAIN ARCUSP 97: Chains the customer number to ARCUSP to retrieve contact information.
    • If not found (*in97 = *on), sets CSCNCT to blanks.
    • Terms Code Lookup:
      • MOVEL 'ARTERM' TRMKEY 12: Sets the table key prefix to 'ARTERM'.
      • MOVE ARTERM TRMKEY: Appends the terms code to TRMKEY.
      • TRMKEY CHAIN GSTABL 99: Chains to GSTABL to retrieve the terms description.
      • If found (*in99 = *off), moves TBDESC to TRMDSC (20 characters); otherwise, sets TRMDSC to blanks.
  8. Output Processing (Output Specifications):

  9. Header Output (H):
    • OPRINTER H 103 L1: Prints header lines at level 1 (for each company).
    • Outputs:
    • ACNAME (company name, position 30).
    • Literal 'PAGE' (position 134).
    • PAGE (zoned, position 138).
    • Literal 'DATE' (position 150).
    • DATE (formatted as YY/MM/DD, position 159).
    • H 2 L1: Prints a title line:
    • Literal ' CUSTOMER MASTER LIST ' (position 77).
    • Literal 'TIME' (position 150).
    • TIME (formatted as HH.MM.SS, position 159).
  10. Detail Lines (D):
    • D 1 L1: Prints decorative lines (asterisks) for formatting (positions 24, 48, 72, 96, 120, 144, 164).
    • D 1 L1: Prints column headers:
    • 'CUST#' (position 6).
    • 'CUSTOMER NAME' (position 20).
    • 'ADDRESS' (position 52).
    • 'PHONE' (position 83).
    • 'CONTACT' (position 102).
    • 'PAYMENT TERMS' (position 137).
    • D 2 L1: Prints additional decorative lines for formatting.
    • D 2 01: Prints customer details:
    • ARCUST (customer number, zoned, position 6).
    • ARNAME (customer name, position 37).
    • ARADR1 (address line 1, position 68).
    • AREA (area code, zoned, blank-suppressed, position 74).
    • TELE (telephone, blank-suppressed, formatted as XXX-XXXX, position 83).
    • CSCNCT (contact name, position 121).
    • TRMDSC (terms description, position 144).
    • D 1 01: Prints additional address lines:
    • ARADR2 (address line 2, position 68).
    • ARADR3 (address line 3, position 68).
    • ARADR4 (address line 4, position 68, conditional on *in10 = *off).

Business Rules

The program enforces the following business rules for generating the customer master list:

  1. Company Validation:
  2. For each customer record in ARCUST, the company number (ARCO) is looked up in ARCONT to retrieve the company name (ACNAME).
  3. If no matching company is found, the company name is blank.

  4. Customer Data Retrieval:

  5. Customer number (ARCOCU) is used to retrieve contact information (CSCNCT) from ARCUSP.
  6. If no matching record is found, the contact name is blank.

  7. Terms Code Lookup:

  8. The terms code (ARTERM) is used to look up a description in GSTABL with the key 'ARTERM' + ARTERM.
  9. If found, the description (TBDESC) is used; otherwise, the terms description (TRMDSC) is blank.

  10. Report Formatting:

  11. The report is grouped by company (L1 level), with headers including company name, page number, date, and time.
  12. Customer details include customer number, name, address (up to 4 lines), phone number (formatted as XXX-XXXX), contact name, and payment terms description.
  13. Address line 4 is printed only if indicator *in10 is off (likely controlled by parameters from AR901P).

  14. Data Formatting:

  15. Numeric fields like ARAREA and ARTELE are converted to zoned format for printing.
  16. The telephone number is formatted with a hyphen (XXX-XXXX).
  17. The date is formatted as YY/MM/DD, and the time as HH.MM.SS.

Tables (Files) Used

  1. ARCUST:
  2. Type: Primary input file (disk, indexed).
  3. Record Length: 384 bytes.
  4. Key: Not explicitly defined in the code but implied to be ARCO (company number) for level processing.
  5. Fields:
    • ARCOCU (positions 2-9): Customer number (8 characters).
    • ARCO (positions 2-3): Company number (2 characters, level L1).
    • ARCUST (positions 4-9): Customer number (6 characters).
    • ARNAME (positions 10-39): Customer name (30 characters).
    • ARADR1-4 (positions 40-159): Address lines (30 characters each).
    • ARAREA (positions 257-258, packed): Area code (3 digits).
    • ARTELE (positions 259-262, packed): Telephone number (7 digits).
    • ARTERM (positions 265-266): Terms code (2 digits).
  6. Purpose: Main customer master file containing core customer data.

  7. AR901S:

  8. Type: Input file (disk, externally described).
  9. Record Length: 30 bytes.
  10. Purpose: Likely contains selection parameters (e.g., company or customer filters) from AR901P. Linked to ARCUST via the extension specification.

  11. ARCONT:

  12. Type: Input file (disk, indexed).
  13. Record Length: 256 bytes.
  14. Key: Position 2 (ARCO, company number).
  15. Fields:
    • ACNAME (positions 4-33): Company name (30 characters).
  16. Purpose: Stores company details for the report header.

  17. ARCUSP:

  18. Type: Input file (disk, indexed).
  19. Record Length: 1344 bytes.
  20. Key: Position 2 (likely customer number).
  21. Fields:
    • CSCNCT (positions 267-291): Contact name (25 characters).
  22. Purpose: Stores supplemental customer data, such as contact information.

  23. GSTABL:

  24. Type: Input file (disk, indexed).
  25. Record Length: 256 bytes.
  26. Key: Position 2 (likely TBTYPE + TBCODE).
  27. Fields:
    • TBDEL (position 1): Deletion flag ('D' for deleted).
    • TBTYPE (positions 2-7): Table type (6 characters).
    • TBCODE (positions 8-13): Table code (6 characters).
    • TBDESC (positions 14-43): Table description (30 characters).
  28. Purpose: Stores lookup data for terms codes (e.g., payment terms descriptions).

  29. PRINTER:

  30. Type: Output file (printer).
  31. Record Length: 164 bytes.
  32. Purpose: Generates the printed customer master list report.

External Programs Called

No external programs are explicitly called within AR901.rpg36 (e.g., via CALL operations). The program is invoked by the OCL program (AR901P.ocl36.txt), which loads and runs AR901 (referenced in the JOBQ or ELSE clause). The RPGLE program AR901P likely passes parameters (e.g., kyalco, kyco1-kyco3, addlst) that control the report’s behavior, but no direct program calls occur within AR901.


Additional Notes

  • Integration with OCL and RPGLE:
  • The OCL program (AR901P.ocl36.txt) sets up the environment, loads AR901P, and optionally queues or runs AR901.
  • The RPGLE program (AR901P.rpgle) collects and validates user input (e.g., company/customer selections, address list flag) and passes parameters to AR901 via shared memory or files like AR901S.
  • AR901 processes these parameters to filter records from ARCUST and generate the report.

  • Indicator Usage:

  • *in99: Indicates whether a CHAIN to ARCONT or GSTABL fails.
  • *in97: Indicates whether a CHAIN to ARCUSP fails.
  • *in10: Controls whether address line 4 (ARADR4) is printed (likely set by addlst from AR901P).
  • L1: Level indicator for processing records by company number (ARCO).

  • Report Structure:

  • The report includes a header with company name, page number, date, and time, followed by a formatted customer list with columns for customer number, name, address, phone, contact, and payment terms.
  • Decorative lines (asterisks) separate sections for readability.

  • No Chart Generation:

  • The query does not request a chart, and no numerical data is provided for visualization, so no chart is generated.

If you need further analysis (e.g., specific field mappings, sample report output, or deeper integration details with AR901P), please provide additional context or files.