Page 1 of 1

Parse in a vb file

PostPosted: Wed May 17, 2017 12:22 pm
by krishnaraj6eee
Hi,

"Please correct me wherever i'm wrong"

I'm Trying to parse an variable record where my records are having "start" keyword or "end" keyword or both.
if my record is having "start" keyword i need the data only after that keyword.
if my record is having "end" keyword i need the data only before that keyword.
if my record is having both "start" and "end" keyword i need the data in between "start" and "end".
if there is none of the keyword is present i want to skip that record.


OPTION COPY
OUTREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(STARTAT=C'start',FIXLEN=80))),
IFTHEN=(WHEN=INIT,
PARSE=(%02=(ENDBEFR=c'end',FIXLEN=80)),
BUILD=(%01,%02))



This is what i tried but am getting all the records.. since i'm using option copy it is giving me all the records(?).. i don't know how to filter first then apply the parse.
edited to align the content to the correction made by the ts

Re: Parse in a vb file

PostPosted: Wed May 17, 2017 1:38 pm
by krishnaraj6eee
sorry
if my record is having "start" keyword i need the data only before that keyword.

it is
if my record is having "end" keyword i need the data only before that keyword.

Re: Parse in a vb file

PostPosted: Thu May 18, 2017 12:15 am
by Robert Sample
Use an INCLUDE for "start" and "end" to get rid of the records you don't want. I've done some looking at the PARSE options but haven't found any set of them that generates what you want.

Re: Parse in a vb file

PostPosted: Thu May 18, 2017 8:45 am
by krishnaraj6eee
Thanks Robert.
And i failed to mention that the position of the keywords may change in every record.. It is not fixed.. I need to mention the field position for using include right?

Re: Parse in a vb file

PostPosted: Thu May 18, 2017 9:47 pm
by Robert Sample
Not if you use SS:
 INCLUDE COND=(1,<record length>,SS,EQ,C'START',OR,  
               1,<record length>,SS,EQ,C'END')      
where you change <record length> to the appropriate value.

Re: Parse in a vb file

PostPosted: Fri May 19, 2017 6:28 pm
by Aki88
Hello,

Can you please show the representational input data and expected output for the conditions you've mentioned?

Thank you.