Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : programming pearls - The fastest algorithm can frequently be replaced by one that is almost as fast and much easier to understand.

Google
 
Web mainframegurukul.com

Welcome to the mainframegurukul forums.

You are currently viewing our mainframe forums as a guest which gives you limited access to view most discussions, articles. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support at admin@mainframegurukul.com


Sorting comma delimited file?

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities
  View previous topic :: View next topic  
Author Message
perumalnk
Member


Joined: 28 Feb 2008
Posts: 20
Location: Denver,USA

PostPosted: Tue Mar 11, 2008 3:12 am    Post subject: Sorting comma delimited file? Reply with quote

Hi,

I have a comma delimited file having 35 fields with each field value is separated by a comma.Depending upon the value of the field the position occupied by a particular field differs.For example,

Rec # 1 - 3,10.1.2.45,sxcd,34566........
Rec # 2 - 3,10.22.33.456,sxcd,34566..........

Here i need sort the second field and fourth field.Is there any way to accomplish this?

Thanks,
Perumal.N.K.
Back to top
View user's profile Send private message

Frank Yaeger
Moderator


Joined: 18 Feb 2006
Posts: 487
Location: San Jose, CA

PostPosted: Tue Mar 11, 2008 4:03 am    Post subject: Reply with quote

You can use DFSORT's PARSE function to do this. However, in order to sort correctly, you need to "normalize" the timestamp in your second field. For example, if you had:

4.12.20.452
11.3.18.32
4.12.5.3

it wouldn't sort correctly unless you treated it as:

04.12.20.452
11.03.18.320
04.12.05.300

The DFSORT job below will do what you want. It will extract the fields you want to sort on and normalize them for sorting. I used a better set of test data in SORTIN. I assumed your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.

Code:

 //S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
3,10.1.2.45,sxcd,34566,ABC,...
3,10.22.33.456,sxcd,34566,DEFG,...
50,10.2.33.4,sxcd,12345,HI,...
50,10.2.33.4,sxcd,12344,HI,...
500,5.02.3.42,sxcd,12346,HI,...
500,4.22.30.425,sxcd,12344,HI,...
500,4.22.30.425,sxcd,12343,HI,...
/*
//SORTOUT DD DSN=&&O1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  INREC PARSE=(%=(ENDBEFR=C','),
    %01=(ENDBEFR=C'.',FIXLEN=2),
    %02=(ENDBEFR=C'.',FIXLEN=2),
    %03=(ENDBEFR=C'.',FIXLEN=2),
    %04=(ENDBEFR=C',',FIXLEN=3),
    %=(ENDBEFR=C','),
    %05=(FIXLEN=5)),
  OVERLAY=(81:%01,83:%02,85:%03,87:%04,90:%05)
  SORT FIELDS=(81,2,UFF,A,83,2,UFF,A,85,2,UFF,A,
    87,3,UFF,A,90,5,ZD,A)
  OUTREC BUILD=(1,80)
/*


SORTOUT would have the following (if you check it carefully, you'll see that it's sorted correctly):

Code:

500,4.22.30.425,sxcd,12343,HI,...     
500,4.22.30.425,sxcd,12344,HI,...     
500,5.02.3.42,sxcd,12346,HI,...       
3,10.1.2.45,sxcd,34566,ABC,...       
50,10.2.33.4,sxcd,12344,HI,...       
50,10.2.33.4,sxcd,12345,HI,...       
3,10.22.33.456,sxcd,34566,DEFG,...   

_________________
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
perumalnk
Member


Joined: 28 Feb 2008
Posts: 20
Location: Denver,USA

PostPosted: Tue Mar 11, 2008 8:52 am    Post subject: Reply with quote

Hi Frank,

Thanks a lot for your reply and the detailed example !

I tried the solution in my application Mainframe machine.It looks like the function PARSE is not supported in my Mainframe machine.But this example gave me idea about using the DFSORT.Once again thanks a lot !

Is there anyother way driven by the number of occurance of commas in the record.Like to sort 12th field, by checking the occurance of comma for 11 times.

Thanks,
Perumal.N.K.
Back to top
View user's profile Send private message
Frank Yaeger
Moderator


Joined: 18 Feb 2006
Posts: 487
Location: San Jose, CA

PostPosted: Tue Mar 11, 2008 8:04 pm    Post subject: Reply with quote

Quote:
It looks like the function PARSE is not supported in my Mainframe machine


DFSORT's PARSE function has been available since April, 2006. Ask your System Programmer to install z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (it's free).
_________________
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
perumalnk
Member


Joined: 28 Feb 2008
Posts: 20
Location: Denver,USA

PostPosted: Tue Mar 11, 2008 9:11 pm    Post subject: Reply with quote

Hi Frank,

Thanks a lot !
I will discuss about this with my Tech support team.

Thanks,
Perumal.N.K.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Presence of mind......too good example !!! 3 Anuj Dhawan 1620 Thu Feb 04, 2010 5:26 am
basujanm2310 View latest post
No new posts In cics what is new copy.please give me a example. 2 mainframe5 4525 Fri Mar 06, 2009 1:13 pm
kapil agarwal View latest post
No new posts what is spanned records in vsam.please give me a example. 1 mainframe5 1447 Tue Nov 25, 2008 9:03 am
Anuj Dhawan View latest post
No new posts what is SPAM RECORDS IN VSAM please give me a example. 2 mainframe5 1664 Tue Nov 25, 2008 8:46 am
Anuj Dhawan View latest post
No new posts for debugging , i need to display variables in hexadecimal 6 danig 2433 Thu Apr 17, 2008 1:34 pm
danig View latest post
 



This widget requires Flash Player 9 or better








Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB