My input string is 'WRITE IN COBOL LANGUAGE'.
Output should be in 'RITE N OBOL ANGUAGE'.
which is first character of every string from input to be removed and then to be captured into output string.
I tried to unstring the message into 4 delimited by spaces and then splitted into 4 strings with countin(length).Using reference modification,i moved each string from its second position to its length specified in COUNTIN.
Is there any other way to do it?
05 WS-STRING1 PIC X(20) VALUE 'WRITE IN COBOL LANGUAGE'.
UNSTRING WS-STRING1 DELIMITED BY SPACES INTO
WS-OUTPUT1 COUNT IN WS-COUNT1
WS-OUTPUT2 COUNT IN WS-COUNT2
WS-OUTPUT3 COUNT IN WS-COUNT3.
MOVE WS-OUTPUT1(2:WS-COUNT1) TO WS-FIN1
MOVE WS-OUTPUT2(2:WS-COUNT2) TO WS-FIN2
MOVE WS-OUTPUT3(2:WS-COUNT3) TO WS-FIN3
1.See if you can twist INSPECT the way you want.
2.If you are allowed to use SQLs then use scalar functions.
3. As suggested by Robert , Use Ref modifications. loop thru the whole string to skip first letter and when you encountered SPACE then set a flag and skip the first letter of the next word and unset that same flag and move remaining letters until you hot next SPACE and repeat this till end of the string.
4. If these are record from the data set then use DFSORT to create a new Data Set the way you want and then run Cobol Program. I would not prefer this when COBOL is simpler.