Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort for a csv File

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

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 9:56 pm    Post subject: Sort for a csv File
Reply with quote

Hi .. I have a VB file having comma separated values. I have to write three fields from each record. Could you please help me with the sort card?

I will give you a example:

I/p File

07Dec2011,0B00NY175,G92450SD1,UKIN,Utd Kdom Gt Britn & Nthn Irlnd,GBP,SNRFOR,07Dec2038,,4.75
07Dec2011,IT000493,,ITALY,Rep Italy,EUR,SNRFOR,01Feb2018,,4.5,6M,Fixed,IBoxx,Xtrakter,Quotes
07Dec2011,IT00493,,ITALY,Rep Italy,EUR,SNRFOR,01Feb2018,,4.5,6M,Fixed,IBoxx,Xtrakter,Quotes

0/p File :
0B00NY175 UKIN
IT000493 ITALY
IT00493 ITALY

This is just an example but for my requirement there are so many field before the required field.
Is it possible that we can count commas in the record and then write after the count of commas
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Dec 09, 2011 10:02 pm    Post subject: Reply to: Sort for a csv File
Reply with quote

How many is "so many"? Is it more than 100? PARSE can handle 100 fields at a time.

You mention three fields, but your required output only shows two.

If you can get us some more detailed information...
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:08 pm    Post subject: Re: Reply to: Sort for a csv File
Reply with quote

Bill Woodger wrote:
How many is "so many"? Is it more than 100? PARSE can handle 100 fields at a time.

You mention three fields, but your required output only shows two.

If you can get us some more detailed information...


Thanks Bill for the quick reply....
Yes my o/p will only contain two fields

I have around 24 fields in front of the required field , I have used ENDBEFR for such kind of requirement earlier
OUTREC PARSE=(%01=(ENDBEFR=C'¦',FIXLEN=12),
%02=(ENDBEFR=C'¦',FIXLEN=01),
%03=(ENDBEFR=C'¦',FIXLEN=02),
%04=(ENDBEFR=C'¦',FIXLEN=180),
%05=(ENDBEFR=C'¦',FIXLEN=30),
%06=(ENDBEFR=C'¦',FIXLEN=30),
%07=(ENDBEFR=C'¦',FIXLEN=30),
%08=(ENDBEFR=C'¦',FIXLEN=30),
%09=(ENDBEFR=C'¦',FIXLEN=30),
%10=(ENDBEFR=C'¦',FIXLEN=30),
%11=(ENDBEFR=C'¦',FIXLEN=30)),

but is it possible to achieve this by some other command or skipping few fields instead of extracting each
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Dec 09, 2011 10:09 pm    Post subject:
Reply with quote

kamiya jain,

You can use DFSORT PARSE function to scan upto 100 fields. You can ignore the ones you don't need. Since your input is a VB file your actual data starts from position 5. Use the following DFSORT JCL which will create a VB file with the fields 2 and 4.

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD DSN=Your input VB file,DISP=SHR       
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  SORT FIELDS=COPY

  INREC PARSE=(%=(ABSPOS=5,ENDBEFR=C','),           
               %01=(ENDBEFR=C',',FIXLEN=15),         
               %=(ENDBEFR=C','),                     
               %02=(ENDBEFR=C',',FIXLEN=10)),       
        BUILD=(1,4,%01,%02)                         

//*
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:22 pm    Post subject:
Reply with quote

Thanks Skolusu ,

I have around 24 field in front of my one of the required field then I have to skip around 25 field after that I have a required field.

So I was thinking is it possible to sort that without using endbefr .
because the sort card will be very big in this case
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Dec 09, 2011 10:29 pm    Post subject:
Reply with quote

kamiya jain wrote:

So I was thinking is it possible to sort that without using endbefr .
because the sort card will be very big in this case


DFSORT is smart enough to process and ignore the fields when you parse with just %= .
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:37 pm    Post subject:
Reply with quote

Code:

  SORT FIELDS=COPY,SKIPREC=1                                     
  OUTREC PARSE=(%=ABSPOS=5,ENDBEFR=C','),                         
              %=(ENDBEFR=C','),                                 
              %01=(ENDBEFR=C',',FIXLEN=12),                     
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
  %=(ENDBEFR=C','),                         
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %02=(ENDBEFR=C',',FIXLEN=18),           
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %03=(ENDBEFR=C',',FIXLEN=18)),     
  BUILD=(1:%01,14:%02,45:%52)             


I tried this sort card but it is not working icon_sad.gif
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:44 pm    Post subject:
Reply with quote

Its working ... but is it possible to make o/p file as FB file . Please reply
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Dec 09, 2011 11:05 pm    Post subject:
Reply with quote

kamiya jain,

The reason your sort card did not work is you trying to overlay the RDW of the VB file. You canNOT overlay the contents of RDW. If you want an FB file then add the following statement. The 3 fields you interested are (12+18+18 =48 bytes)

Code:

  OUTFIL VTOF,BUILD=(5,48)


PS: Don't Quote the whole post.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Dec 09, 2011 11:06 pm    Post subject: Re: Sort for a csv File
Reply with quote

Yes, it is possible.

Are you going with fixed positions/lengths for your output? Also are the chunks of record beyond the field length deliberate? Your output example from your first post wasn't clear on this.

If you can give your start positions and lengths, it'll help.
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 11:32 pm    Post subject: Re: Sort for a csv File
Reply with quote

Bill ,

Yes I have fixed positions/lengths for o/p.
There are around 52 field in a record and I require 2nd ,26th and 52nd field of the csv file.

I have tried using endbefr field but the sort card is too lengthy and I need a o/p file to be FB rather then VB.

I hope I am able to put my exact requirement
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Dec 09, 2011 11:39 pm    Post subject: Reply to: Sort for a csv File
Reply with quote

What do you mean by the sort card being too lengthy? It'll be as long as it needs to be, and needn't be longer. If that is in some way too long, then you'll have to look for another solution, maybe write a program.

Making the output dataset FB is not a problem.

I asked about the start positions and lengths of your output fields, as in what they are, rather than do you have them as a yes/no answer. You currently have "gaps" from the latest you have shown. Do you want those as well?
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 11:59 pm    Post subject: Re: Reply to: Sort for a csv File
Reply with quote

I means to say that sort card was too big...but I am coding that way only.
I used the above posted sort card and it worked fine..
Thank You so much for the help... icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Sat Dec 10, 2011 12:24 am    Post subject: Re: Reply to: Sort for a csv File
Reply with quote

kamiya jain wrote:
I means to say that sort card was too big...but I am coding that way only.
I used the above posted sort card and it worked fine..
Thank You so much for the help... icon_smile.gif


Thanks for the feedback. Glad it's working.

The last line is for Kolusu, I've checked, I didn't post a line of code, and I still don't understand the "too big"/long thing, but there we go. :-)
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us