|
View previous topic :: View next topic
|
| Author |
Message |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
| 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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| 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 |
|
 |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
| 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  |
|
| Back to top |
|
 |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
| Its working ... but is it possible to make o/p file as FB file . Please reply |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
kamiya jain
New User

Joined: 18 Aug 2009 Posts: 7 Location: Mumbai
|
|
|
|
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...  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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...  |
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 |
|
 |
retrostrings
New User

Joined: 21 Jan 2021 Posts: 1 Location: Canada
|
|
|
|
Hi all,
Is there a way to use Parse and Build in SORT to include commas from the csv file? Using ENDBEFR = C'","' and fixed lengths copies data just before the comma. I have a requirement to split a csv file into two files. So fields 1 through 5 go on one file as it is while the remaining fields go on another file. I do not want to get rid of the commas or the enclosed double quotes. Appreciate any pointers please.
This is my first post, I'm sorry if I did not adhere to best practices related to posting but I'll be quick to adapt.
Thanks very much! |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| retrostrings wrote: |
Hi all,
Is there a way to use Parse and Build in SORT to include commas from the csv file? Using ENDBEFR = C'","' and fixed lengths copies data just before the comma. I have a requirement to split a csv file into two files. So fields 1 through 5 go on one file as it is while the remaining fields go on another file. I do not want to get rid of the commas or the enclosed double quotes. Appreciate any pointers please.
This is my first post, I'm sorry if I did not adhere to best practices related to posting but I'll be quick to adapt.
Thanks very much! |
Use ENDAT= instead of ENDBEFR= |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| retrostrings wrote: |
Hi all,
Is there a way to use Parse and Build in SORT to include commas from the csv file? Using ENDBEFR = C'","' and fixed lengths copies data just before the comma. I have a requirement to split a csv file into two files. So fields 1 through 5 go on one file as it is while the remaining fields go on another file. I do not want to get rid of the commas or the enclosed double quotes. Appreciate any pointers please.
This is my first post, I'm sorry if I did not adhere to best practices related to posting but I'll be quick to adapt.
Thanks very much! |
Welcome!
Next time , Please start a new post with your problem statement instead of tailgating any older posts as that's one of the rule and do search this forum before posting as it might have already been discussed before and you could use that solution. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|