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

Preserve order in Input File


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

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Thu Dec 21, 2017 4:20 pm
Reply with quote

Hi All,
I have file as below.


Code:

----+----1----+----2---
.....99999999999999ZrræDEL2017-12-21-09.54.34.217303
.....99999999999999ZrræUPD2017-12-21-09.54.24.302244
.....99999999999999ZrræINS2017-12-21-09.54.01.226931
.....2211111111ML02Z...DEL2017-12-21-20.51.44.387850
.....2211111111ML02Z...UPD2017-12-21-20.32.19.489322
.....2211111111ML02Z...INS2017-12-21-20.21.07.697698
.....3311111111ML03Z...UPD2017-12-21-20.32.19.493278
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
....<4411111111ML04Zà..DEL2017-12-21-20.51.44.429596
....<4411111111ML04Zà..INS2017-12-21-20.21.07.844705
....*5511111111ML05Zí..UPD2017-12-21-20.32.19.495195
....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497


and expecting the first key record in the O/P (Key is before "INS", "UPD" or "DEL") My o/p is coming as below.

Code:

....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497
....<4411111111ML04Zà..INS2017-12-21-20.21.07.844705
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
.....2211111111ML02Z...INS2017-12-21-20.21.07.697698
.....99999999999999ZrræINS2017-12-21-09.54.01.226931


Sort card:

Code:

//SYSIN    DD  *                     
       SORT FIELDS=(1,23,CH,D),EQUALS
       SUM FIELDS=NONE               
/*                                   


It is not preserving the Imput order. How can I preserve the order?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 21, 2017 4:36 pm
Reply with quote

Quote:
It is not preserving the Imput order. How can I preserve the order?


what makes You believe that sort has to take the blame icon_question.gif icon_evil.gif

You will find the culprit by looking at the content of the non displayable part of the records
- positions 1 to 5 of the posted data
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Thu Dec 21, 2017 4:44 pm
Reply with quote

Hello Enrico,

The non displayed part of the data is same for each key record. So KEY is same here.

Please see below after HEX ON

Input:
Code:

.....99999999999999ZrræDEL2017-12-21-09.54.34.217303
00001FFFFFFFFFFFFFFE999CCDFFFF6FF6FF6FF4FF4FF4FFFFFF
0001C99999999999999999C4532017012021009B54B34B217303
 ---------------------------------------------------
.....99999999999999ZrræUPD2017-12-21-09.54.24.302244
00001FFFFFFFFFFFFFFE999EDCFFFF6FF6FF6FF4FF4FF4FFFFFF
0001C99999999999999999C4742017012021009B54B24B302244
 ---------------------------------------------------
.....99999999999999ZrræINS2017-12-21-09.54.01.226931
00001FFFFFFFFFFFFFFE999CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0001C99999999999999999C9522017012021009B54B01B226931
 ---------------------------------------------------
.....2211111111ML02Z...DEL2017-12-21-20.51.44.387850
00002FFFFFFFFFFDDFFE211CCDFFFF6FF6FF6FF4FF4FF4FFFFFF
0002C22111111114302921C4532017012021020B51B44B387850
 ---------------------------------------------------
.....2211111111ML02Z...UPD2017-12-21-20.32.19.489322
00002FFFFFFFFFFDDFFE211EDCFFFF6FF6FF6FF4FF4FF4FFFFFF
0002C22111111114302921C4742017012021020B32B19B489322
 ---------------------------------------------------
.....2211111111ML02Z...INS2017-12-21-20.21.07.697698
00002FFFFFFFFFFDDFFE211CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0002C22111111114302921C9522017012021020B21B07B697698
 ---------------------------------------------------
.....3311111111ML03Z...UPD2017-12-21-20.32.19.493278
00003FFFFFFFFFFDDFFE311EDCFFFF6FF6FF6FF4FF4FF4FFFFFF
0003C33111111114303931C4742017012021020B32B19B493278
 ---------------------------------------------------
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
00003FFFFFFFFFFDDFFE311CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0003C33111111114303931C9522017012021020B21B07B843404
 ----------------------------------------------------
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
00003FFFFFFFFFFDDFFE311CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0003C33111111114303931C9522017012021020B21B07B843404
 ----------------------------------------------------
....<4411111111ML04Zà..DEL2017-12-21-20.51.44.429596
00004FFFFFFFFFFDDFFE411CCDFFFF6FF6FF6FF4FF4FF4FFFFFF
0004C44111111114304941C4532017012021020B51B44B429596
 ----------------------------------------------------
....<4411111111ML04Zà..INS2017-12-21-20.21.07.844705
00004FFFFFFFFFFDDFFE411CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0004C44111111114304941C9522017012021020B21B07B844705
 ----------------------------------------------------
....*5511111111ML05Zí..UPD2017-12-21-20.32.19.495195
00005FFFFFFFFFFDDFFE511EDCFFFF6FF6FF6FF4FF4FF4FFFFFF
0005C55111111114305951C4742017012021020B32B19B495195
 ----------------------------------------------------
....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497
00005FFFFFFFFFFDDFFE511CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0005C55111111114305951C9522017012021020B21B07B846497
 ----------------------------------------------------
....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497
00005FFFFFFFFFFDDFFE511CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0005C55111111114305951C9522017012021020B21B07B846497
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 21, 2017 4:47 pm
Reply with quote

what about the NON displayable part of the OUTPUT icon_question.gif
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Thu Dec 21, 2017 4:49 pm
Reply with quote

Here you go.

Code:

....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497
00005FFFFFFFFFFDDFFE511CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0005C55111111114305951C9522017012021020B21B07B846497
 ----------------------------------------------------
....<4411111111ML04Zà..INS2017-12-21-20.21.07.844705
00004FFFFFFFFFFDDFFE411CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0004C44111111114304941C9522017012021020B21B07B844705
 ----------------------------------------------------
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
00003FFFFFFFFFFDDFFE311CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0003C33111111114303931C9522017012021020B21B07B843404
 ----------------------------------------------------
.....2211111111ML02Z...INS2017-12-21-20.21.07.697698
00002FFFFFFFFFFDDFFE211CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0002C22111111114302921C9522017012021020B21B07B697698
 ----------------------------------------------------
.....99999999999999ZrræINS2017-12-21-09.54.01.226931
00001FFFFFFFFFFFFFFE999CDEFFFF6FF6FF6FF4FF4FF4FFFFFF
0001C99999999999999999C9522017012021009B54B01B226931
 ----------------------------------------------------
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Dec 21, 2017 7:33 pm
Reply with quote

You got exactly what You asked for ..., records in descending order icon_cool.gif
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Thu Dec 21, 2017 7:48 pm
Reply with quote

Well, keys are sorted in descending order. That's fine. When i sorted ASC also, i got same set of records in ascending order as below.

Code:
 
.....99999999999999ZrræINS2017-12-21-09.54.01.226931
....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497
....<4411111111ML04Zà..INS2017-12-21-20.21.07.844705
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
.....2211111111ML02Z...INS2017-12-21-20.21.07.697698


I am expecting o/p as below.

Code:

.....99999999999999ZrræDEL2017-12-21-09.54.34.217303
.....2211111111ML02Z...DEL2017-12-21-20.51.44.387850
.....3311111111ML03Z...UPD2017-12-21-20.32.19.493278
....<4411111111ML04Zà..DEL2017-12-21-20.51.44.429596
....*5511111111ML05Zí..UPD2017-12-21-20.32.19.495195


This is the same order as in input. But in my output I am getting the last key record.
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 Dec 21, 2017 8:00 pm
Reply with quote

Please show the sysout for your sort step.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Dec 21, 2017 11:12 pm
Reply with quote

I think you can use SELECT operator of ICETOOL as:
Code:
SELECT FROM(Input) TO(Output) ON(1,23,CH) FIRST


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

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Fri Dec 22, 2017 1:07 am
Reply with quote

pshongal wrote:
Sort card:

Code:

//SYSIN    DD  *                     
       SORT FIELDS=(1,23,CH,D),EQUALS
       SUM FIELDS=NONE               
/*                                   


It is not preserving the Imput order.

Any clue what SORT operation is supposed to do???

EQUALS preserves the order within multiple records with equal keys (which are then eliminated by your FIELDS=NONE)
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Fri Dec 22, 2017 9:52 am
Reply with quote

@Nic
Please see the SYSOUT

Code:

ICE201I A RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
ICE751I 0 C5-I40658 C6-I35397 C7-I35397 C8-I40658 E9-I40658 C9-I35397 E5-I35397
ICE143I 0 BLOCKSET     SORT  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5650-ZOS, Z/OS DFSORT V2R2  - 21:09 ON MON MA
                 SORT FIELDS=(1,23,CH,D),EQUALS                                 
                 SUM FIELDS=NONE                                               
ICE193I 0 ICEAM1 INVOCATION ENVIRONMENT IN EFFECT - ICEAM1 ENVIRONMENT SELECTED
ICE252I 1 PARMLIB OPTIONS WERE MERGED WITH INSTALLATION MODULE DEFAULTS         
ICE088I 1 DEVDB2QR.STEP030 .        , INPUT LRECL = 52, BLKSIZE = 27976, TYPE =
ICE093I 0 MAIN STORAGE = (MAX,134217728,134204510)                             
ICE156I 0 MAIN STORAGE ABOVE 16MB = (134143984,134143984)                       
ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,
ICE128I 0 OPTIONS: SIZE=134217728,MAXLIM=6291456,MINLIM=450560,EQUALS=Y,LIST=Y,E
ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=NO   ,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=
ICE130I 0 OPTIONS: RESALL=12288,RESINV=0,SVC=109 ,CHECK=N,WRKREL=Y,OUTREL=Y,CKPT
ICE131I 0 OPTIONS: TMAXLIM=134217728,ARESALL=0,ARESINV=0,OVERRGN=65536,CINV=Y,CF
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITC
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAMI
ICE235I 0 OPTIONS: NULLOUT=RC0                                                 
ICE236I 0 OPTIONS: DYNAPCT=10 ,MOWRK=Y,TUNE=STOR,EXPMAX=MAX    ,EXPOLD=50%    ,E
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTOUT                                   
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTIN                                   
ICE750I 0 DC 27976 TC 0 CS DSVUU KSZ 27 VSZ 27                                 
ICE752I 0 FSZ=538 RC  IGN=0 E  AVG=56 0  WSP=39 C  DYN=0 0                     
ICE751I 1 DE-I35397 D5-I35397 D9-I35397 E8-I40658                               
ICE090I 0 OUTPUT LRECL = 52, BLKSIZE = 27976, TYPE = FB                         
ICE080I 0 IN MAIN STORAGE SORT                                                 
ICE055I 0 INSERT 0, DELETE 7                                                   
ICE054I 0 RECORDS - IN: 12, OUT: 5                                             
ICE134I 0 NUMBER OF BYTES SORTED: 624                                           
ICE253I 0 RECORDS SORTED - PROCESSED: 12, EXPECTED: 538                         
ICE199I 0 MEMORY OBJECT USED AS MAIN STORAGE = 0M BYTES                         
ICE299I 0 MEMORY OBJECT USED AS WORK STORAGE = 0M BYTES                         
ICE180I 0 HIPERSPACE STORAGE USED = 0K BYTES
ICE188I 0 DATA SPACE STORAGE USED = 0K BYTES
ICE052I 0 END OF DFSORT                     


@sergeyken

Actually, I don't need records to be sorted again as this file is already sorted (Key: 1-23). I want duplicates to be removed keeping the 1st key record as it appears in input.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Dec 22, 2017 5:49 pm
Reply with quote

Quote:
Actually, I don't need records to be sorted again as this file is already sorted (Key: 1-23). I want duplicates to be removed keeping the 1st key record as it appears in input.


Based on what you have shown, the file is sorted on the key in ASCENDING order.

You are resorting in descending order. Totally different.

Furthermore, when using equals parameter on a descending sort, is the FIRST or LAST record (from the ascending perspective) be the one to be kept?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Fri Dec 22, 2017 6:30 pm
Reply with quote

If th data is already sorted in the sequence that you want and a set of records with the same key is a group and the first record is the one that you want then use the GROUP keyword and add a sequence number that resets on change of group and on the ouput phase include only the records witha sequence number of 1 and remember to remove the sequence number from the output record.

I have never done this but I read most posts and know that there examples in the forum - all you have to do is look for them.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Dec 22, 2017 8:20 pm
Reply with quote

pshongal wrote:
Well, keys are sorted in descending order. That's fine. When i sorted ASC also, i got same set of records in ascending order as below.

Code:
 
.....99999999999999ZrræINS2017-12-21-09.54.01.226931
....*5511111111ML05Zí..INS2017-12-21-20.21.07.846497
....<4411111111ML04Zà..INS2017-12-21-20.21.07.844705
.....3311111111ML03Z...INS2017-12-21-20.21.07.843404
.....2211111111ML02Z...INS2017-12-21-20.21.07.697698

This is the same order as in input. But in my output I am getting the last key record.
I am wondering which control statements got you this result. I ran a test with sort ascending (though sorting is not needed to achieve what you want) and it gave your expected results.

Nic/RahulG31 has pointed out possible solutions here, and if you choose to go with an ICETOOL SELECT, make sure you use a COPY override, so you won't end up in re-sorting your data.
Code:
//TOOLIN   DD *                                       
 SELECT FROM(IN) TO(OUT) ON(1,23,CH) FIRST USING(CTL1)
//CTL1CNTL DD *                                       
 OPTION COPY         
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
Search our Forums:

Back to Top