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
 

 

What's the result of the move statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
k_sanu4u

New User


Joined: 23 Mar 2007
Posts: 8
Location: india

PostPosted: Thu Apr 12, 2007 4:24 pm    Post subject: What's the result of the move statement
Reply with quote

01 VAR-A PIC X(5) VALUE SPACES.
01 VAR-B PIC 9(5) COMP-3.

MOVE VAR-A TO VAR-B.

WHAT WILL BE THE VALUE OF VAR-B?
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Apr 12, 2007 4:31 pm    Post subject:
Reply with quote

Hi k_sanu4u,

Why dont u try urself rather then asking?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Apr 12, 2007 5:25 pm    Post subject:
Reply with quote

Are you sure you will even be allowed to do that move?
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Thu Apr 12, 2007 10:37 pm    Post subject: Re: What's the result of the move statement
Reply with quote

You can't move char to a packed decimal..
It shouldn't even compile

~Vamsi
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Apr 13, 2007 4:00 am    Post subject:
Reply with quote

My guess is that you'll get X'00000F' which, of course, is packed unsigned zeros. Another possiblity is X'000004', but I think the "sign" gets ORed to an F.
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Fri Apr 13, 2007 4:24 am    Post subject: Re: What's the result of the move statement
Reply with quote

this was the compilation error:

"' '" and "X-1 (PACKED INTEGER)" did not follow the "MOVE" statement compatibility rules. The statement was discarded.
Back to top
View user's profile Send private message
k_sanu4u

New User


Joined: 23 Mar 2007
Posts: 8
Location: india

PostPosted: Fri Apr 13, 2007 4:13 pm    Post subject:
Reply with quote

i got zeros as answer while execueting ...can u justify ur answers...
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Apr 13, 2007 5:08 pm    Post subject:
Reply with quote

Quote:
01 VAR-A PIC X(5) VALUE SPACES.
01 VAR-B PIC 9(5) COMP-3.

Explanation
Space = '40' H in EBCDIC
VAR-A = '4040404040'H
After move you will get '00000F' in VAR-B.
See the move worked this way. Only Lower nibbles were considered.
Compiler will generate code for this 'alignment'.

Similarly when there are all 'A's in VAR-A, you will get 11111 (A= C1 H)
When ALL 'B's then you will get 22222 (B= C2 H)
When ALL 'X's then you will get 77777 (X= E7 H)

It can be perceived as upper nibble of each byte is ignored in each move.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 14, 2007 8:43 pm    Post subject:
Reply with quote

I'd only add this to Abhijit's excellent explanation:

The 1st step in the conversion produces X'000004' (the two low order nybbles (40) are reversed, not compressed as the others are). Then, because the PIC of VAR-B is unsigned, the low order byte X(04) is ORed to produce X'0F' making the VAR-B value X'00000F'
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts scheduling between OPC and TWS give u... nsbl IBM Tools 1 Sun Mar 12, 2017 5:35 pm
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


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