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: 7281

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: 1747
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: 7951
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: 1641
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 JCL to get submitted once dataset has... vinu78 JCL & VSAM 17 Thu Feb 16, 2017 7:32 am
No new posts Ccompar BLOB (images of type jpg) on ... nihad DB2 0 Sun Feb 05, 2017 3:13 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm


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