I'm using a sort to extract some values from differents datasets. The idea here is to place the name of the datasets in a column between the extract value just to identify in what data set the value was found.
Z062089 | DANIEL I GONZALEZ | 13 Aug 2019 |
Z062089 | DANIEL I GONZALEZ | 14 Aug 2019 |
Z062089 | DANIEL I GONZALEZ | 14 Aug 2019 |
Z062089 | DANIEL I GONZALEZ | 16 Aug 2019 |
Z062089 | DANIEL I GONZALEZ | 16 Aug 2019 |
And the idea of the report is to have it like this
Z062089 | DANIEL I GONZALEZ | 13 Aug 2019 |SIS.SEGLOG.LISTUSR.RACF.D190803
Z062089 | DANIEL I GONZALEZ | 14 Aug 2019 |
Z062089 | DANIEL I GONZALEZ | 14 Aug 2019 |SIS.SEGLOG.LISTUSR.RACF.D190805
Z062089 | DANIEL I GONZALEZ | 16 Aug 2019 |SIS.SEGLOG.LISTUSR.RACF.D190806
Z062089 | DANIEL I GONZALEZ | 16 Aug 2019 |
The example above is imagining the name of the dataset continuing the record length of the file
And the idea of the report is to have it like this
Z062089 | DANIEL I GONZALEZ | 13 Aug 2019 |SIS.SEGLOG.LISTUSR.RACF.D190803 <-- How come they do match???
Z062089 | DANIEL I GONZALEZ | 14 Aug 2019 |
Z062089 | DANIEL I GONZALEZ | 14 Aug 2019 |SIS.SEGLOG.LISTUSR.RACF.D190805 <-- How come they do match???
Z062089 | DANIEL I GONZALEZ | 16 Aug 2019 |SIS.SEGLOG.LISTUSR.RACF.D190806 <-- How come they do match???
Z062089 | DANIEL I GONZALEZ | 16 Aug 2019 |
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
Quote:
But if we can know in which exactly dataset the sort found the extracted values
Which you cannot do with sort and, as you are posting tin the DFSort part of the forum one has to presume that you want a sort solution.
A programming solution is possible. It would involve passing a dataset name into the program which would then create a dataset containing that DSN and then invoke DFSort to execute a JOINKEYS operation. Loop back to get next dataset name.
JP0 is a nice way to get that done and also can be done using DFSORT Symbols (SYMNAMES).
If the two records belongs to one Data set then only first record should get the Data Set Name suffixed and not all. This is based on Op's initial Post and as per my understanding. If this is not what it is then ignore this modification and use above solution.
So a little modification to this would achieve what is needed ultimately.
JP0 is a nice way to get that done and also can be done using DFSORT Symbols (SYMNAMES).
SYMNAMES doesn't make any change, or benefits related to the way of passing JCL variables into SORT control statements. Just one extra stage of passing the same value.
More simple way (with JES2 only) would be: using the // EXPORT statement of JCL, and SYMBOLS=(EXECSYS) parameter of DD statement, to pass JCL parameters values straightforward to SORT control statements
Rohit Umarjikar wrote:
If the two records belongs to one Data set then only first record should get the Data Set Name suffixed and not all. This is based on Op's initial Post and as per my understanding. If this is not what it is then ignore this modification and use above solution.
So a little modification to this would achieve what is needed ultimately.
1) BUILD= instead of the first OVERLAY= would simplify the rest of BUILD parameters
2) (more important) Also need to take care of the LRECL of each created record, especially when using VTOF.
Discussion of these "bells and whistles" is mainly for Beginner's Forum.
3) Logically, this final formatting to be done not in each LOOKFOR step, but in the last PRINT step, - by PGM=SORT used instead of IEBGENER. It's always preferable to look ahead, and separate the stage of searching for data from the stage of formatting the output report(s):
- the long prepared flat table might need in the future some extra modifications changing the order of rows, or eliminating some rows for new requirements; pseudo "header" rows might disappear before final print/output.
- The format of "group headers" may also require changes in the future, like "titles" before the group of lines, or whatever else.
Thanks again so much for take your time to answer my question.
Best Regards!
If this is not critical for further operations, I'd suggest to remove parameter VTOF (to leave output file RECFM=VB). Otherwise LRECL conflict during write to &&FINDLIST may occur when some DSNs used are of different length...
Or, you can force the same output length using
BUILD=(. . . . . ,JP0,JFY=(SHIFT=LEFT,LENGTH=45))
I continuously recommend to combine both SYNCSORT and DFSORT forums into a single SORT forum. Minor differences between two versions are important for Beginners Forum only.