| Author | 
		  Message
		 | 
		
		  | NSJ | 
		  
		    
			  
				 Posted: Mon Aug 08, 2005 11:05 pm    Post subject: EBCDIC to ASCII conversion | 
				     | 
			   
			 
		   | 
		
		
		    Novice
 
 Joined: 06 Jul 2005 Posts: 12
  
  | 
		  
		    
			  
				Hi All
 
I am trying out some basic conversion from EBCDIC to ASCII .i am very new to this.I will describe what i am trying to do. I dont know whether what i am doing is possible or not.
 
The queue manager is on Windows XP professional 
 
MQ Version   5.3 
 
i am using the Java API for putting and getting the messages.
 
 
I have a java program which puts a Text message onto a Queue after converting the text into ebcdic. The code is as below:
 
 
   
	| Code: | 
   
  
	MQMessage hello_world = new MQMessage();
 
hello_world.format=MQC.MQFMT_STRING;
 
hello_world.characterSet=500;
 
String a = "TEST MESSAGE";
 
byte[] b = a.getBytes();
 
String b1 = new String(b, "Cp500");
 
System.out.println("The EBCDIC string is :"+b1);
 
hello_world.writeString(b1);
 
// specify the message options...
 
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the // defaults,
 
// put the message on the queue
 
system_default_local_queue.put(hello_world,pmo); | 
   
 
 
 
 
This puts the message on to the queue successfully and when i browse the queue using RfhUtil i can see the ebcdic message.
 
Next i am reading the message from the queue using another java program.I am using MQ_GMO_Convert option but the message doesnt get converted. It remains as the EBCDIC string. Am i doing something wrong. 
 
The Java program for getting the message is as below.
 
 
   
	| Code: | 
   
  
	java.util.Hashtable properties = new java.util.Hashtable();
 
properties.put("MQC.CCSID_PROPERTY", "850");
 
// Create a connection to the queue manager
 
qMgr = new MQQueueManager(qManager, properties);
 
 
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;
 
MQEnvironment.CCSID=850;
 
 
MQQueue system_default_local_queue =
 
qMgr.accessQueue("ORDER.OUT",
 
openOptions,
 
"ICSQM", // default q manager
 
null, // no dynamic q name
 
null); // no alternate user id
 
 
 
 
MQMessage retrievedMessage = new MQMessage();
 
retrievedMessage.characterSet=850;
 
 
MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
 
gmo.options = gmo.options|MQC.MQGMO_CONVERT;
 
// get the message off the queue...
 
system_default_local_queue.get(retrievedMessage, gmo);
 
 
String msgText = retrievedMessage.readLine();
 
System.out.println("The message is: " + msgText); | 
   
 
 
 
 
 
Please let me know if you need any more information.
 
Thanks
 
NSJ
  Last edited by NSJ on Tue Aug 09, 2005 5:30 am; edited 1 time in total | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Tue Aug 09, 2005 3:30 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				There is a utility, amqsbcg or amqsbcgc, installed with the samples (<Mq-install-root>/samp/bin on Unix, <mq-install-root>\Tools\c\Samples\Bin on Windows).
 
 
It will dump the contents of a queue into a fairly useful output format.
 
 
Write your message, and then dump it using this utility, and then post the results here. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | NSJ | 
		  
		    
			  
				 Posted: Tue Aug 09, 2005 6:40 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Novice
 
 Joined: 06 Jul 2005 Posts: 12
  
  | 
		  
		    
			  
				Hi
 
Thats a cool utility.I put the message on the queue and ran AMQSBGC.Here is the output.
 
   
	| Code: | 
   
  
	
 
AMQSBCG0 - starts here
 
**********************
 
 
 MQOPEN - 'ORDER.OUT'
 
 
 
 MQGET of message number 1
 
****Message descriptor****
 
 
  StrucId  : 'MD  '  Version : 2
 
  Report   : 0  MsgType : 8
 
  Expiry   : -1  Feedback : 0
 
  Encoding : 273  CodedCharSetId : 500
 
  Format : 'MQSTR   '
 
  Priority : 0  Persistence : 0
 
  MsgId : X'414D5120494353514D20202020202020A126F34220001D01'
 
  CorrelId : X'000000000000000000000000000000000000000000000000'
 
  BackoutCount : 0
 
  ReplyToQ       : '                                                '
 
  ReplyToQMgr    : 'ICSQM                                           '
 
  ** Identity Context
 
  UserIdentifier : 'db2admin    '
 
  AccountingToken :
 
   X'160105150000006F377A03805550D53F8B31B0F903000000000000000000000B'
 
  ApplIdentityData : '                                '
 
  ** Origin Context
 
  PutApplType    : '11'
 
  PutApplName    : 'MB\eclipse\jre\bin\javaw.exe'
 
  PutDate  : '20050809'    PutTime  : '14270396'
 
  ApplOriginData : '    '
 
 
  GroupId : X'000000000000000000000000000000000000000000000000'
 
  MsgSeqNumber   : '1'
 
  Offset         : '0'
 
  MsgFlags       : '0'
 
  OriginalLength : '-1'
 
 
****   Message      ****
 
 
 length - 12 bytes
 
 
00000000:  5445 5354 204D 4553 5341 4745           'TEST MESSAGE    '
 
 
 
 
 No more messages
 
 MQCLOSE
 
 MQDISC | 
   
 
 
 
The program is puting on the queue: èáëè?(áëë åá  which in ASCII is the text  TEST MESSAGE | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | EddieA | 
		  
		    
			  
				 Posted: Tue Aug 09, 2005 6:48 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi
 
 Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| CodedCharSetId : 500 | 
   
 
 
That says the message should be in EBCDIC.
 
   
	| Quote: | 
   
  
	| 5445 5354 204D 4553 5341 4745           'TEST MESSAGE    '  | 
   
 
 
But that's ASCII.  So, a GET with Convert will produxe garbage.
 
 
Cheers, _________________ Eddie Atherton
 
IBM Certified Solution Developer - WebSphere Message Broker V6.1
 
IBM Certified Solution Developer - WebSphere Message Broker V7.0 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | NSJ | 
		  
		    
			  
				 Posted: Wed Aug 10, 2005 4:29 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Novice
 
 Joined: 06 Jul 2005 Posts: 12
  
  | 
		  
		    
			  
				I am a bit confused. When i used RfHutil to read the message it came out as ebcdic characters ie  èáëè?(áëë åá and even when i used java program i got the ebcdic characters.Only when i used AMQSBGC does the ASCII text comes ie TEST MESSAGE. Why are the results differing, Is the message on the queue ASCII or ebcdic.
 
Thanks
 
NSJ | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | wschutz | 
		  
		    
			  
				 Posted: Wed Aug 10, 2005 4:47 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired) 
  | 
		  
		    
			  
				Because amqsbcg does not specify GMO_Convert.  Your java program does:
 
   
	| Code: | 
   
  
	gmo.options = gmo.options|MQC.MQGMO_CONVERT; 
 
 | 
   
 
MQ assumes that the CCSID is correct, so it simply apply the conversion table from 500->437 (or whatever ascii page your are using), which produces "trash".
 
 
   
	| Quote: | 
   
  
	| I have a java program which puts a Text message onto a Queue after converting the text into ebcdic | 
   
 
It appears (from amsqbcg) that your java program is NOT producing an ebcdic string, thats the problem here. _________________ -wayne | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Wed Aug 10, 2005 6:07 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Yes you are doing something wrong.
 
 
If you want for the Mainframe to see the message in EBCDIC without using get with convert 
 
you can try the following:
 
a) convert on the channel 
 
b) use a channel exit on the MF (special format conversion...)
 
c) use JMS and define the remote queue in JNDI with CCSID 500 and use TextMessage
 
 
And then just put normal text in the ccsid of your connecting platform...
 
and do not forget to set your message format to MQSTR
 
 
Enjoy    | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |