Page 1 of 1

WS-VAR3 output as AB12CD3

PostPosted: Tue Dec 11, 2012 3:54 pm
by raghuvanshi
Hi,

In interview today one question was asked if
WS-VAR1 is ABCDE and
WS-VAR2 is 123
How will you get output as below-:

WS-VAR3 AB12CD3
My answer was

MOVE WS-VAR1(1:2) TO WS-VAR3
MOVE WS-VAR2(1:2) TO WS-VAR3
MOVE WS-VAR2(3:2) TO WS-VAR3
MOVE WS-VAR2(3:1) TO WS-VAR3

I know this is wrong and it was stupid of me to think that output will be AB12CD3 but I am looking for the correct answer, any suggestions are welcome!

Re: WS-VAR3 output as AB12CD3

PostPosted: Tue Dec 11, 2012 4:44 pm
by BillyBoyo
Your output will be "3" in the left-most byte and the rest "padded" with space.

To get what you want with reference-modification, you also need to use reference-modification on the receiving field, otherwise each MOVE is going to overwrite the same data.

You don't need reference-modification. You can just do it with data-definitions.

Re: WS-VAR3 output as AB12CD3

PostPosted: Tue Apr 23, 2013 4:23 pm
by sinmani
1 You can use reference variable in the receiving field as well.

2. Another way is to redefine the first variables and move the corresponding redefined parts.