340 pts.
 Remove Trailing & Leading Spaces in COBOL/400
Hi Group, How do we remove Trailing & leading spaces from a field in cobol/400? Please explain with an example Thanks & Regards, M

Software/Hardware used:
ASKED: February 13, 2013  1:59 PM
UPDATED: February 13, 2013  2:01 PM

Answer Wiki:

V5R4M0 or higher use Function TRIML, TRIMR or even TRIM.

MOVE FUNCTION TRIM(STREET-ADDRESS," ") TO STREET-ADDRESS-OUT.

Prior to V5R4 you will have to use the basic INSPECT statement. 

Last Wiki Answer Submitted:  February 13, 2013  3:59 pm  by  RossHowatson   195 pts.
All Answer Wiki Contributors:  RossHowatson   195 pts. , mvrkrishna   340 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

But note that the ‘Answer’ does not result in trailing spaces being removed from STREET-ADDRESS-OUT unless STREET-ADDRESS-OUT is less than or equal to the length of the trimmed value. The value of FUNCTION TRIM(STREET-ADDRESS,” “) is trimmed. Once that value is MOVEd into a field, blanks will be added at the end to fill the result. — Tom

 107,735 pts.