MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DFSORT Parse aginst strings that may not exist

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
peterwarren
Beginner


Joined: 12 Jul 2018
Posts: 2
Topics: 2

PostPosted: Tue Jul 17, 2018 9:41 am    Post subject: DFSORT Parse aginst strings that may not exist Reply with quote

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:
Code:

//SORTOUT  DD  DSN=&OFL,DISP=(,CATLG,DELETE),UNIT=DASD,SPACE=(TRK,(
//             150),RLSE),RECFM=VB,LRECL=27185                     
//SYSIN    DD  *                                                   
 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';',FIXLEN=300),             
          %02=(STARTAT=C':20:',ENDAT=C';',FIXLEN=300),             
          %03=(STARTAT=C':28:',ENDAT=C';',FIXLEN=300),             
          %04=(STARTAT=C':21:',ENDAT=C';',FIXLEN=300),             
          %05=(STARTAT=C':50:',ENDAT=C';',FIXLEN=300),             
          %06=(STARTAT=C':52:',ENDAT=C';',FIXLEN=300),             
          %07=(STARTAT=C':30:',ENDAT=C';',FIXLEN=300),             
          %08=(STARTAT=C':25:',ENDAT=C';',FIXLEN=300),             
          %09=(STARTAT=C':21:',ENDAT=C';',FIXLEN=300),             
          %10=(STARTAT=C':23:',ENDAT=C';',FIXLEN=300),             
          %11=(STARTAT=C':32:',ENDAT=C';',FIXLEN=300),             
          %12=(STARTAT=C':50:',ENDAT=C';',FIXLEN=300),             
          %13=(STARTAT=C':56:',ENDAT=C';',FIXLEN=300),             
          %14=(STARTAT=C':57:',ENDAT=C';',FIXLEN=300),             
          %15=(STARTAT=C':59:',ENDAT=C';',FIXLEN=300),             
          %16=(STARTAT=C':70:',ENDAT=C';',FIXLEN=300),             
          %17=(STARTAT=C':77:',ENDAT=C';',FIXLEN=300),             
          %18=(STARTAT=C':71:',ENDAT=C';',FIXLEN=300)),           
 BUILD=(1,4,%00,%02,%03,%04,%05,%06,%07,%08,%09,%10,%11,%12,%13,   
            %14,%15,%16,%17,%18)                                   
  SORT    FIELDS=COPY                                             
/*

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
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 17, 2018 10:44 am    Post subject: Reply with quote

peterwarren wrote:
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?


peterwarren,

You are only parsing the %88 field but it is NOT used in the BUILD statement, so there is no chance of corrupting the final output.

Do you need that field? if you don't need it in the final output then you can replace that with
Code:

%88=(STARTAT=C'{4:',ENDAT=C';'),


PS: I added the code tags for your posts. Check this link which explains in detail about using code tags

https://www.mvsforums.com/helpboards/viewtopic.php?p=19031#19031
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
peterwarren
Beginner


Joined: 12 Jul 2018
Posts: 2
Topics: 2

PostPosted: Wed Jul 18, 2018 2:41 am    Post subject: syntax error Reply with quote

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
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Jul 18, 2018 5:53 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 18, 2018 12:17 pm    Post subject: Re: syntax error Reply with quote

peterwarren,

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group