Following code can be used to reverse the string after removing trailing spaces. MOVE FUNCTION LENGTH(WS-ORG-STRG) TO WS-COUNT. DISPLAY WS-COUNT. PERFORM VARYING WS-SUB FROM WS-COUNT BY -1 UNTIL WS-SUB = 0 IF WS-ORG-STRG(WS-SUB:) = ' ' CONTINUE ELSE MOVE FUNCTION REVERSE (WS-ORG-STRG(1:WS-SUB)) TO WS-REVRS DISPLAY WS-REVRS MOVE 1 TO WS-SUB END-IF END-PERFORM.
Following code can be used to reverse the string after removing trailing spaces.
MOVE FUNCTION LENGTH(WS-ORG-STRG) TO WS-COUNT.
DISPLAY WS-COUNT.
PERFORM VARYING WS-SUB FROM WS-COUNT BY -1 UNTIL WS-SUB = 0
IF WS-ORG-STRG(WS-SUB:) = ' '
CONTINUE
ELSE
MOVE FUNCTION REVERSE (WS-ORG-STRG(1:WS-SUB)) TO WS-REVRS
DISPLAY WS-REVRS
MOVE 1 TO WS-SUB
END-IF
END-PERFORM.
Could you please give the code to reverse the words in a string.
I Like cobol--> cobol like i