ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Converting String to Integer question

Post new topic  Reply to topic
 Converting String to Integer question « View previous topic :: View next topic » 
Author Message
TonyD
PostPosted: Mon Dec 06, 2004 4:55 pm    Post subject: Converting String to Integer question Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

I have an MRM message that contains a repeating group preceded by a Count field. All data is string, eg:
Code:

Count    03
Group1  123
Group2  456
Group3  789

The message therefore looks like:
Code:

03123456789

or:
Code:

X'3033313233343536373839'

I need to convert the 2-byte Count to integer so that the MRM can resolve the number of occurences using this field.
The required result is therefore:
Code:

X'0003313233343536373839'

If the Count was 55 the first two bytes would be X'0037'.
I have been able to achieve this. However the result is platform dependent. I am developing and testing in a Windows environment for deployment on a Unix machine. The 2-byte Windows representation of integer 3 is X'0300' vs X'0003' in Unix.
Is there a way that I can achieve the required result that is platform independent? That is, the integer is correctly represented depending upon the platform it is running on without having to change the ESQL. Also does anyone has an elegant way of converting the 2-byte string Count to a two-byte integer Count ?
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Mon Dec 06, 2004 5:21 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Maybe I'm missing something, but don't you just declare the count in the MRM as an Integer, and cast the String to it. And as long as the Encoding is set to Native, it will be written out correctly for any platform.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
TonyD
PostPosted: Mon Dec 06, 2004 6:43 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Well it is probably me who is missing something but I'm always ready to be corrected....
In the actual situation I am working on the physical data that arrives at the MQInput node in my message for the 2-byte Count field is X'3033''. Although I have altered the MRM field definition, built from an imported Cobol copybook, from 'string' with length 2 to 'int' with length 2 this does not alter the fact that the data is not a valid integer representation. MRM parsing fails with an incorrect message length.
I therefore am reading the message as a BLOB, recalculating the value of Count to X'0003', and then converting it to little-endian X'0300' for my Intel environment. The message is then reparsed correctly through an RCD node.
The problem is that X'0300' will not be correct when the flow runs in a big-endian Unix environment.
Am I making things more difficult than they need to be?!
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Mon Dec 06, 2004 11:44 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
Am I making things more difficult than they need to be

Maybe.
Quote:
Although I have altered the MRM field definition, built from an imported Cobol copybook, from 'string' with length 2 to 'int' with length 2

Not quite. You need to change it so it's declared as an Extended Decimal. (I think that's the correct term). It's the equivalent of a COBOL PIC 99 field. This is a numeric field, but still as characters, not binary or packed decimal. Or, change the COBOL copybook from PIC XX to PIC 99 and re-import.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
kirani
PostPosted: Mon Dec 06, 2004 11:53 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

It does not matter in this case whether the field is defined as PIC 99. or PIC XX. The output will look same in either case. It would not work if the fields are defined as signed.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
EddieA
PostPosted: Tue Dec 07, 2004 12:02 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
It does not matter in this case whether the field is defined as PIC 99. or PIC XX

But this is an Input field, used to determine how many repeats there are. I this case, I would have thought that it did matter.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
TonyD
PostPosted: Tue Dec 07, 2004 2:09 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Quote:

But this is an Input field, used to determine how many repeats there are. I this case, I would have thought that it did matter

....it does matter because the MRM parser will only correctly calculate the number of occurrences if the Count (Repeat Reference) is an integer....in fact you cannot specify a field as a repeat reference unless it is defined as integer.
If the program that created the message had created the field as packed decimal there would be no problem but it didn't and it is not possible to change it to do so as it is used by a number of other functions.
If I have to modify my ESQL to decide the 'endian-ness' of the runtime enviroment what would be the best way to do this?
Back to top
View user's profile Send private message Send e-mail
TonyD
PostPosted: Tue Dec 07, 2004 2:55 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Quote:

If I have to modify my ESQL to decide the 'endian-ness' of the runtime enviroment what would be the best way to do this?

...decided to test MQENC_NATIVE for '273' or '546' since these are the only two platforms involved...works OK.
Back to top
View user's profile Send private message Send e-mail
TonyD
PostPosted: Tue Dec 07, 2004 4:44 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Quote:

You need to change it so it's declared as an Extended Decimal. (I think that's the correct term). It's the equivalent of a COBOL PIC 99 field. This is a numeric field, but still as characters, not binary or packed decimal. Or, change the COBOL copybook from PIC XX to PIC 99 and re-import.


...you were right EddieA!...and I was making things way more difficult than they needed to be!!
For some reason I had the idea firmly in my mind that the Count field had to be a binary integer....completely wrong! 'xsd:short' works perfectly well and makes all the stuff I wrote above completely unnecessary and also incorrect...please disregard!
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Tue Dec 07, 2004 5:26 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Glad you got it working.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
kirani
PostPosted: Tue Dec 07, 2004 11:54 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

EddieA wrote:
But this is an Input field, used to determine how many repeats there are.

I missed this part
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Converting String to Integer question
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.