IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to place name of the file where the data was extract


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
danielgp89

New User


Joined: 17 Oct 2019
Posts: 4
Location: Mexico

PostPosted: Thu Oct 17, 2019 12:55 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Thu Oct 17, 2019 1:02 am
Reply with quote

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
View user's profile Send private message
danielgp89

New User


Joined: 17 Oct 2019
Posts: 4
Location: Mexico

PostPosted: Thu Oct 17, 2019 1:11 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Oct 17, 2019 1:15 am
Reply with quote

Quote:
How can I do it?

I don't think you can. I could look up the manual to confrim this but...so could you.
Back to top
View user's profile Send private message
danielgp89

New User


Joined: 17 Oct 2019
Posts: 4
Location: Mexico

PostPosted: Thu Oct 17, 2019 1:31 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Oct 17, 2019 2:48 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Oct 17, 2019 2:19 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Thu Oct 17, 2019 7:21 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Oct 17, 2019 7:56 pm
Reply with quote

Neat, sergeyken.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Oct 17, 2019 8:39 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Thu Oct 17, 2019 9:53 pm
Reply with quote

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
View user's profile Send private message
danielgp89

New User


Joined: 17 Oct 2019
Posts: 4
Location: Mexico

PostPosted: Fri Oct 18, 2019 12:14 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Fri Oct 18, 2019 1:05 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Fri Oct 18, 2019 8:59 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Fri Oct 18, 2019 11:03 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Oct 19, 2019 2:06 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Mon Oct 21, 2019 2:57 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Mon Oct 21, 2019 3:55 am
Reply with quote

Agree.
Btw OP don’t mentioned the product at site so far nor share the SORTOUT to make a decision.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Oct 21, 2019 1:09 pm
Reply with quote

He has posted in the Beginners forum and that shows that he is using Syncsort.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top