Remove trailing SPACES using SORT.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Previous topicNext topic
User avatar

Topic Author
BobThomas
Registered Member
Posts: 72
Joined: Sat Jun 15, 2013 11:04 am
Zodiac: Sagittarius

Remove trailing SPACES using SORT.

Post by BobThomas » Sat Jan 07, 2017 6:54 pm

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: 597
Joined: Wed Apr 23, 2014 8:45 pm

Re: Remove trailing SPACES using SORT.

Post by nicc » Sat Jan 07, 2017 8:44 pm

Will it always be the same number of fields? Your example shows each record having 3 fields.


Regards
Nic

User avatar

Topic Author
BobThomas
Registered Member
Posts: 72
Joined: Sat Jun 15, 2013 11:04 am
Zodiac: Sagittarius

Re: Remove trailing SPACES using SORT.

Post by BobThomas » Tue Jan 10, 2017 11:40 am

Thanks for the answer. Yes, it will always be same number of fields.




William Collins
Global Moderator
Global Moderator
Posts: 499
Joined: Sun Aug 25, 2013 7:24 pm

Re: Remove trailing SPACES using SORT.

Post by William Collins » Wed Jan 11, 2017 11:14 pm

Use FINDREP to change C' ,' to C''



User avatar

Topic Author
BobThomas
Registered Member
Posts: 72
Joined: Sat Jun 15, 2013 11:04 am
Zodiac: Sagittarius

Re: Remove trailing SPACES using SORT.

Post by BobThomas » Thu Jan 12, 2017 2:21 pm

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: 499
Joined: Sun Aug 25, 2013 7:24 pm

Re: Remove trailing SPACES using SORT.

Post by William Collins » Sat Jan 14, 2017 1:35 pm

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

Topic Author
BobThomas
Registered Member
Posts: 72
Joined: Sat Jun 15, 2013 11:04 am
Zodiac: Sagittarius

Re: Remove trailing SPACES using SORT.

Post by BobThomas » Wed Jan 18, 2017 11:04 am

Thank you.



Previous topicNext topic

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