Remove trailing SPACES using SORT.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Remove trailing SPACES using SORT.

Post by BobThomas »

Hi,

From an input file I want to remove the trailing spaces after the value of the filed and before the commausing SORT. For example, please consider the data like this:

Code: Select all

11,A B C D ,abc  , 
12,xxyy zz ,xyz  some place   , 
13,xxyz ,xyz  other avenue , 
The output file should like this:

Code: Select all

11,A B C D ,abc, 
12,xxyy zz ,xyz  some place, 
13,xxyz ,xyz  other avenue, 
Could anyone please suggest a way of doing this?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Remove trailing SPACES using SORT.

Post by nicc »

Will it always be the same number of fields? Your example shows each record having 3 fields.
Regards
Nic
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: Remove trailing SPACES using SORT.

Post by BobThomas »

Thanks for the answer. Yes, it will always be same number of fields.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Remove trailing SPACES using SORT.

Post by William Collins »

Use FINDREP to change C' ,' to C''
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: Remove trailing SPACES using SORT.

Post by BobThomas »

But that removes the sapce for second field also, I want to remove teh sapce for third filed only.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Remove trailing SPACES using SORT.

Post by William Collins »

Sorry, missed that part as it only appeared with the data :-)

Two techniques. Use FINDREP with DO=2 to change comma to X'FD' (or any non-display value). Use FINDREP to change the spaces-and-comma (you'll need multiple, it looks like, as you don't have a fixed number of trailing spaces). This can be DO=1. Use FINDREP again to change the non-display value back to comma (DO=2).

Use JFY. SHIFT=RIGHT to maximum record-length. SHIFT=RIGHT to entire record except the "." which is in the right-most position. SHIFT=LEFT for the entire record.
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: Remove trailing SPACES using SORT.

Post by BobThomas »

Thank you.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”