MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract values from delimited file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sub
Beginner


Joined: 30 Jan 2007
Posts: 20
Topics: 12

PostPosted: Thu Jul 08, 2010 3:19 pm    Post subject: Extract values from delimited file Reply with quote

Hi,
I have a pipe delimited file with 10 fields in a variable file. When a field doesn't have any value, there is nothing populated.

For eg, the input file will look like this
ABC|sds|3432|||4||r|5||
A|343|rt|67|t|u|||||
abcd|45|45|dsf|tr|45|3|67|t|i|

If I want to extract only 3rd field to an output file from the above input file is there a way to do it using SORT?

Thanks,
Sub
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jul 08, 2010 3:32 pm    Post subject: Reply with quote

sub,

Use the following DFSORT JCL which will give you the desired results. I assumed that the 3rd field has a max length of 10 bytes. you can change it to whatever length you want

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=(%=(ENDBEFR=C'|'),             
               %=(ENDBEFR=C'|'),             
              %1=(ENDBEFR=C'|',FIXLEN=10)), 
  BUILD=(1,4,%1)                             
//*


The output from this job is

Code:

3432
RT   
45   

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sub
Beginner


Joined: 30 Jan 2007
Posts: 20
Topics: 12

PostPosted: Tue Jul 13, 2010 10:22 am    Post subject: Reply with quote

Kolusu,
Thanks, the solution you had mentioned worked. I was trying to expand this solution to convert more than 200 fields from a variable length file to a fixed length file. But learnt that there is a limitation on the parsed fields. The IBM manual says "You can assign up to 100 %nn parsed fields (%00-%99) to the variable fields you want to extract."

Is there a work around for using it to more than 200 fields?
Thanks,
Sub
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 13, 2010 12:07 pm    Post subject: Reply with quote

sub,

Well you can split the job into 2 steps and extract the first 100 fields in step1 and the next 100 in the next step.

Alternatively you can write a program to get the work done
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> 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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group