Page 1 of 1

Using PARSE on VB Files

PostPosted: Mon Sep 12, 2011 9:12 pm
by Andyf
I'm struggling to get PARSE to work on a VB File.
What I want to achieve is the following
a) Extract records from the VB File (Record format . . . : VB Record length . . . : 204) of the following format, only extract those records where chars from position 16 for length 5 are 10POL (as below)
"0000002","10POL","","0000000085","AV01","ORDM","NOCMGMP","AC",
"0000072","10POL","PZ54128690","0000000011","AV01","MRLY","NOCMGMP","AC",
"0000073","10POL","PZ54148961","0000000012","AV01","MRLY","NOCMGMP","AC",
"0000150","10POL","","0000000090","AV01","ORDM","NOCMGMP","AC",
b) Create an output file whereby the only content is that of the fourth comma delimited field
I was trying to use PARSE along with OUTFIL or OUTREC to define the layout to DFSORT but kept getting error messages

SORT FIELDS=COPY
INCLUDE COND=(16,5,CH,EQ,C'10POL')
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=9),
%02=(ENDBEFR=C',',FIXLEN=7),
%03=(ENDBEFR=C',',FIXLEN=12),
%04=(ENDBEFR=C',',FIXLEN=13)),
BUILD=(5:%04)
G RECORD TYPE IS V - DATA STARTS IN POSITION 5
2 INCONSISTENT *OUTREC IFTHEN 0 REFORMATTING FIELD FOUND
0 C5-K51706 C6-K51706 C7-K54602 C8-K51706 E7-K51706
3 END OF DFSORT

Re: Using PARSE on VB Files

PostPosted: Mon Sep 12, 2011 10:51 pm
by skolusu
Andyf ,

Since your input is a VB file , you need to account the RDW too. So your build statement should be as follows.
BUILD=(1,4,%04)


that will produce an VB file with an LRECL of 17 ( 4 bytes RDW + 13 bytes of parsed data)

If you want your output to be a FB then you need to use VTOF parm. Let me know if you are interested in that

Re: Using PARSE on VB Files

PostPosted: Mon Sep 12, 2011 11:40 pm
by Frank Yaeger
Andy,

BTW, since you aren't interested in the first 3 values, you can have PARSE "ignore" them like this:

   ...
   OUTREC PARSE=(%=(ENDBEFR=C','),
      %=(ENDBEFR=C','),
      %=(ENDBEFR=C','),
      %04=(ENDBEFR=C',',FIXLEN=13)),
      BUILD=(1,4,5:%04)

Re: Using PARSE on VB Files

PostPosted: Tue Sep 13, 2011 1:33 pm
by Andyf
Frank,

Thanks for an excellent reply.
I found your document DFSORT: Beyond Sorting, so I was able to use VTOF, although I used it as another sort step rather than putting all the instructions in a single sort step

Thanks
Andy

Re: Using PARSE on VB Files

PostPosted: Tue Sep 13, 2011 10:54 pm
by Frank Yaeger
so I was able to use VTOF, although I used it as another sort step rather than putting all the instructions in a single sort step


So I guess you must like using extra resources for no reason. :roll:

Re: Using PARSE on VB Files

PostPosted: Wed Sep 14, 2011 7:20 pm
by Andyf
We have plenty of power and I like to keep things simple for the next person