|
View previous topic :: View next topic
|
| Author |
Message |
Nablokov
New User
Joined: 13 Apr 2021 Posts: 4 Location: France
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 |
|
 |
Nablokov
New User
Joined: 13 Apr 2021 Posts: 4 Location: France
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| 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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| 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.  |
|
| Back to top |
|
 |
Nablokov
New User
Joined: 13 Apr 2021 Posts: 4 Location: France
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| Mind to share your solution? That would be great feedback to the ones who spent their time to help. |
|
| Back to top |
|
 |
Nablokov
New User
Joined: 13 Apr 2021 Posts: 4 Location: France
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| 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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|