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

Moving partial values from one variable to another


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pradeep.veluvali

New User


Joined: 07 Mar 2005
Posts: 1

PostPosted: Tue Oct 16, 2007 11:06 am
Reply with quote

I have 2 variables

A PIC X (2).

B PIC X (2002).

I need to move the last 2 digits of variable ‘B’ in to the variable ‘A’.

How will you do it?
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Tue Oct 16, 2007 1:35 pm
Reply with quote

Quote:
Sorry, I got wrong. Please ignore the first post.

It should be

MOVE 'B(2001:2)' TO 'A'.


Why are you using quotes?

KSK
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 16, 2007 2:19 pm
Reply with quote

HI Inamadugu,

Quote:
MOVE 'B(2004:2)' TO 'A'.
Is there any another method to do this?


Do you mean It? Read the post properly.

It will be

Code:
MOVE B(2001:2) TO A.
Back to top
View user's profile Send private message
inamadugu
Warnings : 1

New User


Joined: 23 Aug 2007
Posts: 18
Location: Delhi

PostPosted: Tue Oct 16, 2007 2:57 pm
Reply with quote

Hi Hemanth,
I have already posted the answer what you have quoted. Please see the next post send by me. The first post was an accident.
Now another thing what KSK asked is why I used quotes?
KSK,
I used quotes because it is an alphanumeric item. If anything wrong please let me know.
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 16, 2007 3:08 pm
Reply with quote

Hi Inmadugu,

Quote:
I used quotes because it is an alphanumeric item. If anything wrong please let me know


Just I posted that clarify you about Move Syntax. Again you are asking a question.

Murali told you to check syntax of Move Verb, had you gone through it? I hope, No. And KSK asked to you "why are you using quotes".

Justify yourself, Where you are wrong?
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Tue Oct 16, 2007 3:13 pm
Reply with quote

Hemantha,

Quote:
Justify yourself

We use quotes for moving constant values (alpha or alphanumeric). But for the requirement you are moving from var to var. Moreover your destination (A) according to your post is a constant not a var (memory allocation).

Just let us know, if you need anymore info on this. And also go thru the manual one more time.
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 16, 2007 3:24 pm
Reply with quote

Hi Murali,

Quote:
We use quotes for moving constant values (alpha or alphanumeric). But for the requirement you are moving from var to var. Moreover your destination (A) according to your post is a constant not a var (memory allocation).


Thanks for your explanation, but as per var declared in this POST I moved the same to Var (A). I know syntax Rules of Move command, thats why, I replied for Inmadugu's Reply. I don't know how you understood this.

Thanks for good explanation.
Back to top
View user's profile Send private message
ravi.veda

New User


Joined: 30 Mar 2007
Posts: 7
Location: banglore

PostPosted: Tue Oct 16, 2007 5:51 pm
Reply with quote

MOVE 'B(2004:2)' TO 'A'.


i think the above one is wrong,

MOVE B(2000:2) to A
bcz he want to move 2001,2002 to A.
RF = (starting position:total length)[/i]


Regards,
veda.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 5:58 pm
Reply with quote

ravi,

Quote:
MOVE B(2000:2) to A
bcz he want to move 2001,2002 to A.



Did you refer to the manuals?
Back to top
View user's profile Send private message
ravi.veda

New User


Joined: 30 Mar 2007
Posts: 7
Location: banglore

PostPosted: Tue Oct 16, 2007 5:58 pm
Reply with quote

ravi.veda wrote:
MOVE 'B(2004:2)' TO 'A'.


i think the above one is wrong,

MOVE B(2001:2) to A
bcz he want to move 2001,2002 to A.
RF = (starting position:total length)[/i]


Regards,
veda.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 6:01 pm
Reply with quote

Ravi,

Please read all the posts on the topic before posting as this was already answered by hemanth.

Anyways you are correct this time.

There is one more way to move the last 2 digits.

Code:
Code:
MOVE B(2001:) TO A.
Back to top
View user's profile Send private message
ravi.veda

New User


Joined: 30 Mar 2007
Posts: 7
Location: banglore

PostPosted: Tue Oct 16, 2007 8:06 pm
Reply with quote

Hi Ayru,
sory for that.next time i will look all the posts.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Wed Oct 17, 2007 11:45 am
Reply with quote

Inamadugu,


Quote:
KSK,
I used quotes because it is an alphanumeric item. If anything wrong please let me know.



If u want to move a string, u can use quotes to move total string to another variable. But in this case u want to move value of sending field but not string and also u were using quotes for receiving field which was again wrong.

KSK
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Oct 17, 2007 5:16 pm
Reply with quote

Code:

01  A                                     PIC X(02).

01  B.
    05  FILLER                            PIC X(2000).
    05  B-OFFSET-2000-FOR-2               PIC X(02).



Code:

MOVE B-OFFSET-2000-FOR-2
  TO A.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top