WS-VAR3 output as AB12CD3

raghuvanshi
Posts: 43
Joined: Tue Dec 07, 2010 5:32 pm
Skillset: COBOL,JCL,DB2,VSAM,CA7
Referer: Google

WS-VAR3 output as AB12CD3

Postby raghuvanshi » Tue Dec 11, 2012 3:54 pm

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!

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

Re: WS-VAR3 output as AB12CD3

Postby BillyBoyo » Tue Dec 11, 2012 4:44 pm

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.

sinmani
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Skillset: COBOL
CICS
JCL
DB2
VSAM
IMS
Referer: INTERNET

Re: WS-VAR3 output as AB12CD3

Postby sinmani » Tue Apr 23, 2013 4:23 pm

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.
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well


  • Similar Topics
    Replies
    Views
    Last post