Page 1 of 1

Reference modification for the receiving field?

Posted: Wed Nov 08, 2017 10:12 am
by BobP
Hi

is it possible to use reference modification for a receiving field in a COBOL program? For example, can we use something like this:

Code: Select all

MOVE 'ABC123' to WS-VAR-A(3:3). 
?

Re: Reference modification for the receiving field?

Posted: Wed Nov 08, 2017 6:40 pm
by Robert Sample
What did the Enterprise COBOL Language Reference manual tell you when you searched it for reference modification?

Re: Reference modification for the receiving field?

Posted: Wed Nov 08, 2017 7:04 pm
by nicc
What happened when you simply tried it?

Re: Reference modification for the receiving field?

Posted: Wed Nov 08, 2017 7:44 pm
by Robert Sample
My second observation (after suggesting you look at the manual) is that your MOVE statement is incorrectly set up -- you are moving a 6-byte constant into a 3-byte receiving field.

My third observation is that it took 3 minutes for me to code, compile, and execute a test that shows reference modification on receiving variables is perfectly valid. It took 2 more minutes to change my test to match your post and find that the results matched my expectations -- the ABC got moved since you told COBOL the receiving field was only 3 bytes, and alphanumeric data is moved left-to-right. So rather than waiting 10 1/2 hours for responses on a forum, you could have tested it yourself in far less time.