Skip to content

AP760 RPG36

The AP760.rpg36.txt is an RPG/36 program (likely running on an IBM System/36 or AS/400 environment) called from the AP760P.ocl36.txt OCL program to generate a Vendor 1099 Register. This program processes vendor data from the AP761 file and produces a printed report (APPRINT) summarizing 1099-related information, such as vendor payments categorized by 1099 box types (e.g., rent, medical, miscellaneous). Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called, based on the provided RPG code.


Process Steps of the RPG/36 Program (AP760)

The AP760 program reads vendor data from the AP761 file, retrieves 1099 type descriptions from GSTABL, accumulates totals for specific 1099 boxes, and outputs a formatted report to the printer file APPRINT. Here’s a step-by-step breakdown of the process:

  1. Program Initialization (lines 0026–0032):
  2. ONCE Subroutine:

    • Checks if the ONCE flag is zero (first execution) (line 0026).
    • Retrieves the system time and date using the TIME operation and stores them in TIMDAT (12 bytes), then moves them to TIME (6 bytes, time) and DATE (6 bytes, date) fields (lines 0027–0029).
    • Initializes the SEP array (66 elements, 2 bytes each) with '* ' for use as a separator in the report (line 0030).
    • Sets ONCE to 1 to prevent re-execution (line 0031).
  3. Processing Vendor Records (Level 2 Break - L2):

  4. The program processes records from the AP761 file at level 2 (L2), indicated by the L2 indicator, which suggests a control break for grouping records by 1099 type (VN1099).
  5. Steps for Each L2 Group (lines 0034–0074):

    • Initializes the table key (TBKEY, 12 bytes) to blanks and sets the prefix to 'AP1099' (lines 0034–0035).
    • Appends the vendor’s 1099 code (VN1099) to TBKEY and chains to the GSTABL file to retrieve the corresponding description (TBDESC) (lines 0036–0037).
    • If the record is not found (indicator 99 on) and KYTY1 (from UDS, set by AP760P) is neither 'M' (miscellaneous) nor 'N' (non-employee compensation), sets indicators 33 or 34 to adjust report formatting (line 0037).
    • Initializes counters and accumulators for the L2 group:
    • L2CNT (count of vendors in the group) to zero (line JB01).
    • L21AMT (total for box 1, rent), L23AMT (total for box 3, non-employee compensation), L26AMT (total for box 6, medical), and L27AMT (total for box 7, miscellaneous) to zero (lines 0038–0040).
    • Initializes report accumulators for each box (BX1AMT, BX3AMT, BX6AMT, BX7AMT) to zero (lines 0044–0046).
  6. Processing Individual Vendor Records (Level 1 Break - 01):

  7. For each vendor record (AP761, indicator 01), the program processes payment amounts and payee names:

    • Accumulate Box Amounts (lines 0048–0070):
    • Checks the first box number (VNBOX1) and assigns the first amount (VNAMT1) to the corresponding accumulator:
      • If VNBOX1 = 1, adds VNAMT1 to BX1AMT (rent) (lines 0048–0050).
      • If VNBOX1 = 3, adds VNAMT1 to BX3AMT (non-employee compensation) (lines 0052–0054).
      • If VNBOX1 = 6, adds VNAMT1 to BX6AMT (medical) (lines 0052–0054).
      • If VNBOX1 = 7, adds VNAMT1 to BX3AMT (miscellaneous, treated as non-employee compensation) (lines 0056–0058).
    • Checks the second box number (VNBOX2) and assigns the second amount (VNAMT2) similarly:
      • If VNBOX2 = 1, adds VNAMT2 to BX1AMT (rent) (lines 0060–0062).
      • If VNBOX2 = 6, adds VNAMT2 to BX6AMT (medical) (lines 0064–0066).
      • If VNBOX2 = 7, adds VNAMT2 to BX3AMT (miscellaneous) (lines 0068–0070).
    • Update Group Totals (lines 0071–0074, JB01):
    • Increments the vendor count (L2CNT) for the L2 group.
    • Adds BX1AMT, BX3AMT, BX6AMT, and BX7AMT to their respective L2 totals (L21AMT, L23AMT, L26AMT, L27AMT).
    • Handle Payee Names (lines JB01):
    • Initializes PYN1 and PYN2 (payee name fields, 40 bytes each) to blanks and turns off indicators 71 and 72 (formatting flags).
    • If VNPYN1 (payee name 1) is blank, uses VNNAME (vendor name) for PYN1 (lines JB01).
    • If VNNOVF = 'Y' (name overflow flag), moves VNADD1 (address line 1) to PYN2 and sets indicator 72 for printing (lines JB02).
    • If VNPYN1 is not blank, uses VNPYN1 for PYN1 and sets indicator 71.
    • If VNPYN2 (payee name 2) is not blank, uses VNPYN2 for PYN2 and sets indicator 72 (lines JB01).
  8. Report Output (APPRINT) (lines 0076–0120):

  9. The program writes to the printer file APPRINT (132 characters per line) with the following structure:
    • L2 Detail and Overflow Lines (lines 0076–0108):
    • Prints page number (PAGE), date (DATE, formatted as Y), and time (TIME, formatted as HH.MM.SS) (lines 0078–0086).
    • Prints the report title “VENDOR 1099 REGISTER” (line 0084).
    • Prints the 1099 type (VN1099) and description (TBDESC) from GSTABL (lines 0088–0089).
    • Prints column headers: “NUMBER” (vendor number), “1099 ID #”, “PAYEE NAME”, “RENT (BOX=1)”, “MEDICAL (BOX=6)”, “MISC (BOX=3)” (lines 0095–0105).
    • Prints separator lines (SEP) as needed (lines 0092, 0108).
    • Vendor Detail Lines (01) (lines 0109–0115, JB01):
    • Prints vendor number (VNVENDZ), 1099 ID (VNID#), payee name 1 (PYN1), and amounts for boxes 1, 6, and 3 (BX1AMTK, BX6AMTK, BX3AMTK) (lines 0109–0115).
    • If indicator 72 is on, prints payee name 2 (PYN2) on a second line (line JB01).
    • L2 Totals (lines 0116–0120):
    • Prints “** TOTALS”, vendor count (L2CNT), and total amounts for boxes 1, 6, and 3 (L21AMTK, L26AMTK, L23AMTK) at the end of each 1099 type group.

Business Rules

The AP760 RPG program enforces the following business rules for generating the 1099 register report:

  1. 1099 Type Grouping:
  2. The report groups vendors by 1099 type (VN1099), with subtotals printed at each type change (L2 break).
  3. Descriptions for 1099 types are retrieved from GSTABL using the key AP1099 + VN1099.

  4. Box Number Mapping:

  5. Box 1: Rent payments (VNBOX1 or VNBOX2 = 1).
  6. Box 3: Miscellaneous payments (VNBOX1 or VNBOX2 = 3 or 7).
  7. Box 6: Medical payments (VNBOX1 or VNBOX2 = 6).
  8. Box 7: Treated as miscellaneous (mapped to BX3AMT).
  9. Amounts are accumulated separately for each box and totaled by 1099 type.

  10. Payee Name Formatting (JB01, JB02):

  11. If VNPYN1 (payee name 1) is blank, use VNNAME (vendor name) as the primary name (PYN1).
  12. If VNNOVF is 'Y', use VNADD1 (address line 1) as the secondary name (PYN2) for name overflow.
  13. If VNPYN1 is not blank, use VNPYN1 as PYN1 and VNPYN2 (if not blank) as PYN2.
  14. Indicators 71 and 72 control printing of PYN1 and PYN2.

  15. Report Layout:

  16. Headers include page number, date, time, 1099 type, and column labels.
  17. Detail lines show vendor number, 1099 ID, payee name(s), and amounts for rent, medical, and miscellaneous boxes.
  18. Totals at each 1099 type break include vendor count and box amounts.

  19. Data Exclusion:

  20. Records marked as deleted (VNDEL = 'D', position 1) are skipped (handled by prior steps in AP760.ocl36.txt and AP761.rpg36.txt).

  21. Special Handling:

  22. If KYTY1 is 'M' or 'N' and the GSTABL lookup fails, set indicators 33 or 34, respectively, which may affect report formatting or filtering (line 0037).

Tables Used

The RPG program uses the following files (tables):

  1. AP761:
  2. Type: Disk file (DISK), primary input file (IP).
  3. Size: 196 bytes.
  4. Fields:
    • VNDEL (position 1, 1 byte): Delete code.
    • VN1099L2 (position 2, 1 byte): 1099 code (renamed VN1099).
    • VNVENDL1 (positions 3–7, 5 bytes): Vendor number (renamed VNVENDZ).
    • VNID# (positions 8–18, 11 bytes): 1099 ID number.
    • VNNAME (positions 19–48, 30 bytes): Vendor name.
    • VNAMT1 (positions 49–57, 9 bytes, packed decimal): First box amount.
    • VNAMT2 (positions 58–66, 9 bytes, packed decimal): Second box amount.
    • VNBOX1 (positions 67–68, 2 bytes): First box number.
    • VNBOX2 (positions 69–70, 2 bytes): Second box number.
    • VNPYN1 (positions 71–110, 40 bytes): Payee name 1 (added by JB01).
    • VNPYN2 (positions 111–150, 40 bytes): Payee name 2 (added by JB01).
    • VNNOVF (position 151, 1 byte): Name overflow (added by JB02).
    • VNADD1 (positions 152–181, 30 bytes): Address line 1 (added by JB02).
  5. Purpose: Preprocessed 1099 data from AP761.rpg36.txt, containing one record per vendor.

  6. GSTABL:

  7. Type: Disk file (DISK), input file (IC), keyed access.
  8. Size: 256 bytes, with a 12-byte key.
  9. Fields:
    • TBDESC (positions 14–43, 30 bytes): Table description.
  10. Purpose: Lookup table for 1099 type descriptions, accessed with key AP1099 + VN1099.

  11. APPRINT:

  12. Type: Printer file (PRINTER), output file (O).
  13. Size: 132 bytes.
  14. Purpose: Output file for the 1099 register report, containing headers, detail lines, and totals.

External Programs Called

The AP760 program does not explicitly call any external programs. However: - It is invoked by the AP760P.ocl36.txt OCL program, either directly or via a job queue, as specified in the OCL’s // JOBQ or // AP760 commands. - The AP760P program (previously analyzed) sets up and validates parameters passed to AP760 via the User Data Structure (UDS), specifically KYTY1 for 1099 type filtering.


Summary

The AP760 RPG/36 program generates a Vendor 1099 Register by: 1. Initializing date, time, and report formatting settings. 2. Processing vendor records from AP761, grouped by 1099 type (VN1099), and retrieving type descriptions from GSTABL. 3. Accumulating payment amounts for 1099 boxes (1: rent, 3: non-employee compensation, 6: medical, 7: miscellaneous) and handling payee names (using vendor name, payee names, or address for overflow). 4. Printing a formatted report to APPRINT with headers, vendor details, and totals for each 1099 type group. 5. Enforcing business rules for box mapping, payee name formatting, and report structure.

Tables/Files Used: - AP761 (vendor 1099 data, primary input). - GSTABL (1099 type descriptions, indexed). - APPRINT (printer output for the report).

External Programs Called: - None directly called, but invoked by AP760P.ocl36.txt and relies on parameters set by AP760P.

If you need further details, such as a sample report layout or additional analysis of the AP761 file structure, let me know!