Reference modification for the receiving field?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Previous topicNext topic

Topic Author
BobP
Registered Member
Posts: 27
Joined: Mon Jun 17, 2013 1:33 pm
Zodiac: Sagittarius

Reference modification for the receiving field?

Post by BobP » Wed Nov 08, 2017 10:12 am

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). 
?


Thanks,

User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1331
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: Reference modification for the receiving field?

Post by Robert Sample » Wed Nov 08, 2017 6:40 pm

What did the Enterprise COBOL Language Reference manual tell you when you searched it for reference modification?




nicc
Global Moderator
Global Moderator
Posts: 580
Joined: Wed Apr 23, 2014 8:45 pm

Re: Reference modification for the receiving field?

Post by nicc » Wed Nov 08, 2017 7:04 pm

What happened when you simply tried it?


Regards
Nic

User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1331
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: Reference modification for the receiving field?

Post by Robert Sample » Wed Nov 08, 2017 7:44 pm

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.



Previous topicNext topic

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”