rarvins
New User
Joined: 24 Jan 2007 Posts: 59 Location: Texas
|
|
|
|
Hi,
I have to parse a data file delimited by a special character.But there are certain situations in which the special character itself existx as a part of data.In such a scenario , my program abends.So I need a SORT or FILEAID step before my program, which will eliminate records having the special character as a part of data and put it in another file.
Example: Say I have pipe delimited data
Input file:
Code: |
Line1: data1 | data2 | data3 | data 4|
Line2: data1 | data2 | data3 | data 4|
Line3: data1 | da|ta2 | data3 | data 4|
Line4: data1 | data2 | da|ta3 | data 4|
Line5: da|ta1 | data2 | data3 | data 4|
Line6: data1 | data2 | data3 | data 4|
Line7: data1 | data2 | data3 | data 4|
|
I can find out the records having pipe based on the count of it in a line
So in my example lines 3,4 & 5 have more than 4 '|' symbols....So they have to eliminated.
So my output should be"
Code: |
Input file to my program:
Line1: data1 | data2 | data3 | data 4|
Line2: data1 | data2 | data3 | data 4|
Line6: data1 | data2 | data3 | data 4|
Line7: data1 | data2 | data3 | data 4|
|
Code: |
Discard file
Line3: data1 | da|ta2 | data3 | data 4|
Line4: data1 | data2 | da|ta3 | data 4|
Line5: da|ta1 | data2 | data3 | data 4|
|
Can somebody suggest me a solution.Need not be a Sort.Any other tool like Fileaid or something is also ok. |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARTSE function. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
Use [URL] BBCode for External Links
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
data1 | data2 | data3 | data 4|
data1 | data2 | data3 | data 4|
data1 | da|ta2 | data3 | data 4|
data1 | data2 | da|ta3 | data 4|
da|ta1 | data2 | data3 | data 4|
data1 | data2 | data3 | data 4|
data1 | data2 | data3 | data 4|
/*
//KEEP DD SYSOUT=*
//DISCARD DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%1=(STARTAT=C'|',FIXLEN=1),
%2=(STARTAT=C'|',FIXLEN=1),
%3=(STARTAT=C'|',FIXLEN=1),
%4=(STARTAT=C'|',FIXLEN=1),
%5=(STARTAT=C'|',FIXLEN=1)),
OVERLAY=(81:%1,%2,%3,%4,%5)
OUTFIL FNAMES=DISCARD,INCLUDE=(81,5,CH,EQ,C'|||||'),
BUILD=(1,80)
OUTFIL FNAMES=KEEP,SAVE,
BUILD=(1,80)
/*
|
|
|