SQZ=(SHIFT=LEFT) with IFTHEN

Author Message
karthik_sripal

New User

Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

Posted: Tue Jul 09, 2013 12:32 am

Hi all,

I have a input record to be squeezed but if there is any spaces as the only value in the field - I would like to retain only one space.

Input record
 Code: "AA  ","BBBBB    ","CCC'CCCC      ","DDD D","    "

My current sort cord
 Code: OPTION COPY                        INREC BUILD=(1,80,SQZ=(SHIFT=LEFT))

My current output
 Code: "AA","BBBBB","CCC'CCCC","DDDD",""

Whereas my expected output is

 Code: "AA","BBBBB","CCC'CCCC","DDDD"," "

Please note the space in the last field.

Thank you very much!
karthik_sripal

New User

Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

Posted: Tue Jul 09, 2013 12:43 am

Kind of arrived at the solutions

But is there any other intresting solution - I would like to know !

 Code: OPTION COPY                              INREC BUILD=(1,80,SQZ=(SHIFT=LEFT))      OUTREC FINDREP=(IN=C',""',OUT=C'," "')
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

Posted: Tue Jul 09, 2013 12:54 am

I hink you're about there. You don't need both INREC and OUTREC. I assume you want the embedded blank to disappear from "DDD D"? The inclusion of the "," in your test isn't strictly needed (you shouldn't have another way to get "" together) and it would mean your code would not work if the first "column" of your CSV were "blank".

 Code: OPTION COPY                              INREC IFTHEN=(WHEN=INIT,BUILD=(1,80,SQZ=(SHIFT=LEFT))),            IFTHEN=(WHEN=INIT,FINDREP=(IN=C'""',OUT=C'" "'))
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics IFTHEN : Is there a better way? DFSORT/ICETOOL 7 Outrec IFTHEN builds data in wrong po... DFSORT/ICETOOL 6 IFTHEN HIT=NEXT BUILR should create m... DFSORT/ICETOOL 5 DO we have alternate syntax for IFTHEN? Compuware & Other Tools 8 INREC IFTHEN question SYNCSORT 2
Search our Forums: