Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Can this be performed using sort/icetool?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Shanthid

New User


Joined: 02 Jun 2006
Posts: 3

PostPosted: Tue Feb 08, 2011 3:16 pm    Post subject: Can this be performed using sort/icetool?
Reply with quote

Can this be performed using sort/icetool?

I have an input file in the below format

Column1 | Column2 | Column3
-------------------------------------------------
AAAA.FILE1 | 1111 | aaaaa
AAAA.FILE1 |2222 | aaaaa
AAAA.FILE2 | 1111 | aaaaa
AAAA.FILE2 | 2222 | aaaaa
AAAA.FILE3 | 1111 | aaaaa
AAAA.FILE4 | 1111 | aaaaa

The above file refers column2 and column3 values are in the filename mentioned in column1.
I want the below to be perfomed with the above file(this file will be changing in each run)

1)Need to get the filename(column1) into a output file with the duplicates removed
2)All these files from step1 should be merged to a single file(input to the merge is dynamic).
3)Count of each file and the merged file into another file with filename and count
Example
count
AAAA.FILE1 - 100
AAAA.FILE2 - 100
AAAA.FILE3 - 100
AAAA.FILE4 - 100

Merged file - 400
Back to top
View user's profile Send private message

giraffe

New User


Joined: 09 Nov 2010
Posts: 28
Location: SHENZHEN CHINA

PostPosted: Tue Feb 08, 2011 6:23 pm    Post subject:
Reply with quote

Hi, Pls try my code showed below:
Code:
CNTFILE    EXEC PGM=SORT
SYSOUT      DD    *
SYSPRINT   DD    *
SYSUDUMP DD   *
SORTIN       DD   DSN=...
SORTOUT   DD   DSN=...
SYSIN         DD    *
   SKIPREC=2
   INREC    FIELDS=(1,10,C'001')
   SORT      FIELDS=(1,10,CH,A)
   SUM       FIELDS=(11,3,ZD)
   OUTREC  FIELDS=(1,10,C' - ',11,3) 
   OUTFIL   FNAMES=(SORTOUT),
                 HEADER1=('COUNT'),
                 TRAILER1=('MERGED FILE - ', TOTAL=(14,3,ZD))
/*     
//*

Since I'm not at my working place, so I didn't run it, but I think the logic is correct, pls try it and respond me.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Feb 08, 2011 10:34 pm    Post subject: Reply to: Can this be performed using sort/icetool?
Reply with quote

shantid wrote:

The above file refers column2 and column3 values are in the filename mentioned in column1.
I want the below to be perfomed with the above file(this file will be changing in each run)

1)Need to get the filename(column1) into a output file with the duplicates removed
2)All these files from step1 should be merged to a single file(input to the merge is dynamic).
3)Count of each file and the merged file into another file with filename and count


shantid,

Are all files to be merged have same DCB properties (LRECL, RECFM ...)?

Do you have the authority to submit a job dynamically via INTRDR?

Is there anything in these files that identifies them uniquely ?

giraffe,

You need to spend some time reading the Op's question again before you answer.
Back to top
View user's profile Send private message
Shanthid

New User


Joined: 02 Jun 2006
Posts: 3

PostPosted: Wed Feb 09, 2011 9:27 am    Post subject:
Reply with quote

Skolusu,

Yes merged files have the same DCB properties

No,we dont have access for INTRDR.

no there is nothing to identify them uniquely.

giraffe,

The logic which you gave dint work.

Thanks
Back to top
View user's profile Send private message
Guest







PostPosted: Wed Feb 09, 2011 11:43 am    Post subject:
Reply with quote

Hi Shanthid,
According to my understanding of your requirement you can use the following JCL:

Code:

//JCLLIB   JCLLIB ORDER=(XXXX.MEMBER.IBM)                             
//*                                                                   
//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
XXXX.TEMP.IBM1|111 | AAAAA                                             
XXXX.TEMP.IBM1|222 | AAAAA                                             
XXXX.TEMP.IBM2|111 | AAAAA                                             
XXXX.TEMP.IBM2|222 | AAAAA                                             
XXXX.TEMP.IBM3|111 | AAAAA                                             
XXXX.TEMP.IBM3|111 | AAAAA                                             
//OUT      DD DSN=XXXX.OUTPUT1.IBM,DISP=(,CATLG)                                                         
//OUT1     DD DSN=XXXX.MEMBER.IBM(MEM1),DISP=OLD                       
//OUT2     DD DSN=XXXX.MEMBER.IBM1,DISP=(,CATLG)                                                             
//SYSIN    DD *                                                       
 SORT FIELDS=(1,14,CH,A)                                               
 SUM FIELDS=NONE                                                       
 OUTFIL FNAMES=OUT,BUILD=(1,14)                                       
 OUTFIL FNAMES=OUT1,                                                   
     IFTHEN=(WHEN=INIT,                                               
    BUILD=(C'//SORTIN',SEQNUM,2,ZD,C' DD DSN=',1,14,C',DISP=SHR',80:X))
 OUTFILE FNAMES=OUT2,REMOVECC,                                         
     IFTHEN=(WHEN=INIT,                                               
  BUILD=(C' COUNT FROM(SORTIN',SEQNUM,2,ZD,C') WRITE(SORTOUT) TEXT(''',
           1,14,C''')',80:X)),                                         
    HEADER1=(C' COUNT',80:X),                                         
    TRAILER1=(C' COUNT FROM(SORTIN99) WRITE(SORTOUT) TEXT(''MERGE'')',
        80:X)                                                         
//*                                                                   
//STEP0200 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//FILES  INCLUDE MEMBER=MEM1                       
//SORTOUT  DD DSN=XXXX.MERGE.IBM.OUT,DISP=(,CATLG),
//             RECFM=FB,         
//             LRECL=80                           
//SYSIN    DD *                                   
 MERGE FIELDS=(1,1,CH,A)                           
//*                                               
//STEP0300 EXEC PGM=ICETOOL                       
//TOOLMSG  DD SYSOUT=*                             
//DFSMSG   DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//FILES  INCLUDE MEMBER=MEM1                       
//SORTIN99 DD DSN=XXXX.MERGE.IBM.OUT,DISP=SHR     
//SORTOUT  DD SYSOUT=*                             
//TOOLIN   DD DSN=XXXX.MEMBER.IBM1,DISP=SHR 


Kindly get back to me incase of any concern.

devil13
There is always a better solution.
Back to top
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2165
Location: @my desk

PostPosted: Wed Feb 09, 2011 3:12 pm    Post subject:
Reply with quote

Did you test your "solution" before posting?
Back to top
View user's profile Send private message
Guest







PostPosted: Wed Feb 09, 2011 4:06 pm    Post subject:
Reply with quote

Hi Arun,

Well it worked fine for me and I got the ouput. The result from my spool:

Code:

XXXX.TEMP.IBM1000000000000002
XXXX.TEMP.IBM2000000000000002
XXXX.TEMP.IBM3000000000000002
MERGE000000000000006       


devil13
There is always a better solution.
Back to top
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 09, 2011 10:54 pm    Post subject:
Reply with quote

devil13 wrote:
Hi Arun,
Well it worked fine for me and I got the ouput. The result from my spool:


Delete the MEM1 from your PDS first and then re-run your job. The INCLUDE MEMBER=MEM1 is substituted well before running the first step which creates it. You would get a JCL error when you try to run the job.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2165
Location: @my desk

PostPosted: Wed Feb 09, 2011 11:18 pm    Post subject:
Reply with quote

devil13 wrote:
Well it worked fine for me
devil13,

You cannot edit the job which has already started running. One possible way is to submit it through INTRDR which Kolusu has already mentioned here, but the OP is restricted to do.

Do test your solutions before posting.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 09, 2011 11:44 pm    Post subject:
Reply with quote

Shanthid wrote:
Skolusu,

Yes merged files have the same DCB properties


What is the LRECL and RECFM for the files.

Shanthid wrote:
No,we dont have access for INTRDR.


Well I can show you a way to create JCL needed to merge all the dataset and get the counts but if you don't have INTRDR access then you need to manually submit the job.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Feb 10, 2011 12:43 am    Post subject:
Reply with quote

Shanthid,
What is the purpose of the data in Column 2 and Column 3 in your original post? Are those some kind of criteria for including records (in the Step2 merge) from the file(s) identified in Column 1? Or can they just be ignored?
Back to top
View user's profile Send private message
Guest







PostPosted: Thu Feb 10, 2011 5:56 am    Post subject:
Reply with quote

Hi All,
It was an easy thing to figure out. I have mentioned the MEM1 as DISP=OLD.
Code:

//OUT1     DD DSN=XXXX.MEMBER.IBM(MEM1),DISP=OLD


And first time when we submit the job we need to add dummy data to the MEM1.

Just like this:
Code:

//SORTIN01 DD DSN=XXXX.TEMP.IBM1,DISP=SHR


It would be the easiest thing to solve this error:

Code:

ICE056A N SORTIN01 NOT DEFINED


Quote:

Do test your solutions before posting.


Well I missed to mention about adding dummy data. But I thought it would be easy to figure that out icon_smile.gif

This JCL definitely works icon_smile.gif
But as my signature goes there is always a better solution and I have always been learning from here.


devil13
There is always a better solution
Back to top
Guest







PostPosted: Thu Feb 10, 2011 6:14 am    Post subject:
Reply with quote

Hi,
The same JCL once again:
Code:

 //JCLLIB   JCLLIB ORDER=(XXXX.MEMBER.IBM)                               
 //*                                                                     
 //STEP0100 EXEC PGM=SORT                                               
 //SYSOUT   DD SYSOUT=*                                                 
 //SORTIN   DD *                                                         
 XXXX.TEMP.IBM1111 | AAAAA                                               
 XXXX.TEMP.IBM1222 | AAAAA                                               
 XXXX.TEMP.IBM2111 | AAAAA                                               
 XXXX.TEMP.IBM2222 | AAAAA                                               
 XXXX.TEMP.IBM3111 | AAAAA                                               
 XXXX.TEMP.IBM3111 | AAAAA                                               
 //OUT      DD DSN=XXXX.OUTPUT1.IBM,DISP=(,CATLG),                       
 //             DATACLAS=XXXX                                         
 //OUT1     DD DSN=XXXX.MEMBER.IBM(MEM1),DISP=OLD                       
 //OUT2     DD DSN=XXXX.MEMBER.IBM1,DISP=(,CATLG),                       
 //             DATACLAS=XXXX                                         
 //SYSIN    DD *                                                         
  SORT FIELDS=(1,14,CH,A)                                               
  SUM FIELDS=NONE                                                       
  OUTFIL FNAMES=OUT,BUILD=(1,14)                                         
  OUTFIL FNAMES=OUT1,                                                   
      IFTHEN=(WHEN=INIT,                                                 
     BUILD=(C'//SORTIN',SEQNUM,2,ZD,C' DD DSN=',1,14,C',DISP=SHR',80:X))
  OUTFILE FNAMES=OUT2,REMOVECC,                                         
      IFTHEN=(WHEN=INIT,                                                 
   BUILD=(C' COUNT FROM(SORTIN',SEQNUM,2,ZD,C') WRITE(SORTOUT) TEXT(''',
            1,14,C''')',80:X)),                                         
     TRAILER1=(C' COUNT FROM(SORTIN99) WRITE(SORTOUT) TEXT(''MERGE'')', 
         80:X)                                                           
 //*                                                                     
 //STEP0200 EXEC PGM=SORT                                               
 //SYSOUT   DD SYSOUT=*                                                 
 //FILES  INCLUDE MEMBER=MEM1                                           
//SORTOUT  DD DSN=XXXX.MERGE.IBM.OUT,DISP=(,CATLG),
//             DATACLAS=XXXX,RECFM=FB,         
//             LRECL=80                           
//SYSIN    DD *                                   
 MERGE FIELDS=(1,1,CH,A)                           
//*                                               
//STEP0300 EXEC PGM=ICETOOL                       
//TOOLMSG  DD SYSOUT=*                             
//DFSMSG   DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//FILES  INCLUDE MEMBER=MEM1                       
//SORTIN99 DD DSN=XXXX.MERGE.IBM.OUT,DISP=SHR     
//SORTOUT  DD SYSOUT=*                             
//TOOLIN   DD DSN=XXXX.MEMBER.IBM1,DISP=SHR       



devil13
There is always a better solution.
Back to top
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 10, 2011 7:11 am    Post subject:
Reply with quote

devil13 wrote:
Hi All,
It was an easy thing to figure out. I have mentioned the MEM1 as DISP=OLD.
Well I missed to mention about adding dummy data. But I thought it would be easy to figure that out icon_smile.gif

This JCL definitely works icon_smile.gif


Devil13,

Apart from adding a dummy member before running the job. There are a few things you missed.

1. The Max length of a file name is 44 bytes. Your first problem is building the dynamic file names in the COUNT control cards

2. You are merging the datasets based on the first char in the files. what makes you think the data is already sorted on the first byte?

3. Since you did not account for varying length file names your job would abend as the DISP is coded after DSN name.

Running your test job is fine with creating a member in your pds, but what if the same job needs to used in production? Imagine how many jobs would be held up since you had DISP=OLD on a Production PDS.

You need to consider all scenarios before you post a solution and claim it to be working.

And just for the record , you don't need 2 steps (one to merge and 1 to get the count as we can get all of them in one go).
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2165
Location: @my desk

PostPosted: Thu Feb 10, 2011 7:20 am    Post subject:
Reply with quote

Skolusu wrote:
The INCLUDE MEMBER=MEM1 is substituted well before running the first step which creates it
devil13,

I wonder still you did not/are not willing to understand this. It's better not to make any further posts until we hear from the OP on the requested info.
Back to top
View user's profile Send private message
Guest







PostPosted: Thu Feb 10, 2011 7:59 am    Post subject:
Reply with quote

Hi,
I am willing to learn from mistakes.

Definitely I suggested from the limit of my knowlege and well thats pretty small icon_smile.gif

devil13
There is always a better solution.
Back to top
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Thu Feb 10, 2011 8:07 am    Post subject:
Reply with quote

Quote:
There is always a better solution.
In linear programming (a branch of methematics), an optimal solution means there is no better solution, period. Computer programming deals with a number of linear programming issues -- such as the traveling salesman problem -- so if an optimal solution exists to the linear programming problem, your tag line is not a true statement.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us