Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Default parsed fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Default parsed fields
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    Post subject:
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    Post subject:
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    Post subject: Different solution
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 Moderator


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

PostPosted: Wed Sep 29, 2010 1:34 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us