View previous topic :: View next topic |
Author |
Message |
sub Beginner
Joined: 30 Jan 2007 Posts: 20 Topics: 12
|
Posted: Thu Jul 08, 2010 3:19 pm Post subject: Extract values from delimited file |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Jul 08, 2010 3:32 pm Post subject: |
|
|
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
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
sub Beginner
Joined: 30 Jan 2007 Posts: 20 Topics: 12
|
Posted: Tue Jul 13, 2010 10:22 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Jul 13, 2010 12:07 pm Post subject: |
|
|
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 |
|
 |
|
|