Skip to content

AR191 RPG36

The RPG program AR191.rpg36.txt is an RPG/36 program (likely for an IBM System/36 or AS/400 environment) that handles the A/R Salesman Change Transaction Edit process, as referenced in the previously provided .OCL file (AR190.ocl36.txt). This program generates a printed report listing salesman change transactions from the ARSLST file, including customer and salesman details, with validation against related files. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPG code.


Process Steps of RPG Program AR191

The AR191 program is a batch reporting program that processes records from the ARSLST file and produces a formatted report on a printer file (ARPRINT). It retrieves additional data from the ARCUST and GSTABL files to enrich the report with customer names and salesman descriptions. Here’s a detailed breakdown of the process steps:

  1. File Definitions and Initialization:
  2. Files Defined:
    • ARSLST: Primary input file (IP) for salesman change transactions, with a 256-byte record length and an 8-byte key starting at position 2. Fields include:
    • ASDEL (delete code, position 1, 'D' for deleted records).
    • ASCO (company number, positions 2–3).
    • ASCUST (customer number, positions 4–9).
    • ASSLSO (old salesman code, positions 10–11).
    • ASSLSN (new salesman code, positions 12–13).
    • ARCUST: Input file (IF) for customer master data, with a 384-byte record length and an 8-byte key. Fields include:
    • ARNAME (customer name, positions 10–39).
    • GSTABL: Input file (IF) for general table data (e.g., salesman codes), with a 256-byte record length and a 12-byte key. Fields include:
    • TBDESC (table description, e.g., salesman name, positions 14–43).
    • ARPRINT: Output file (O) for the printed report, with a 132-byte record length.
  3. Initial Setup (lines 0022–0029):

    • The program checks the ONCE variable to ensure initialization occurs only once (ONCE = 0).
    • Sets ONCE = 1 to prevent re-execution of initialization.
    • Captures the current time (TIME) into TIMEX (12 digits).
    • Formats the time into TIMEOF (6 characters, likely HHMMSS) and date into DATE (6 characters, likely MMDDYY).
    • This information is used in the report header.
  4. Record Processing Loop:

  5. The program implicitly processes each record in ARSLST sequentially, as ARSLST is defined as the primary input file (IP), triggering a level break (L1) on changes in the company number (ASCO).
  6. For each ARSLST record (lines 0032–0043):

    • Customer Lookup:
    • Builds a key (ARKEY) by combining ASCO (company number) and ASCUST (customer number).
    • Performs a CHAIN operation on ARCUST to retrieve the customer name (ARNAME).
    • If the customer is not found (indicator 10 on), sets ARNAME to 'INVALID'; otherwise, uses the retrieved ARNAME.
    • Salesman Lookup:
    • Builds a key (SLKEY) by combining the literal 'SLSMAN' and the new salesman code (ASSLSN).
    • Performs a CHAIN operation on GSTABL to retrieve the salesman description (TBDESC).
    • If the salesman code is not found (indicator 10 on), sets TBDESC to 'INVALID'; otherwise, uses the retrieved TBDESC.
  7. Report Generation:

  8. The program writes records to the ARPRINT printer file using output specifications (lines 0046–0089).
  9. Header Output (lines 0046–0082):
    • On a level break (L1, change in ASCO) or overflow (OF), prints the report header:
    • Page number (PAGE) at position 104–108 (e.g., "PAGE 001").
    • Date (DATE, formatted as MM/DD/YY) at position 120–129.
    • Report title (" SALESMAN CHANGE EDIT ") centered at position 75.
    • Time (TIMEOF, formatted as HH.MM.SS) at position 120–129.
    • Decorative lines of asterisks (* * * * * * * * * * * *) across positions 24–131.
    • Column headers:
      • "CO" (company number) at position 2.
      • "CUSTOMER #", "NAME", "SALESMAN OLD NEW" at positions 11, 32, and 58, respectively.
    • Another set of decorative asterisk lines.
  10. Detail Output (lines 0083–0089):

    • For each ARSLST record (conditioned by 01, non-deleted records where ASDEL ≠ 'D'):
    • ASCO (company number) at position 2.
    • ASCUST (customer number, zero-suppressed) at position 10.
    • ARNAME (customer name from ARCUST) at position 45.
    • ASSLSO (old salesman code) at position 53.
    • ASSLSN (new salesman code) at position 58.
    • TBDESC (new salesman description from GSTABL) at position 90.
  11. Program Termination:

  12. The program ends automatically after processing all ARSLST records, as is typical for primary input file processing in RPG/36. No explicit loop termination is coded, and the program closes the printer file (ARPRINT) upon completion.

Business Rules

The AR191 program enforces the following business rules for generating the salesman change edit report:

  1. Record Selection:
  2. Only non-deleted records (ASDEL ≠ 'D') from ARSLST are included in the report (indicator 01 in output specifications, line 0083).
  3. Records are grouped by company number (ASCO), with a level break (L1) triggering header output when the company number changes.

  4. Data Validation and Enrichment:

  5. Customer Validation:
    • Each ARSLST record’s customer number (ASCUST) is validated against the ARCUST file using the key ASCO + ASCUST.
    • If the customer is not found, the report displays 'INVALID' for the customer name (ARNAME).
  6. Salesman Validation:

    • The new salesman code (ASSLSN) is validated against the GSTABL file using the key 'SLSMAN' + ASSLSN.
    • If the salesman code is not found, the report displays 'INVALID' for the salesman description (TBDESC).
  7. Report Formatting:

  8. The report includes a header with page number, date, time, and title, printed on each company change (L1) or page overflow (OF).
  9. Detail lines show:
    • Company number (ASCO).
    • Customer number (ASCUST, zero-suppressed).
    • Customer name (ARNAME).
    • Old salesman code (ASSLSO).
    • New salesman code (ASSLSN).
    • New salesman description (TBDESC).
  10. The report is formatted with fixed-position fields and decorative asterisk lines for readability.

  11. Date and Time:

  12. The report includes the system date and time in the header, formatted as MM/DD/YY and HH.MM.SS, respectively.

Tables (Files) Used

The following files are used by the AR191 program: 1. ARSLST: Primary input file for salesman change transactions (input mode, IP), containing: - ASDEL (delete code, 1 byte, 'D' for deleted records). - ASCO (company number, positions 2–3). - ASCUST (customer number, positions 4–9). - ASSLSO (old salesman code, positions 10–11). - ASSLSN (new salesman code, positions 12–13). 2. ARCUST: Customer master file (input mode, IF), containing: - ARNAME (customer name, positions 10–39). 3. GSTABL: General table file (input mode, IF), containing: - TBDESC (table description, e.g., salesman name, positions 14–43). 4. ARPRINT: Printer output file (O), used to generate the report with a 132-byte record length.


External Programs Called

The AR191 program does not explicitly call any external programs (e.g., via CALL operations). It operates as a standalone batch program, processing input files and generating output directly to the printer file.


Summary

  • Process Steps:
  • Initializes the program by capturing the system date and time for the report header.
  • Processes each ARSLST record sequentially, grouped by company number (ASCO).
  • Validates customer numbers against ARCUST and salesman codes against GSTABL, marking invalid entries with 'INVALID'.
  • Generates a formatted report to ARPRINT with headers (on company change or page overflow) and detail lines for non-deleted records.
  • Terminates after processing all records.

  • Business Rules:

  • Includes only non-deleted ARSLST records (ASDEL ≠ 'D').
  • Validates customer and salesman data, displaying 'INVALID' for missing records.
  • Groups records by company number, with headers printed on company changes or page overflows.
  • Formats the report with fixed-position fields, including date, time, and decorative lines.

  • Tables Used: ARSLST, ARCUST, GSTABL, ARPRINT.

  • External Programs: None.

This program complements AR190 (add/update transactions) by providing a printed edit report to verify salesman change transactions. If you have additional details (e.g., sample data or report output formats), I can provide further analysis. Let me know if you’d like me to search for related information or analyze other files!