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
 

 

problem about MOVE statement

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

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 9:18 am    Post subject: problem about MOVE statement
Reply with quote

I have code below
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL1 PIC X(04)

MOVE WS-O-CTL1(1:2) TO WS-O-CTL1(3:2).
MOVE '00' TO WS-O-CTL1(1:2).
MOVE WS-O-CTL2(1:3) TO WS-O-CTL2(2:3).
MOVE '0' TO WS-O-CTL2(1:1).
MOVE WS-O-CTL3(1:3) TO WS-O-CTL3(2:3).
MOVE '0' TO WS-O-CTL3(1:1).
MOVE '0000' TO WS-O-CTL4.


before process this code,the value is
WS-O-CTL1 : 18
WS-O-CTL2 : 100
WS-O-CTL3 : 694
WS-O-CTL4 : 000
WS-O-CTL1(2:3) : 8
WS-O-CTL2(2:3) : 00
WS-O-CTL3(2:3) : 94
after press,the value is
WS-O-CTL1 : 0018
WS-O-CTL2 : 0111
WS-O-CTL3 : 0666
WS-O-CTL4 : 0000

WS-O-CTL2 and WS-O-CTL3 is not the value i want,what cause that?
Why WS-O-CTL1 is correct?
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Fri Mar 16, 2007 9:31 am    Post subject:
Reply with quote

Since the source and destination bits (partially) are similar for CTL2 and CTL3, you are getting the OP like that.

Corrections are welcome.
Back to top
View user's profile Send private message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 10:12 am    Post subject: Re: problem about MOVE statement
Reply with quote

The system delete the spaces automatically,so i add space line here.
MOVE WS-O-CTL1(1:2) TO WS-O-CTL1(3:2).

MOVE '00' TO WS-O-CTL1(1:2).

MOVE WS-O-CTL2(1:3) TO WS-O-CTL2(2:3).

MOVE '0' TO WS-O-CTL2(1:1).

MOVE WS-O-CTL3(1:3) TO WS-O-CTL3(2:3).

MOVE '0' TO WS-O-CTL3(1:1).

MOVE '0000' TO WS-O-CTL4.
Back to top
View user's profile Send private message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 10:13 am    Post subject:
Reply with quote

correct the definition
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL2 PIC X(04)
05 WS-O-CTL3 PIC X(04)
05 WS-O-CTL4 PIC X(04)
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Mar 16, 2007 10:41 am    Post subject:
Reply with quote

WS-O-CTL2 100B -- B for blank
MOVE WS-O-CTL2(1:3) TO WS-O-CTL2(2:3).
it works like this- this move will spawn 3 byte level moves.
Code:
   WS-O-CTL2(1:1) to WS-O-CTL2(2:1)   ---   WS-O-CTL2  is 110B
   WS-O-CTL2(2:1) to WS-O-CTL2(3:1)   ---   WS-O-CTL2  is 111B
   WS-O-CTL2(3:1) to WS-O-CTL2(4:1)   ---   WS-O-CTL2  is 1111

NOTE:
Value of your variable is changing after every elementary move.
Other results are explanable using the same techniqe.
Use a temp variable so as not to get in to such problem. icon_smile.gif
Back to top
View user's profile Send private message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 10:44 am    Post subject:
Reply with quote

Thank you.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Mar 16, 2007 10:50 am    Post subject:
Reply with quote

Your'e welcome. icon_smile.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Mar 16, 2007 10:59 am    Post subject: Re: problem about MOVE statement
Reply with quote

william51 wrote:
WS-O-CTL2 and WS-O-CTL3 is not the value i want,what cause that?
Standard overlapping move, programmers have been using it for almost 50 years to clear or initialize memory.
The MVC works byte for byte left to right.
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 SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm


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