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

Query on Move X(11) data to 9(11) variable


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

New User


Joined: 11 Jul 2007
Posts: 68
Location: noida

PostPosted: Mon Apr 27, 2009 8:56 pm
Reply with quote

Hi All.

Pls look at the follwoing code
05 CC-00000000000 PIC X(11) VALUE
'00000000000'.

05 D17625-MEMBER-ID PIC 9(11).

MOVE CC-00000000000 TO D17625-MEMBER-ID

This move is working fine. But I wanted to understand what is going on at background. How is the move able to assign char data to numeric data ( is it always allowed ?)

Secondly if it is allowed.. then when does actual type checking happen or is there sometype of type conversion happening..

Pls throw as much light as possible..
Thanks
Sunny
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Apr 27, 2009 9:00 pm
Reply with quote

If you run the compile with LIST (not OFFSET) you will see the MOVE statement is converted into a pseudo-assembler MVC instruction. This instruction moves 11 bytes from one field to another field -- as long as they are both USAGE DISPLAY. Note that the sending field does not even have to have numeric data; you can move anything from a variable to a PIC 9(11) USAGE DISPLAY field.

Attempting to do any arithmetic with the field, however, will cause problems unless all 11 characters are actually numeric digits. And you will also run into issues when fields are converted (USAGE COMP, COMP-3, etc) as these types of moves require numeric data or generally a S0C7 abend occurs.
Back to top
View user's profile Send private message
sunny_io

New User


Joined: 11 Jul 2007
Posts: 68
Location: noida

PostPosted: Mon Apr 27, 2009 9:50 pm
Reply with quote

Hi
Thanks for the reply
One more query I had ..
MOVE CC-00000000000 TO D17625-MEMBER-ID

Considering what I have as pic clause and what I'm moving ..
Although 05 CC-00000000000 PIC X(11) VALUE
'00000000000'.
is character by PIC clause but has zeroes in it..
Would I stil get Soc 7 if I manipulate D17625-MEMBER-ID ??
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Apr 27, 2009 10:38 pm
Reply with quote

Not the way you've got things defined -- COBOL doesn't care where the data came from, only that each digit is numeric when being used for arithmetic or other numeric operation.
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 Store the data for fixed length COBOL Programming 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top