Topic
3 replies Latest Post - ‏2012-10-16T22:18:16Z by BillWoodger
SystemAdmin
SystemAdmin
403 Posts
ACCEPTED ANSWER

Pinned topic input data trace

‏2012-10-15T21:58:28Z |
I have a program that reads a record from a file, but uses only a subset of the fields on that record. Is there a way, via TraceMaster, Debug, compiler option, ..., that would list the input record fields the program actually accesses?
For example, the input record layout is
10 CUST-ACCT-NO PIC X(010).
10 CUST-CUR-BLG-DY PIC X(002).
10 SUMMRY-BLG-INDR PIC X(001).
10 ASGND-BL-CYCLE PIC X(002).
etc...
By manually searching the source code I could determine that, say, the first 2 fields are used in the program but the second two are not.
The problem is: I have dozens of programs each with many input files, each with hundreds of fields. Manually eyeballing would get tedious and error prone after awhile :-(
Any suggestions?
Updated on 2012-10-16T22:18:16Z at 2012-10-16T22:18:16Z by BillWoodger
  • BillWoodger
    BillWoodger
    75 Posts
    ACCEPTED ANSWER

    Re: input data trace

    ‏2012-10-15T22:05:52Z  in response to SystemAdmin
    If you look at the compiler options in your manual (I don't know which compiler you are using, you didn't say) you should be able to get a "cross reference" of data-names on the compile listing. This will show you the line number where defined (on the compile listing) and all lines which reference a particular field, again the line number on the listing. You'll even, probably, find useful information attached - M prefixed to the line number of the reference indicates the the field is "modified" by the reference. This is detailed at the start of the cross reference itself.
    • SystemAdmin
      SystemAdmin
      403 Posts
      ACCEPTED ANSWER

      Re: input data trace

      ‏2012-10-16T20:50:08Z  in response to BillWoodger
      Bill,

      We use the IBM Enterprise z/OS COBOL compiler, and the option that provides that cross reference is XREF, which generated this listing:

      Defined Cross-reference of data names References
      9006 ABEND-DB2-WARNINGS . . . . . . M16400
      9030 ABEND-OTH-INFO . . . . . . . . M12583 M12843 M12960 M13244
      ...
      1598 COMINGLED-BILL
      3540 COMMON-AREA-CONTINUED
      581 COMPANY-CODE . . . . . . . . . 12909 12981
      729 COMPANY-CODE . . . . . . . . . 11681 11993 12069 12459
      etc...

      This will be helpful, though I will still need to write some REXX script to aid me in wading through the tons of compiled listings I will have to go through :-).

      Thank you for the info.
      • BillWoodger
        BillWoodger
        75 Posts
        ACCEPTED ANSWER

        Re: input data trace

        ‏2012-10-16T22:18:16Z  in response to SystemAdmin
        XREF(SHORT) will give you on the cross-reference only those items explicitly referenced. Good for humans, not necessary for programmatic processing.

        From the data division map, you can get all the line numbers for all the data definitions for each 01 level. They have leading-zeros suppressed, unlike the XREF. Bit of "normalisation" required.

        You have the source listing, for data and procedure.

        You have the Verb cross-reference, and Procedure cross-reference.

        There's a lot of "information" you can pull out of all this "data", and the compiler has done the bulk of the work for you :-)

        I found AWK more convenient for the processing, as its "associative arrays" make it easy. You could try to "mimic" that with pairs of stem variables, one referenced by a simple number, the value of which can be the reference for the other stem. Just a thought. Perhaps the more-traditional Rexx ways would be enough.

        Once you've go the general thing up and running (to make all of that information available for use within a program), the requirement you have is a piece of cake :-)