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

Get two files from one file with diffrent sorted


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nablokov

New User


Joined: 13 Apr 2021
Posts: 4
Location: France

PostPosted: Tue Apr 13, 2021 2:53 am
Reply with quote

Hello,
at present, I have a file like this in SORTIN
TEAM LIVERPOOL
CITY PARIS
PLAYER ZINEDINE ZIDANE
PLAYER DIEGO MARADONA
TEAM REAL MADRID
CITY JAIPUR

I use a sort like this :
Code:
SORT FIELDS=(1,50,CH,A)
OPTION VLSHRT
OUTFIL FNAMES=SORTF1,OMIT=(1,6,CH,NE,C'PLAYER')
OUTFIL FNAMES=SORTF2,SAVE


SORTF1
CITY JAIPUR
CITY PARIS
TEAM LIVERPOOL
TEAM REAL MADRID
SORTF2:
PLAYER DIEGO MARADONA
PLAYER ENZO FRANCESCOLI


AND I would obtain the same SORTF1 but the following SORTF2 sorted by name (a SORT FIELDS=(50,50,CH,A)
PLAYER ENZO FRANCESCOLI
PLAYER DIEGO MARADONA

Is it possible to do it in one step ?

Thanks for any help
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Tue Apr 13, 2021 3:35 am
Reply with quote

The simplest way:

Use ICETOOL, and complete two (or more) SORT stages in one single job step.

Another way:
Code:
 INREC - shift all records except PLAYER 7 bytes to the right
 SORT FIELDS=(8,50,CH,A)
 OUTFIL FNAMES=F1,INCLUDE=(no PLAYER),BUILD=(8,50)
 OUTFIL FNAMES=F2,SAVE,BUILD=(1,50)
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Tue Apr 13, 2021 4:45 am
Reply with quote

Welcome!
Why are you sorting ?
PLAYER ENZO FRANCESCOLI - I don’t see in input.
What is SORT FIELDS=(50,50,CH,A) or a typo ?

Please use a code tags for input and expected output data as well and try to present expected output from the input again and rules.
Back to top
View user's profile Send private message
Nablokov

New User


Joined: 13 Apr 2021
Posts: 4
Location: France

PostPosted: Wed Apr 14, 2021 12:49 am
Reply with quote

Hello
Sorry my input SORTIN was false :
Code:
TEAM LIVERPOOL
CITY PARIS
PLAYER ENZO      FRANCESCOLI
PLAYER DIEGO     MARADONA
TEAM REAL MADRID
CITY JAIPUR


I want two output
First ouput (all except records starting by PLAYER) sorted by position 6
Second output (records starting by PLAYER) sorted by name position 18

The INPUT was in fact a VB 400 and I would keep the format for the two outputs.

Hoping it's clearer and not wrong this time

Nablokov
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Wed Apr 14, 2021 2:06 am
Reply with quote

Nablokov wrote:
Hello
Sorry my input SORTIN was false :
Code:
TEAM LIVERPOOL
CITY PARIS
PLAYER ENZO      FRANCESCOLI
PLAYER DIEGO     MARADONA
TEAM REAL MADRID
CITY JAIPUR


I want two output
First ouput (all except records starting by PLAYER) sorted by position 6
Second output (records starting by PLAYER) sorted by name position 18

The INPUT was in fact a VB 400 and I would keep the format for the two outputs.

Hoping it's clearer and not wrong this time

Nablokov

I gave you two solutions, both almost ready to use.
You have ignored all of them.
If so, there is no need to ask any questions; it’s wasting of time.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Wed Apr 14, 2021 3:00 am
Reply with quote

The original question was "Is it possible to do it in one step ?" , Answer is, it might be possible. TS is not asking how to do it , since its pretty simple to do it in multiple steps or one giant ICETOOL step with multiple COPY and CTL* statement/passes.

This is the dirty way in one step with multiple passes.
Code:
//TOOLIN DD *                                 
 COPY   FROM(SORTIN) TO(TEMP1) USING(CTL1)   
 COPY   FROM(SORTIN) TO(TEMP2) USING(CTL2)   
 COPY   FROM(TEMP1)  TO(SORTF1) USING(CTL3)   
 COPY   FROM(TEMP2)  TO(SORTF2) USING(CTL4)   
//CTL1CNTL DD *                               
 SORT FIELDS=COPY                             
 OMIT COND=(1,6,CH,NE,C'PLAYER')             
//CTL2CNTL DD *                               
 SORT FIELDS=COPY                             
 OMIT COND=(1,6,CH,EQ,C'PLAYER')             
//CTL3CNTL DD *                               
 SORT FIELDS=(18,20,CH,A)                     
//CTL4CNTL DD *                               
 SORT FIELDS=(6,20,CH,A) 

sergeyken wrote:
The simplest way:

Use ICETOOL, and complete two (or more) SORT stages in one single job step.

Another way:
Code:
 INREC - shift all records except PLAYER 7 bytes to the right
 SORT FIELDS=(8,50,CH,A)
 OUTFIL FNAMES=F1,INCLUDE=(no PLAYER),BUILD=(8,50)
 OUTFIL FNAMES=F2,SAVE,BUILD=(1,50)

Its a good idea but did you test it ?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1245
Location: Bamberg, Germany

PostPosted: Wed Apr 14, 2021 5:58 am
Reply with quote

Rohit Umarjikar wrote:
sergeyken wrote:
The simplest way:
..
Another way:
Code:
 INREC - shift all records except PLAYER 7 bytes to the right
 SORT FIELDS=(8,50,CH,A)
 OUTFIL FNAMES=F1,INCLUDE=(no PLAYER),BUILD=(8,50)
 OUTFIL FNAMES=F2,SAVE,BUILD=(1,50)

Its a good idea but did you test it ?

Yes. Verified and tested. icon_wink.gif
Back to top
View user's profile Send private message
Nablokov

New User


Joined: 13 Apr 2021
Posts: 4
Location: France

PostPosted: Wed Apr 14, 2021 10:02 am
Reply with quote

Sorry Sergeyken,
I didn't understand your solutions, I had made a mistake in the INREC and I ve believed that's because I was wrong in the wording of the problem.
It works now.
So, I am numbskull on this case.
Thank you again for your solution and your time ! and to Rohit and Joerg also to confirm I had to read and test !

Nablokov
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1245
Location: Bamberg, Germany

PostPosted: Wed Apr 14, 2021 10:34 am
Reply with quote

Mind to share your solution? That would be great feedback to the ones who spent their time to help.
Back to top
View user's profile Send private message
Nablokov

New User


Joined: 13 Apr 2021
Posts: 4
Location: France

PostPosted: Wed Apr 14, 2021 11:03 am
Reply with quote

Your're right Joerg, this is the solution I've used

Code:
INREC IFTHEN=(WHEN=(1,6,CH,NE,C'PLAYER'),                       
             BUILD(1,5,12X,6,50))                               
SORT FIELDS=(18,50,CH,A)                                       
OUTFIL FNAMES=F1,INCLUDE=(1,6,CH,NE,C'PLAYER'),BUILD=(1,5,18,50)
OUTFIL FNAMES=F2,SAVE,BUILD=(1,50)       


Thank you again
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Wed Apr 14, 2021 6:50 pm
Reply with quote

Nablokov wrote:
Your're right Joerg, this is the solution I've used

Code:
INREC IFTHEN=(WHEN=(1,6,CH,NE,C'PLAYER'),                       
             BUILD(1,5,12X,6,50))                               
SORT FIELDS=(18,50,CH,A)                                       
OUTFIL FNAMES=F1,INCLUDE=(1,6,CH,NE,C'PLAYER'),BUILD=(1,5,18,50)
OUTFIL FNAMES=F2,SAVE,BUILD=(1,50)       


Thank you again

Two output files become different LRECL (F1 - 55 bytes, F2 - 50 bytes).
For exercise purposes it’s OK, but in a real production task it may cause problems in the future.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 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
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top