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

Data issue when moving from Alphanumeric to numeric field


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

New User


Joined: 15 Sep 2008
Posts: 22
Location: Mumbai

PostPosted: Sat Nov 14, 2009 3:38 pm
Reply with quote

Hi,
Can someone give clarification and to resolve the following.

My code has a variable Var1 which is X(10) and a group variable Var2 which contain Var21 as 9(7) and other child variables

I am trying to Move Var1(1:7) to Var21

Here if Var1 has 00000CC, Var2 wont have anything as it cannot hold this data.
But if Var1 has 000000C, Var2 has 0000003.

Can someone tell me why the value is changed for the last digit alone?

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

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Nov 14, 2009 4:06 pm
Reply with quote

Hello,

Because the target field has no sign.
Back to top
View user's profile Send private message
nithivenkat

New User


Joined: 15 Sep 2008
Posts: 22
Location: Mumbai

PostPosted: Sat Nov 14, 2009 4:20 pm
Reply with quote

Hi Dick,

Can u please elaborate? I mean how to actually make the target field to follow the same as case 1?

Thanks,
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Nov 14, 2009 4:24 pm
Reply with quote

When a receiving field is defined as display-numeric (IE: VAR2) and data is moved to it, the compiler ensures a zone-nibble "F" in the last-byte via an Or-Immediate instruction ("OI").

In your example, the last-byte of the sending field is a capital "C" (X'C3'). After the move, the compiler issues the "OI" against the last-byte of the receiving-field and the X'C3' is transformed to a X'F3' (a numeric "3").

To avoid this, issue -

Code:

MOVE VAR1 (1:) TO VAR2 (1:).

You don't need to specify the length of 7, because both fields are the same length and the compiler will treat the move as an Alphanumeric to an Alphanumeric and the "OI" will not be issued.

So, regardless of the last-byte's zone-nibble, the 'OI' will be issued when reference modification is not specified against the receiving-field.

However, if the numeric portion of the sending field's last byte is a 4-Bit "A" through a 4-Bit "F", you'll create a field which has the potential to raise a S0C7, when arithmetic is performed against it, regardless whether the "OI" is issued or not.

Using this Alphanumeric to Alphanumeric reference modification move when the receiving field is NUMERIC is not something which should be advocated or used, unless there's a specific business need, because this could cause problems later.

Bill
Back to top
View user's profile Send private message
nithivenkat

New User


Joined: 15 Sep 2008
Posts: 22
Location: Mumbai

PostPosted: Sat Nov 14, 2009 4:30 pm
Reply with quote

Hi Bill,

"You don't need to specify the length of 7, because both fields are the same length and the compiler will treat the move as an Alphanumeric to an Alphanumeric and the "OI" will not be issued. "

My Var 1 is X(10) and Var21 is 9(7).

I need the first 7 bytes of Var 1 to be moved to Var21.

Please advice.
Back to top
View user's profile Send private message
nithivenkat

New User


Joined: 15 Sep 2008
Posts: 22
Location: Mumbai

PostPosted: Sat Nov 14, 2009 4:41 pm
Reply with quote

Also, I wont perform any arithmetic with my target field. So kindly advice on this regard Bill/Dick.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Nov 14, 2009 4:44 pm
Reply with quote

Yes, the example MOVE will work, regardless of the sending field's length. But, if you'd only need to populate (for example) bytes 1-4 of the 7-byte receiving field, then you would specify (1:4) and bytes 5-7 will not be touched.

Take a look at the MVC assembler instruction and you'll find that there isn't any length specified for the sending field (known as operand-1), but there is a length specified for the receiving field (known as operand-2).

You can find instruction breakdowns in the Principles of Operation -

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/DZ9ZBK03

search for MVC and you'll see what I mean.

Bill
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Nov 14, 2009 10:04 pm
Reply with quote

Hello,

Not tested but you could run a little experiment using S9(7) for Var2 rather than 9(7). . .
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Nov 15, 2009 7:57 pm
Reply with quote

Hi nithivenkat,

It might be helpful to tell us how the data will be eventually used. If it will be presented in a report (not DISPLAYed on a screen) give us examples of the types of data that can be expected in VAR1 and what you expect to see when it's printed. Here's some examples - what are the possibilities in your case:

abcdefg
ABCDEFG
~ 6^><|2
$800.00
2006.24
000000C (i.e. X'F0F0F0F0F0F0C3')
x'0000000000003C'
ETC.
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top