01 ws-data1 pic x(12) value "satish kumar'
01 ws-data2 pic x(5)
How can u move only "kumar" to ws-data2
Question asked by visitor satish kumar
01 ws-data1 pic x(12) value "satish kumar'
01 ws-data2 pic x(5)
How can u move only "kumar" to ws-data2
Question asked by visitor satish kumar
Hi,
this can be done in many ways:
(1)Declare another variable as:
->01 ws-data-group
03 ws-filler pic x(07).
03 ws-data2 pic x(05).
->move ws-data1 to ws-data-group.
your required value will be in ws-data.
(2)The second logic uses a counter which will search for a space after satish and move the remaining to data2.
->declare:
01 count pic 9(02).
01 remain pic 9(02) value 0.
->perform varying count from 1 by 1 until ws-data1(count) equal space.
->subtract count from length of ws-data1 giving remain.
->add 1 to count.
->move ws-data1(count:remain) to ws-data2
Hope this helps......
Also, if you are coding the program and you want to always MOVE the last five characters of WS-DATA1 to WS-DATA2, you'd simply do:
MOVE WS-DATA1 (8:5) TO WS-DATA2.
[True.............