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

NUMERIC to SIGNED BINARY DATA type conversion


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

New User


Joined: 20 Jan 2010
Posts: 26
Location: Alabama

PostPosted: Tue Apr 08, 2014 8:53 pm
Reply with quote

Hi. I'm trying to load the value of a BINARY data element (PIC s9(05) BINARY) from numeric data (PIC 9(05)), but I'm not getting the desired results. See below. please advise how to do this. I've tried MOVE, COMPUTE, and ADD - all produce the same results. Why is there a zero on the end of the target field?

Code:
20  ZMQMS-MQ-MESSAGE-LEN   PIC  9(005).


Code:
16  WS-MESSAGE-LEN              PIC S9(05) BINARY.


Code:
DISPLAY '-MQIO- ZMQMS-MQ-MESSAGE-LEN: '
        ZMQMS-MQ-MESSAGE-LEN.

MOVE  ZMQMS-MQ-MESSAGE-LEN  TO
      WS-MESSAGE-LEN.

DISPLAY '-MQIO- WS-MESSAGE-LEN: '
        WS-MESSAGE-LEN.


OUTPUT:

Code:
-MQIO- ZMQMS-MQ-MESSAGE-LEN: 5704
-MQIO- WS-MESSAGE-LEN: 57040
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Apr 08, 2014 9:16 pm
Reply with quote

Count your digits in the output from your DISPLAY. I make that four.

Put ">" "<" (or similar) around each field you DISPLAY, then you can see every time. Saved me and those I've suggested it to many, many hours over the years.
Back to top
View user's profile Send private message
rss0213

New User


Joined: 20 Jan 2010
Posts: 26
Location: Alabama

PostPosted: Tue Apr 08, 2014 11:27 pm
Reply with quote

I'm not sure what you mean. The original message length value is 5704. The receiving variable gets 57040. How is that?
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: Tue Apr 08, 2014 11:44 pm
Reply with quote

Brain fade here . . . .

Quote:
Count your digits in the output from your DISPLAY. I make that four.
Code:
20  ZMQMS-MQ-MESSAGE-LEN   PIC  9(005).
How did the 9(005) become a length of four?

Been one of those days between my ears . . . icon_rolleyes.gif
Do be gentle . . . icon_pray.gif

d
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Apr 09, 2014 12:34 am
Reply with quote

rss0213 wrote:
I'm not sure what you mean. The original message length value is 5704. The receiving variable gets 57040. How is that?

How many digits are in "5704"?
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: Wed Apr 09, 2014 12:53 am
Reply with quote

Your PIC 9(005) variable probably has 5704 and a space - hence the suggestion to use '>' and '<' to clearly delineate your variable value. The space will be converted to a zero during the move, hence the BINARY variable value is 57040.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Apr 09, 2014 3:13 am
Reply with quote

Scott,

There are many discussion on BINARY data conversion on this forum and I found two of them which could be of your interest,

1) www.ibmmainframes.com/viewtopic.php?t=58905&highlight=binary
2) www.ibmmainframes.com/viewtopic.php?t=59717&highlight=binary
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Apr 09, 2014 9:19 pm
Reply with quote

Scott,

well, since MQS delivers the message size in binary (part of each message header)
it could be that the idiot that converted the binary value to a display value (used as your input) created a small problem.
the message length is usually contained in a fullword binary field.
so, S9(05) as the display field is not a good choice.

so, as several have said, investigate the value contained in the display field.
Back to top
View user's profile Send private message
rss0213

New User


Joined: 20 Jan 2010
Posts: 26
Location: Alabama

PostPosted: Thu Apr 10, 2014 1:51 am
Reply with quote

I found the issue. A group-level MOVE statement in a different area of the program was stomping on the data area contained in ZMQMS-MQ-MESSAGE-LEN. That group-level item contained a LENGTH field with PIC 9(04).

icon_redface.gif

Mystery solved. Thanks for helping everyone!
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: Thu Apr 10, 2014 6:45 pm
Reply with quote

Good to hear it is resolved - thank you for letting us know icon_smile.gif

d
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 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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts 10 byte RBA conversion DB2 2
Search our Forums:

Back to Top