Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

MOVE statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Thu Dec 02, 2010 12:11 pm    Post subject: MOVE statement
Reply with quote

There is a scenario which I am facing currently as mentioned below.

01 XYZ PIC X(2000).
01 PQR PIC X(2001).

The PQR has some data and in the last byte of PQR there is character 'V' stored and then we issue move statement as below.

MOVE XYZ TO PQR

After this the 2001th byte of PQR which has character 'V' becomes space.

I checked many times in the code but could not figure out the reason.

As per my knowledge the last character should have been retained.

Can anybody justify this behaviour?
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Thu Dec 02, 2010 12:20 pm    Post subject: Reply to: MOVE statement
Reply with quote

but as per cobol knowledge ( and the <majority> of other languages )

char moving
from smaller to larger clears/fills the <excess> trailing <space> with blanks
from larger to smaller ( if allowed ) truncates the excess ( trailing side )

numeric moving
from smaller to larger clears/fills the <excess> leading <space> with zeroes
from larger to smaller ( if allowed ) truncates the excess (leading side )

that' s what is GENERALLY safe to assume

to retain <some> values in the destination use a <substringing> approach,
==>for cobol the reference modification
Back to top
View user's profile Send private message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Thu Dec 02, 2010 12:40 pm    Post subject:
Reply with quote

I tried with a sample program and found out that whatever you are saying is correct.

My wrong presumption led me to post this topic. So learning is, dont presume without verification !!

It is always better to be enlightened..... icon_wink.gif
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Tue Dec 07, 2010 1:44 am    Post subject:
Reply with quote

The below is from the COBOL Reference guide. This is under the heading "Alignment Rules" in the Data Division Overview chapter. It is refering to any kind of a data move.

Alphanumeric, alphanumeric-edited, alphabetic, DBCS
For these receiving items, the following rules apply:
1. The data is aligned at the leftmost character position, and (if necessary) truncated or padded with spaces at the right.
2. If the JUSTIFIED clause is specified for this receiving item, the above rule is modified as described in “JUSTIFIED clause”

COBOL will truncate or pad a field as needed.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Dec 07, 2010 2:11 am    Post subject: Reply to: MOVE statement
Reply with quote

In your example, because of the data-lengths, COBOL probably generates an Assembler MVCL or (worst case), calls a COBOL run-time routine. icon_eek.gif

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us