Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Preserve order in Input File

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

New User


Joined: 14 Jun 2012
Posts: 94
Location: India

PostPosted: Thu Dec 21, 2017 4:20 pm    Post subject: Preserve order in Input File
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

Senior Member


Joined: 14 Mar 2007
Posts: 10535
Location: italy

PostPosted: Thu Dec 21, 2017 4:36 pm    Post subject:
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: 94
Location: India

PostPosted: Thu Dec 21, 2017 4:44 pm    Post subject:
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

Senior Member


Joined: 14 Mar 2007
Posts: 10535
Location: italy

PostPosted: Thu Dec 21, 2017 4:47 pm    Post subject: Reply to: Preserve order in Input File
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: 94
Location: India

PostPosted: Thu Dec 21, 2017 4:49 pm    Post subject:
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

Senior Member


Joined: 14 Mar 2007
Posts: 10535
Location: italy

PostPosted: Thu Dec 21, 2017 7:33 pm    Post subject:
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: 94
Location: India

PostPosted: Thu Dec 21, 2017 7:48 pm    Post subject:
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: 2110
Location: UK

PostPosted: Thu Dec 21, 2017 8:00 pm    Post subject:
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: 445
Location: USA

PostPosted: Thu Dec 21, 2017 11:12 pm    Post subject: Reply to: Preserve order in Input File
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

Active User


Joined: 29 Apr 2008
Posts: 379
Location: Maryland

PostPosted: Fri Dec 22, 2017 1:07 am    Post subject: Re: Preserve order in Input File
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: 94
Location: India

PostPosted: Fri Dec 22, 2017 9:52 am    Post subject:
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: 714
Location: Pennsylvania

PostPosted: Fri Dec 22, 2017 5:49 pm    Post subject:
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: 2110
Location: UK

PostPosted: Fri Dec 22, 2017 6:30 pm    Post subject:
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: 2429
Location: @my desk

PostPosted: Fri Dec 22, 2017 8:20 pm    Post subject:
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    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 COBOL file declaration jithinraghavan COBOL Programming 2 Fri Nov 16, 2018 10:54 pm
No new posts Will this code extract 1 byte from fi... pkmurali CLIST & REXX 8 Sat Nov 10, 2018 11:13 pm
No new posts Error reading file in REXX module ashek15 CLIST & REXX 3 Wed Oct 24, 2018 4:50 am
No new posts Convert VB file to FB plus special fo... cz016m SYNCSORT 15 Fri Oct 19, 2018 7:26 pm
No new posts Picking up the latest PS file pema_yozer JCL & VSAM 8 Thu Oct 11, 2018 12:26 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us