Page 1 of 2

How to remove trailing Spaces in Syncsort?

PostPosted: Mon Mar 05, 2012 4:28 pm
by pjagathis
Hi all,

Could you please tell me the syntax to remove the trailing spaces in Sync sort?

Input:
----+----1----+---
******************
A00 DFR   | |  |A|
A0  FR    | |  |A|



Expected Output:

----+----1----+
***************
A00 DFR| |  |A|
A0  FR| |  |A|


Just want to remove the trailing spaces in first field alone and should not remove the spaces in between the field1?

Thanks in advance..

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Mon Mar 05, 2012 4:47 pm
by BillyBoyo
Have a look at PARSE. Is the first sub-field (A00/A0) a fixed length? If not, can it be entirely blanks? Is the second sub-field a fixed length?

You'll need one, two or three parsed fields, with one requiring an appropriate SQZ.

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Mon Mar 05, 2012 4:59 pm
by pjagathis
Hi BillyBoyo,

I want to remove the trailing spaces in first field alone and it is fixed length.But i want to keep the 2 and 3 field as it is.

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Mon Mar 05, 2012 5:14 pm
by BillyBoyo
Get you manual. Look up SQZ in the index.

You want to aim for something like BUILD=(squeezed-field,11,length-to-end-of-record) .

If you are unclear in the manual, search here for some examples, try them out, and understand how it is working. Go back and understand the manual. Apply the results to your code.

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Mon Mar 05, 2012 5:49 pm
by bodatrinadh
Jagathis,

Hope this will work for you!

                                                   
//STEP1    EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SYSPRINT DD SYSOUT=*                                 
//SORTIN DD *                                           
A00 DFR   | |  |A|                                     
A0  FR    | |  |A|                                     
//SORTOUT DD SYSOUT=*                                   
//SYSIN  DD *                                           
  SORT FIELDS=COPY                                     
  INREC FINDREP=(IN=C' ',OUT=C'',STARTPOS=5,ENDPOS=11) 


Output :-

A00 DFR| |  |A| 
A0  FR| |  |A| 
 


Thanks
-3nadh

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Mon Mar 05, 2012 7:29 pm
by BillyBoyo
Nice solution, -3nadh. No confirmation of fixed start position, but it matches the data :-)

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Tue Mar 06, 2012 10:21 am
by pjagathis
Hi -3nadh,

Thanks for your post and help.

My data include single word also.. then it won't work..

Input
W 6 5 4   |Z|111|
W9        |Z|111|
W96653400 |Z|111|
W966 34000|Z|111|
W9665 44  |Z|111|


Expected output:

----+----1----+----2----+
*************************
W 6 5 4|Z|111|           
W9|Z|111|               
W96653400|Z|111|         
W966 34000|Z|111|       
W9665 44|Z|111|         


Thanks in advance..!

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Tue Mar 06, 2012 12:50 pm
by bodatrinadh
try this snippet. this may give you the perfect solution.

//STEP1    EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SYSPRINT DD SYSOUT=*                                     
//SORTIN DD *                                             
W         |Z|111|                                         
W 6 5 4   |Z|111|                                         
W9        |Z|111|                                         
W96653400 |Z|111|                                         
W966 34000|Z|111|                                         
W9665 44  |Z|111|                                         
//SORTOUT DD SYSOUT=*                                     
//SYSIN  DD *                                             
 SORT FIELDS=COPY                                                   
 OUTREC IFTHEN=(WHEN=(2,9,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=2,ENDPOS=10)),                             
        IFTHEN=(WHEN=(3,8,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=3,ENDPOS=10)),                             
        IFTHEN=(WHEN=(4,7,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=4,ENDPOS=10)),                             
        IFTHEN=(WHEN=(5,6,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=5,ENDPOS=10)),                             
        IFTHEN=(WHEN=(6,5,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=6,ENDPOS=10)),                             
        IFTHEN=(WHEN=(7,4,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=7,ENDPOS=10)),                             
        IFTHEN=(WHEN=(8,3,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=8,ENDPOS=10)),                             
        IFTHEN=(WHEN=(9,2,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',     
                STARTPOS=9,ENDPOS=10)),                             
        IFTHEN=(WHEN=(10,1,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',   
                STARTPOS=10,ENDPOS=10))         


Thanks
-3nadh

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Tue Mar 06, 2012 8:39 pm
by pjagathis
Hi -3nadh,

Thanks for your help..!

If my field is less than 10 or 20 bytes, the above code will work but if my field is greater than 30 bytes, then coding lines may increase.I will use the above logic for my need now. But if the field length is high, then how can we proceed?

Please advice..!

Re: How to remove trailing Spaces in Syncsort?

PostPosted: Tue Mar 06, 2012 9:30 pm
by mfrookie
See if this satisfies your requirement. I assumed that your input file is FB and 80 bytes long. Your 1st field can be max of 11 bytes, 2nd field can be max of 2 bytes, 3rd field can be max of 4 bytes (including the delimiter '|').

//REFMDATA EXEC PGM=SYNCTOOL,COND=(0,NE)                               
//INPUTFIL DD   *                                                       
W 6 5 4   |Z|111|                                                       
W9        |Z|111|                                                       
W96653400 |Z|111|                                                       
W966 34000|Z|111|                                                       
W9665 44  |Z|111|                                                       
/*                                                                     
//OUTPUTFI DD   SYSOUT=*                                               
//TOOLIN   DD   *                                                       
  COPY FROM(INPUTFIL) USING(REFM)                                       
/*                                                                     
//REFMCNTL DD   *                                                       
  INREC IFTHEN=(WHEN=INIT,                                             
           PARSE=(%00=(ENDAT=C'|',FIXLEN=11),                           
                  %01=(ENDAT=C'|',FIXLEN=02),                           
                  %02=(ENDAT=C'|',FIXLEN=04),                           
                  %03=(FIXLEN=63)),                                     
           BUILD=(%00,                                                 
                  %01,                                                 
                  %02,                                                 
                  %03)),                                               
        IFTHEN=(WHEN=INIT,                                             
           BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C' '))),                     
        IFTHEN=(WHEN=INIT,                                             
                   FINDREP=(IN=C' |',OUT=C'|'))                         
  OUTFIL FNAMES=OUTPUTFI                                               
/*                                                                     
//TOOLMSG  DD   SYSOUT=*                                               
//DFSMSG   DD   SYSOUT=*                                               


The output is
---+----1----+----2----+----3----
*********************************
W 6 5 4|Z|111|                   
W9|Z|111|                       
W96653400|Z|111|                 
W966 34000|Z|111|               
W9665 44|Z|111|                 
********************************