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 » Conversion

Post new topic  Reply to topic
 Conversion « View previous topic :: View next topic » 
Author Message
bobbee
PostPosted: Tue Jun 16, 2015 1:08 am    Post subject: Conversion Reply with quote

Knight

Joined: 20 Sep 2001
Posts: 545
Location: Tampa

I need an eight byte HEX field that looks like this:

value -70 30 05 43 00 00 80 20
byte - 0 1 2 3 4 5 6 7

They are sending me 16 bytes of character data Below. This is actually coming in as a BLOB. Would I manually convert this by looping through the 16 characters doing BIT manipulation with an XREF table. Is there a way doing a CAST. I just got this requirement last night.

value - 70 30 05 43 00 00 80 20
byte - 01 23 45 67 89 ab cd ef
Back to top
View user's profile Send private message Send e-mail AIM Address
mqjeff
PostPosted: Tue Jun 16, 2015 4:44 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

DFDL supports bit level fields.
Back to top
View user's profile Send private message
bobbee
PostPosted: Tue Jun 16, 2015 5:11 am    Post subject: Reply with quote

Knight

Joined: 20 Sep 2001
Posts: 545
Location: Tampa

Waiting to test, but this is what i came up with, with a liitel help from someone.

Code:
public class Convert {

   public static byte[] convert(String before) throws Exception {
      try {
   /*      String s="7030054300008020";                      */
          byte[] b = new BigInteger(before,16).toByteArray();
          return (byte[]) b;

      } catch (Exception e) {
         System.out.println("Error in CONVERSION method!!");
         e.printStackTrace();
         byte[] ERROR = { (byte) 204 };
         return (byte[]) ERROR;
      }
   }
Back to top
View user's profile Send private message Send e-mail AIM Address
fjb_saper
PostPosted: Tue Jun 16, 2015 6:48 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Sounds about right but for the fact that you're never going to throw an exception... Remove the throws exception from the signature...
And you might want to check the size of the byte array being returned...

Now about that cast how about

Code:
DECLARE cval Char '70.....';
DECLARE bval = BLOB;
cval = 'x' || cval;
bval = CAST (cval AS BLOB);


or something like it...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Conversion
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.