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
 

 

NUMERIC to SIGNED BINARY DATA type conversion

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: NUMERIC to SIGNED BINARY DATA type conversion
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Apr 08, 2014 9:16 pm    Post subject: Reply to: NUMERIC TO SIGNED BINARY DATA TYPE CONVERSION
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    Post subject:
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

Site Director


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

PostPosted: Tue Apr 08, 2014 11:44 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Wed Apr 09, 2014 12:34 am    Post subject:
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: 7913
Location: Bellevue, IA

PostPosted: Wed Apr 09, 2014 12:53 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Apr 09, 2014 3:13 am    Post subject:
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) http://www.ibmmainframes.com/viewtopic.php?t=58905&highlight=binary
2) http://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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Apr 10, 2014 6:45 pm    Post subject:
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    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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
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 File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm


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