IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Default parsed fields


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Fri Sep 24, 2010 5:12 pm
Reply with quote

I am parsing a CSV file into a fixed length output. The input file contains a date field with is missing on some records and populated on others:

John Smith,a house,19/04/1980,xxx
john dow,a different house,,yyy

I want to default the date to 12/31/9999 if it is missing.

IFTHEN=WHEN does not seem appropriate because the date field is not at a fixed position.

Is it possible to do this in a single step?
Back to top
View user's profile Send private message
prahalad

New User


Joined: 14 Sep 2010
Posts: 18
Location: Pune

PostPosted: Fri Sep 24, 2010 7:58 pm
Reply with quote

You can try with the following SORT job. You can adjust the field position are per your requirement.

Code:

 INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),                     
              %02=(ENDBEFR=C',',FIXLEN=20),                     
              %03=(ENDBEFR=C',',FIXLEN=10),                     
              %04=(FIXLEN=5)),BUILD=(1:%01,11:%02,31:%03,41:%04)
 OPTION COPY                                                     
 OUTFIL IFTHEN=(WHEN=(31,10,CH,EQ,C'          '),               
                OVERLAY=(31:C'12/31/9999'))     


InputFile:
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
JOHN SMITH,A HOUSE,19/04/1980,XXX                                       
JOHN DOW,A DIFFERENT HOUSE,,YYY                                 


Output file:
Code:

----+----1----+----2----+----3----+----4----+
JOHN SMITHA HOUSE             19/04/1980XXX 
JOHN DOW  A DIFFERENT HOUSE   12/31/9999YYY 
Back to top
View user's profile Send private message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Mon Sep 27, 2010 4:22 pm
Reply with quote

Thanks that worked.

They key thing I missed was the ability to use INREC to parse the record first.
Back to top
View user's profile Send private message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Tue Sep 28, 2010 3:55 pm
Reply with quote

I found a better solution for the case when there are multiple fields to default.

IFTHEN is not good in this scenario because it can only handle one match per record and if there are multiple fields missing in the input you have to cover every possible combination with complicated IFTHEN statements.

After a quick ssearch through the manual I found the CHANGE statement which suits my purpose perfectly

Code:
OUTREC BUILD=(1,53,                                     
              54,2,                                     
              CHANGE=(2,C'  ',C'00'),                   
              NOMATCH=(54,2),                           
              56,3,                                     
              59,10,                                   
              CHANGE=(10,C'          ',C'12/31/9999'), 
              NOMATCH=(59,10))                         
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Sep 29, 2010 1:34 am
Reply with quote

Quote:
if there are multiple fields missing in the input you have to cover every possible combination with complicated IFTHEN statements.


Well, I'm not sure what you mean by that exactly, but I suspect you could use HIT=NEXT to avoid complicated IFTHEN statements. HIT=NEXT continues to the next IFTHEN clause even if the current one is satisfied, so it let's you deal with multiple unrelated fields using simple IFTHEN clauses.
Back to top
View user's profile Send private message
joeempson

New User


Joined: 21 Mar 2009
Posts: 11
Location: UK

PostPosted: Wed Sep 29, 2010 2:18 pm
Reply with quote

Thanks Frank, I didn't know about HIT=NEXT and yes it is an alternative solution to my problem.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Running a Job with the Default User ID JCL & VSAM 2
No new posts Change Default Scroll Setting TSO/ISPF 1
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Define default volume for DSN storage... JCL & VSAM 8
Search our Forums:

Back to Top