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
 

 

Is this a valid move

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

New User


Joined: 21 Jul 2006
Posts: 18
Location: Pune

PostPosted: Thu Nov 29, 2007 4:54 pm    Post subject: Is this a valid move
Reply with quote

Hi All,

In my program I have declared two variables as :

Code:
IDENTIFICATION DIVISION.                       
PROGRAM-ID. ARVIND.                           
DATA DIVISION.                                 
WORKING-STORAGE SECTION.                       
77  A               PIC   X(9) VALUE '12345'. 
77  B REDEFINES A   PIC   9(5).               
PROCEDURE DIVISION.                           
                                               
    DISPLAY 'A :' A.                           
    MOVE A TO B.                               
    DISPLAY 'B :' B.                           
    STOP RUN.                                 


Output which I am getting is
Code:
A :12345
B :5   0
[/code]

Here I have two doubts :-
1. Can we move Alphanumeric to Numeric.
2. If we can then for positions 2,3,4 in B why it is displaying spaces.

Thanks,
Arvind
Back to top
View user's profile Send private message

Aaru

Senior Member


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

PostPosted: Thu Nov 29, 2007 5:41 pm    Post subject: Reply to: Is this a valid move
Reply with quote

aravind,

Quote:
MOVE A TO B.


Why are you moving the value of A when it is redefined? Remove the MOVE statement and check. It will have 12345 in B.

Quote:
Can we move Alphanumeric to Numeric.


Yes, you can move alphanumeric to numeric.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Nov 29, 2007 5:58 pm    Post subject:
Reply with quote

aravind,

Code:

77  A               PIC   X(9) VALUE '12345'. 
77  B REDEFINES A   PIC   9(5).     


Code:

A has '12345    '  or '12345bbbb' where b = space


you moved something 'almost' to itself.

since B is numeric, the starting point of the sending field is the length of the receiving field (5) and since it is numeric, it is left justified instead of right (as in an alpha move). So you moved '5bbbb' to B and the right most byte was set to zero.

as aaru said, before the move, b contained 12345.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Nov 29, 2007 6:56 pm    Post subject:
Reply with quote

This is what manual says about such move.
Unpredictable!!!!
Back to top
View user's profile Send private message
Aaru

Senior Member


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

PostPosted: Thu Nov 29, 2007 7:02 pm    Post subject: Reply to: Is this a valid move
Reply with quote

Abhijit,

Thanks for the link. It makes sense as there is no necessity to move when redefined.

Aravind,

Quote:
Can we move Alphanumeric to Numeric.


check this topic

http://ibmmainframes.com/viewtopic.php?t=6130
Back to top
View user's profile Send private message
rahul.banik

New User


Joined: 23 Jan 2007
Posts: 16
Location: Mysore

PostPosted: Fri Nov 30, 2007 12:55 pm    Post subject:
Reply with quote

Hi All,

This is almost same like Aravind's program.But I've declared 'B' separately(not redefines A).

Code:
WORKING-STORAGE SECTION.                     
77  A               PIC   X(9) VALUE '12345'.
77  B               PIC   9(5) VALUE ZEROES.
PROCEDURE DIVISION.                         
                                             
    DISPLAY 'A :' A.                         
    DISPLAY 'B :' B.                         
    MOVE A TO B.                             
    IF B IS NUMERIC                         
       DISPLAY ' B IS STILL NUMERIC '       
    END-IF.                                 
    DISPLAY 'B :' B.                         
    GOBACK.                                 



Output which I am getting is like that:



Code:

A :12345
B :00000
B :5       


Can anyone explain it.

Thanks,
Rahul
Back to top
View user's profile Send private message
Aaru

Senior Member


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

PostPosted: Fri Nov 30, 2007 1:41 pm    Post subject: Reply to: Is this a valid move
Reply with quote

rahul,

Welcome to the forums.

Quote:
Output which I am getting is like that:



Code:

A :12345
B :00000
B :5



Can anyone explain it.


It is well explained in Dick's last post on thi stopic.

Dick Wrote:
Quote:
since B is numeric, the starting point of the sending field is the length of the receiving field (5) and since it is numeric, it is left justified instead of right (as in an alpha move). So you moved '5bbbb' to B and the right most byte was set to zero


Post your queries if you are not convinced.
Back to top
View user's profile Send private message
liwony

New User


Joined: 13 Apr 2007
Posts: 4
Location: china

PostPosted: Fri Nov 30, 2007 8:42 pm    Post subject: Re: Reply to: Is this a valid move
Reply with quote

Aaru wrote:
rahul,

Welcome to the forums.

Quote:
Output which I am getting is like that:



Code:

A :12345
B :00000
B :5



Can anyone explain it.


It is well explained in Dick's last post on thi stopic.

Dick Wrote:
Quote:
since B is numeric, the starting point of the sending field is the length of the receiving field (5) and since it is numeric, it is left justified instead of right (as in an alpha move). So you moved '5bbbb' to B and the right most byte was set to zero


Post your queries if you are not convinced.


but Output I got which is like this:
A:12345 B:00000 B:5 0
can anyone explain it

thanks
liwony
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 01, 2007 7:48 am    Post subject:
Reply with quote

The explanation for the MOVE result observed by Arvind is contained in the link below:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr10/6.2.24.1?SHELF=&DT=20020920180651&CASE=

I've Quoted the pertinent parts here:
Quote:
The following rules outline the execution of valid elementary moves. When the receiving field is:

Numeric or Numeric-edited:

Except where zeros are replaced because of editing requirements, alignment by decimal point and any necessary zero filling take place, as described under "Alignment rules" in topic 5.1.6.6.
MMW- this produces the intermediate result "5bbbb"- MMW

If the receiving item is unsigned, the absolute value of the sending item is moved, and no operational sign is generated for the receiving item.

When the sending item is alphanumeric, the data is moved as if the sending item were described as an unsigned integer.
MMW- to produce an unsigned integer the MOVE rtn ORs the hi-order nybble of the low-order byte (X'40') to produce an X'F0' - this produces the final result "5bbb0"- MMW
Back to top
View user's profile Send private message
liwony

New User


Joined: 13 Apr 2007
Posts: 4
Location: china

PostPosted: Sat Dec 01, 2007 10:32 am    Post subject:
Reply with quote

Hi, ammwife

thanks for ur link
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 01, 2007 7:06 pm    Post subject:
Reply with quote

HIH.
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 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
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 Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


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