How to remove trailing Spaces in Syncsort?



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

How to remove trailing Spaces in Syncsort?

Postby pjagathis » Mon Mar 05, 2012 4:28 pm

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..
Thanks and Regards,
Jagathis P
pjagathis
 
Posts: 67
Joined: Wed May 04, 2011 5:04 pm
Location: Chennai
Has thanked: 0 time
Been thanked: 0 time

Re: How to remove trailing Spaces in Syncsort?

Postby BillyBoyo » Mon Mar 05, 2012 4:47 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to remove trailing Spaces in Syncsort?

Postby pjagathis » Mon Mar 05, 2012 4:59 pm

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.
Thanks and Regards,
Jagathis P
pjagathis
 
Posts: 67
Joined: Wed May 04, 2011 5:04 pm
Location: Chennai
Has thanked: 0 time
Been thanked: 0 time

Re: How to remove trailing Spaces in Syncsort?

Postby BillyBoyo » Mon Mar 05, 2012 5:14 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to remove trailing Spaces in Syncsort?

Postby bodatrinadh » Mon Mar 05, 2012 5:49 pm

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
Thanks
-3nadh
User avatar
bodatrinadh
 
Posts: 67
Joined: Thu Jan 12, 2012 9:05 pm
Has thanked: 0 time
Been thanked: 4 times

Re: How to remove trailing Spaces in Syncsort?

Postby BillyBoyo » Mon Mar 05, 2012 7:29 pm

Nice solution, -3nadh. No confirmation of fixed start position, but it matches the data :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to remove trailing Spaces in Syncsort?

Postby pjagathis » Tue Mar 06, 2012 10:21 am

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..!
Thanks and Regards,
Jagathis P
pjagathis
 
Posts: 67
Joined: Wed May 04, 2011 5:04 pm
Location: Chennai
Has thanked: 0 time
Been thanked: 0 time

Re: How to remove trailing Spaces in Syncsort?

Postby bodatrinadh » Tue Mar 06, 2012 12:50 pm

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
Thanks
-3nadh
User avatar
bodatrinadh
 
Posts: 67
Joined: Thu Jan 12, 2012 9:05 pm
Has thanked: 0 time
Been thanked: 4 times

Re: How to remove trailing Spaces in Syncsort?

Postby pjagathis » Tue Mar 06, 2012 8:39 pm

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..!
Thanks and Regards,
Jagathis P
pjagathis
 
Posts: 67
Joined: Wed May 04, 2011 5:04 pm
Location: Chennai
Has thanked: 0 time
Been thanked: 0 time

Re: How to remove trailing Spaces in Syncsort?

Postby mfrookie » Tue Mar 06, 2012 9:30 pm

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|                 
********************************
mfrookie
 
Posts: 40
Joined: Mon Apr 25, 2011 8:46 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post