Posted: Tue Jul 17, 2018 9:41 am Post subject: DFSORT Parse aginst strings that may not exist
Hi, I am trying to parse a file and build and outrec where the parse filed may or may not exist in the input record. Is it possible for the parse statement to recognise the string isn't present and fill the parse %var with nulls?
Example:
the parse statement %88 may or may not exist in the record and, if it isn't there, it seems to corrupt the output.
Any thoughts please? _________________ Peter Warren
Posted: Wed Jul 18, 2018 2:41 am Post subject: syntax error
Many thanks, though if I use this it gives me a syntax error :
Code:
ICE000I 1 - CONTROL STATEMENTS FOR 5650-ZOS, Z/OS DFSORT V2R1 - 08:00 ON WED JU
OPTION VLSCMP
INCLUDE COND=((1,300,SS,EQ,C'{1:F01ULSBGB2B',
AND,1,300,SS,EQ,C'{2:O101'))
OUTREC PARSE=(%00=(STARTAT=C'{2:',ENDAT=C';',FIXLEN=300),
%01=(STARTAT=C'{3:',ENDAT=C';{4:;',FIXLEN=300),
%88=(STARTAT=C'{4:',ENDAT=C';'),
£
ICE243A F PARSED FIELD DEFINITION ERROR
%02=(STARTAT=C':20:',ENDAT=C';',FIXLEN=300),
£
ICE007A 1 SYNTAX ERROR
%03=(STARTAT=C':28:',ENDAT=C';',FIXLEN=300),
£
ICE007A 1 SYNTAX ERROR
%04=(STARTAT=C':21:',ENDAT=C';',FIXLEN=300),
£
ICE007A 1 SYNTAX ERROR
But the major problem is that if a parsed field doesn't exist in the input then all output is dropped from the field onwards.
for example if I have a file containing a record with
Code:
"{2:blah;", ":20:blah;",":21:blah"
then all output is topped @ :20: because the next parse field :28: doesn't exist so no parse statements after the %03 are processed.
Is this the way parsing works? It will only parse up to statements that match and then ignores others after the first non-match?
Thanks _________________ Peter Warren
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
Posted: Wed Jul 18, 2018 5:53 am Post subject:
We cannot tell what is wrong as you have not used the code tags. The code tags preserve leading blanks and strings of blanks. These are stripped by HTML if you do not use the code tags.
Also, it would be a good idea to show sample records - one with all fields and one without the optional field. Show the expected results for each. Use the code tags again. _________________ Utility and Program control cards are NOT, repeat NOT, JCL.
As NIC pointed out, without the code tags it is kinda of hard to see where the error. My initial post showed as to how to add code tags. Please follow the rules from next time on wards.
peterwarren wrote:
Many thanks, though if I use this it gives me a syntax error :
peterwarren,
My mistake. The ignore field is just % without any number. So it should be
Code:
%=(STARTAT=C'{4:',ENDAT=C';'),
peterwarren wrote:
But the major problem is that if a parsed field doesn't exist in the input then all output is dropped from the field onwards.
for example if I have a file containing a record with
Code:
"{2:blah;", ":20:blah;",":21:blah"
then all output is topped @ :20: because the next parse field :28: doesn't exist so no parse statements after the %03 are processed.
Is this the way parsing works? It will only parse up to statements that match and then ignores others after the first non-match?
Thanks
Well if you read the documentation of parse you would have seen this
DFSORT Application Programming Guide wrote:
if STARTAFT=string or STARTAT=string is specified, the search for string starts at the Start Pointer. If string is found, the Start Pointer is set to the byte after the end of the string. If string is not found, the current parsed field and any subsequent parsed fields contain all blanks.
If you can send in your sample input file and desired output then may be we can suggest an alternative way using multiple IFTHEN WHEN=INIT statements. _________________ Kolusu
www.linkedin.com/in/kolusu
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