|
View previous topic :: View next topic
|
| Author |
Message |
danielgp89
New User
Joined: 17 Oct 2019 Posts: 4 Location: Mexico
|
|
|
|
Hello!
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.
The data sets are:
SIS.SEGLOG.LISTUSR.RACF.D190803
SIS.SEGLOG.LISTUSR.RACF.D190804
SIS.SEGLOG.LISTUSR.RACF.D190805
SIS.SEGLOG.LISTUSR.RACF.D190806
SIS.SEGLOG.LISTUSR.RACF.D190807
This is the final the result of the sort report
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
this is my code
| Code: |
//TOOLIN DD *
SORT FROM(INDD) TO(OUTDD) USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
INCLUDE COND=(6,8,CH,EQ,C'Z062089')
OUTFIL FNAMES=OUTDD,VTOF,OUTREC=(5,8,13,3,16,1,13,3,18,20,13,3,
16,1,13,3,356,12) |
How can I do it? |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| danielgp89 wrote: |
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 |
|
|
|
| Back to top |
|
 |
danielgp89
New User
Joined: 17 Oct 2019 Posts: 4 Location: Mexico
|
|
|
|
In the original report where I'm extracting the data, the name of the dataset doesn't come.
I was wondering if I can define a statement in the sort syntax, to place between cols xx and xx the name of the dataset where the value was found.
The dataset that I specified in the INDD Step |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
I don't think you can. I could look up the manual to confrim this but...so could you. |
|
| Back to top |
|
 |
danielgp89
New User
Joined: 17 Oct 2019 Posts: 4 Location: Mexico
|
|
|
|
Thanks for the help Nic!
We know that the extracted data obviously is in those datasets.
But if we can know in which exactly dataset the sort found the extracted values. It will save me a lot of time.
Regards! |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| You can do it thru combination of REXX and DFSORT. I don't know much REXX but I have seen it in my project. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
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. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| Code: |
//*====================================================================
//SCANDSN PROC DS=NULLFILE
//*
//LOOKFOR EXEC PGM=SORT,PARM='JP0"&DS"'
//*
//SYSOUT DD SYSOUT=*
//*
//SORTIN DD DISP=SHR,DSN=&DS
//OUTDD DD DISP=(MOD,PASS),
// UNIT=SYSDA,SPACE=(TRK,(100,100)),
// DSN=&&FINDLIST
//*
//SYSIN DD *
INCLUDE COND=(6,8,CH,EQ,C'Z062089')
SORT FIELDS=COPY
OUTREC BUILD=(1,4,
5,8,
13,3,
16,1,
13,3,
18,20,
13,3,
16,1,
13,3,
356,12,
JP0)
OUTFIL FNAMES=OUTDD,VTOF
END
//*
// PEND
//*====================================================================
//DSN#1 EXEC SCANDSN,DS=&SYSUID..DSN#1
//DSN#2 EXEC SCANDSN,DS=&SYSUID..DSN#2
//DSN#3 EXEC SCANDSN,DS=&SYSUID..DSN#3
//DSN#4 EXEC SCANDSN,DS=&SYSUID..DSN#4
//* . . . . . . . . . . . . . . . . . . . .
//DSN#99 EXEC SCANDSN,DS=&SYSUID..DSN#99
//DSN#100 EXEC SCANDSN,DS=&SYSUID..DSN#100
//*--------------------------------------------------------------------
//PRINT EXEC PGM=IEBGENER
//SYSPRINT DD DUMMY
//SYSIN DD DUMMY
//SYSUT1 DD DISP=(OLD,DELETE),DSN=&&FINDLIST
//SYSUT2 DD SYSOUT=*
//*
//*==================================================================== |
|
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Neat, sergeyken. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
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.
| Code: |
//SYSIN DD *
INCLUDE COND=(6,8,CH,EQ,C'Z062089')
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(500:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(500,8,ZD,EQ,1),
BUILD=(1,4,
5,8,
13,3,
16,1,
13,3,
18,20,
13,3,
16,1,
13,3,
356,12,
JP0)),
IFTHEN=(WHEN=NONE,
BUILD=(1,4,
5,8,
13,3,
16,1,
13,3,
18,20,
13,3,
16,1,
13,3,
356,12))
OUTFIL FNAMES=OUTDD,VTOF
END
|
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| Rohit Umarjikar wrote: |
| 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. |
|
| Back to top |
|
 |
danielgp89
New User
Joined: 17 Oct 2019 Posts: 4 Location: Mexico
|
|
|
|
Thanks a lot for your help.
It works great! This was my final JCL
| Code: |
//SCANDSN PROC DS=NULLFILE
//*
//SETP001 EXEC PGM=ICETOOL,PARM='JP0"&DS"'
//*
//SYSOUT DD SYSOUT=*
//INDD DD DISP=SHR,DSN=&DS
//*OUTDD DD SYSOUT=*
//OUTDD DD DISP=(MOD,PASS),
// UNIT=3390,
// SPACE=(CYL,(2,2),RLSE),
// DSN=&&FINDLIST
//TOOLIN DD *
SORT FROM(INDD) TO(OUTDD) USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
INCLUDE COND=((6,8,CH,EQ,C'PRTRCATA'),OR,
(6,8,CH,EQ,C'C107161'),OR,
(6,8,CH,EQ,C'PRIFZERO'),OR,
OUTREC BUILD=(1,4,5,8,13,3,16,1,13,3,18,20,13,3,
16,1,13,3,356,12,13,3,JP0)
OUTFIL FNAMES=OUTDD,VTOF
END
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//*
// PEND
//DSN1 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190601
//DSN2 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190602
//DSN3 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190603
//DSN4 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190604
//DSN5 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190605
//DSN6 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190606
//DSN7 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190607
//DSN8 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190608
//DSN9 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190609
//DSN10 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190610
//DSN11 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190611
//DSN12 EXEC SCANDSN,DS=SIS.SEGLOG.LISTUSR.RACF.D190612
//PRINT EXEC PGM=IEBGENER
//SYSPRINT DD DUMMY
//SYSIN DD DUMMY
//SYSUT1 DD DISP=(OLD,DELETE),DSN=&&FINDLIST
//SYSUT2 DD SYSOUT=*
//* |
Thanks again so much for take your time to answer my question.
Best Regards! |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| danielgp89 wrote: |
Thanks a lot for your help.
It works great! This was my final JCL
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)) |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| danielgp89 wrote: |
This was my final JCL
| Code: |
//CTL1CNTL DD *
SORT FIELDS=COPY
INCLUDE COND=((6,8,CH,EQ,C'PRTRCATA'),OR,
(6,8,CH,EQ,C'C107161'),OR,
(6,8,CH,EQ,C'PRIFZERO'),OR,
OUTREC BUILD=(1,4,5,8,13,3,16,1,13,3,18,20,13,3,
16,1,13,3,356,12,13,3,JP0)
OUTFIL FNAMES=OUTDD,VTOF
END
/*
|
|
1) I suspect there is a mismatch in used positions, isn't it?
| Quote: |
INCLUDE COND=((6,8,CH,EQ,C'PRTRCATA'),OR,
. . . . . . . . . . . .
OUTREC BUILD=(1,4,5,8,13,3,16,1,13,3,18,20,13,3, |
2) selection can be simplified
| Code: |
INCLUDE COND=((6,8,CH,EQ,L(C'PRTRCATA',
C'C107161',
C'PRIFZERO',
C'. . . . '))
. . . . . . . . . . . . . |
Or
| Code: |
INCLUDE COND=((6,8,SS,EQ,C'PRTRCATA,C107161 ,PRIFZERO,. . .'))
. . . . . . . . . . . . . |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
Long list selection needs to be replaced by JOINKEYS from file:
| Code: |
//*=========================================
//SCANDSN PROC DS=NULLFILE
//*
//LOOKFOR EXEC PGM=ICETOOL,PARM='JP0"&DS"'
//*
//SYSOUT DD SYSOUT=*
//USERLIST DD *
PRTRCATA
C107161
PRIFZERO
. . . .
. . . .
+ 100500 different IDs
. . . .
//*
//INDD DD DISP=SHR,DSN=&DS
//*
//OUTDD DD DISP=(MOD,PASS),
// UNIT=3390,
// SPACE=(CYL,(2,2),RLSE),
// DSN=&&FINDLIST
//TOOLIN DD *
COPY JKFROM TO(OUTDD) USING(CTL1)
/*
//CTL1CNTL DD *
JOINKEYS F1=USERLIST,
FIELDS=(1,8,A)
JOINKEYS F2=INDD,
FIELDS=(6,8,A)
REFORMAT FIELDS=(F2:1,4,5)
OUTREC BUILD=(1,4,
5?,8,
13,3,
16,1,
13,3,
18,20,
13,3,
16,1,
13,3,
356,12,
13,3,
JP0)
OUTFIL FNAMES=OUTDD,VTOF
//*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//*
// PEND |
|
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Why post in the DFSort part of the forum when you have Syncsort. You have been asked before to post in the correct part of a forum. Do it in future.
Topic moved. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| 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. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
Agree.
Btw OP don’t mentioned the product at site so far nor share the SORTOUT to make a decision. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| He has posted in the Beginners forum and that shows that he is using Syncsort. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|