IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

MOVE statement


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Dec 02, 2010 12:20 pm
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
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: 202
Location: Toronto, ON, Canada

PostPosted: Tue Dec 07, 2010 1:44 am
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Dec 07, 2010 2:11 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts How to move DB2 Installation HLQ DB2 4
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
Search our Forums:

Back to Top