Java UDF help: Hexadecimal to Chinese Unicode converison
Hi Experts,
can someone help me in a design solution to convert Hexadecimal Values to Chinese Characters while sending the data to receiver system.
I am not able to get any methods in Java to do the conversion.
Help is appreciated.
Regards,
Prakash.
Hi Grzegorz Glowacki,
I am sorry this is not working :(.
Sample input: 4E2D56FD -->basically this hexavalues are chinese character representation.
Output for it: ?????????
+for verification:open Wordpad-->copy the hexcode >select 4chars at a time> hit <altx> and you will get corresponding conversion value.++
String result = new String();
try {
byte[] bytes = new byte[input.length()/4];
for (int i = 0; i < input.length()/4; i++) {
byte value = Integer.valueOf(input.substring(i*4,i*4+4), 16).byteValue();
bytes<i> = new Byte( value ); *//Byte cannot be stored in byte*
result = new String(bytes, "UTF-16");
catch (UnsupportedEncodingException e){}
return result;
Also this is PI7.0 system. please do help.
thanks in advance.
Regards,
Prakash.
Edited by: senthilprakash selvaraj on Feb 2, 2012 9:38 AM
Similar Messages
-
hello
I have a string that I recieve from a WS. the string is flat XML. I would like to take only sum of the string.
I would the out put string to be from the begining tag <NS8:EzlifeInsuranceFile and to end </NS8:EzlifeInsuranceFile>.
I would like to transfer the substring of the string the start with the tag above and ends with the string above. does any body has a UDF that does it?
and example XML:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<SOAP-ENV:Header>
<NS1:MessageID xmlns:NS1="http://schemas.xmlsoap.org/ws/2004/03/addressing">82851a66-374c-4847-bf53-437755c45654</NS1:MessageID>
<NS2:From xmlns:NS2="http://schemas.xmlsoap.org/ws/2004/03/addressing">General</NS2:From>
<NS3:StartTime xmlns:NS3="http://migdal.com/soap/header/">2008-12-23 10:32:29.077</NS3:StartTime>
<NS4:ServiceName xmlns:NS4="http://migdal.com/soap/header/">MortgageProposalDetailService</NS4:ServiceName>
<NS5:ServiceVersion xmlns:NS5="http://migdal.com/soap/header/">1.0</NS5:ServiceVersion>
<NS6:CallIdentifier xmlns:NS6="http://migdal.com/soap/header/">176226f3-8c67-4dda-a069-ce8495e44236</NS6:CallIdentifier>
<NS7:CurrentCallMetaData xmlns:NS7="http://migdal.com/soap/header/">
<NS7:ServiceName>MortgageProposalDetailService</NS7:ServiceName>
<NS7:ServiceVersion>1.0</NS7:ServiceVersion>
<NS7:StartTime>TIMESTAMP '2008-12-23 10:32:29.171'</NS7:StartTime>
<NS7:Provider>SAPCRM</NS7:Provider>
<NS7:Protocol>HTTP</NS7:Protocol>
<NS7:Server>mgnt371</NS7:Server>
<NS7:Destination>https://mgnt371:50001/XISOAPAdapter/MessageServlet?channel=:SOAP_Services:ProposalDetailsService_SOAP_Sender</NS7:Destination>
<NS7:Mode>Sync </NS7:Mode>
<NS7:User>xisuper</NS7:User>
<NS7:Password>mgdsap</NS7:Password>
</NS7:CurrentCallMetaData>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<NS8:EzlifeInsuranceFile xmlns:NS8="http://Migdal.co.il/ProposalDetailsRequest/Input">
<userName>CRM_SYS_USER</userName>
<password>Qaz9Pl@5</password>
<TransferType>2</TransferType>
<Agent>
<ID>237cb1f3-19e6-48b5-9e92-bdc1592f145b</ID>
<FirstName>סוכן</FirstName>
<LastName/>
<FullName>סוכן </FullName>
<AgentNumber>1254</AgentNumber>
<SupervisorName/>
</Agent>
<InsuranceFile>
<ID>222069cd-cf2c-45dd-a72d-e52e2c0e1c8a</ID>
<Family>
<ID>222069cd-cf2c-45dd-a72d-e52e2c0e1c8a</ID>
</Family>
<AdditionalQuestionsSelection>
<CapitalPensionPrimeDivisionSelection>5</CapitalPensionPrimeDivisionSelection>
<SalaryInNIS>0</SalaryInNIS>
<SalaryInPercents>0</SalaryInPercents>
<InvestmentTypeSelection>1</InvestmentTypeSelection>
<RewardRouteSelection>1</RewardRouteSelection>
<CompensationRouteSelection>1</CompensationRouteSelection>
<DangerousHobbySelected>False</DangerousHobbySelected>
<DangerousHobbyDescription/>
<IsCourseNoEmployerAproved>False</IsCourseNoEmployerAproved>
<IsCourseWithEmployerAproved>False</IsCourseWithEmployerAproved>
<StartWorkingDate/>
<SpouseSmokingStatusDetails>
<SmokingStatus>0</SmokingStatus>
<CigarettesPerDay>0</CigarettesPerDay>
<YearsOfSmoking>0</YearsOfSmoking>
<YearsOfNotSmoking>0</YearsOfNotSmoking>
</SpouseSmokingStatusDetails>
<ProposalReceivingDate>23/12/2008 10:32:27</ProposalReceivingDate>
</AdditionalQuestionsSelection>
<Note/>
<Title/>
</InsuranceFile>
</NS8:EzlifeInsuranceFile>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>Hi Grzegorz Glowacki,
I am sorry this is not working :(.
Sample input: 4E2D56FD -->basically this hexavalues are chinese character representation.
Output for it: ?????????
+for verification:open Wordpad-->copy the hexcode >select 4chars at a time> hit <altx> and you will get corresponding conversion value.++
String result = new String();
try {
byte[] bytes = new byte[input.length()/4];
for (int i = 0; i < input.length()/4; i++) {
byte value = Integer.valueOf(input.substring(i*4,i*4+4), 16).byteValue();
bytes<i> = new Byte( value ); *//Byte cannot be stored in byte*
result = new String(bytes, "UTF-16");
catch (UnsupportedEncodingException e){}
return result;
Also this is PI7.0 system. please do help.
thanks in advance.
Regards,
Prakash.
Edited by: senthilprakash selvaraj on Feb 2, 2012 9:38 AM -
Hello Sdn
I have bit tricky problem to achieve through java udf in XI. We have to parse a tricky text in java.
Source has a text field : ST - 102RP34;RP - 234ST89;VT - 90789ST;
So the souce text field has a qualifier - value;
In target , I have 3 repeating segments
1) First segment to be created if qualifier is ST ,second segment for qualifier RP,third segment for qualifier VT.
2) There exists 1 field in each segment.
Target Field value for first segment : 10234RP34
Target Field for second sement : 234ST89
Target field for third segment :90789ST
So the problem and trick ,as i understand is : we have 3 qualifiers but in values for these qualifier also we have qualifier values ST,RP etc. So we cant just directly take index of qualifiers as values also have qualifier values.Eg : we have a value : 10234RP34 and RP is also the qualifier.
There will be 2 udfs : one for segment creation and other for the Target field value.
Basically with help of some do while or some loop we need to extract value after "-" and before " ;" and this shld be in some loop to get all the values.
Please help. I am not a java person.
ThanksHi
Assuming that your target is having nodes like
qualifier
value
qualifier
value
qualifier
value
You need 2 UDF's one to generate qualifier and another to generate value from the input String of parameter cache context
For generating qualifier
public void qualifier(String[] input,ResultList result,Container container)
String element, qualifier ="";
StringTokenizer token1 = new StringTokenizer( input, ";");
while (token1.hasMoreTokens())
element = token1.nextToken();
StringTokenizer token2 = new StringTokenizer( element, "-" );
qualifier = token2.nextToken();
result.addValue(qualifier);
output returned will be
ST
RP
VT
Another UDF just and extension of the above can give values(type context)
public void values(String[] input,ResultList result,Container container)
String element, qualifier,value ="";
StringTokenizer token1 = new StringTokenizer( input, ";");
while (token1.hasMoreTokens())
element = token1.nextToken();
StringTokenizer token2 = new StringTokenizer( element, "-" );
qualifier = token2.nextToken();
value = token2.nextToken();
result.addValue(value);
output returned will be
102RP34
234ST89
90789ST
Thanks
Gaurav -
Resources for developing java UDFs used in XI
I am with some Java background working in XI
for developing Java UDFs used in XI are there any online resources or books other than from the SAP help and SAP certification material.Hi Kalyan
You can get a lot of UDF already discussed in Forum and Blogs, Wiki
As you said you are familiar with Java then you wont find any difficulty
https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_weblog&query=xi+udf&adv=false&sortby=cm_rnd_rankvalue
Thanks
Gaurav -
In PI 7.1 - Java UDF's Compiled Class files - Jar File location
Hi All,
In PI 7.1 Does anybody know where the compiled Java UDF's (which are used in Graphical mapping) class files stored in jar are located in integration server? I want to use this jar file in my XSLT mapping.Hi,
I guess it would be under
\usr\sap\<SID>\DVEBMGS00\j2ee\cluster\server0\temp\classpath_resolver
or
\usr\sap\<SID>\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver
Where SID is your XI instance name.
Thanks,
Gujjeti
Edited by: Praveen Gujjeti on Jun 23, 2008 5:12 PM -
Web Service call from java UDF in message mapping
Hi,
Is it possible to call a web service from inside a java UDF in message mapping? The webservice can be any standard one. If this is possible please let me know how this can be done.
Regards,
ShiladityaHi Shila,
Hope u remember me
Here is the standard code used to call webservice from Java UDF
public String setSoapAction(String SOAPAction,Container container){
try{
DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey soapurl = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/SOAP" , "THeaderSOAPACTION");
conf.put(soapurl, SOAPAction);
return "";
}catch(Exception e){
e.getMessage();
return "";
Regards,
Arijit -
Java Access Helper Jar file problem
I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
% java -jar jaccesshelper.jar -install
I get the following error message, and the installation stopped.
Exception in thread "main" java.lang.NumberFormatException: Empty version string
at java.lang.Package.isCompatibleWith(Package.java:206)
at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
at JAccessHelper.main(JAccessHelper.java:39)
If I try to run the jar file, I get the same error message.
Does anyone know how I can fix this?
ThanksCross-posted, to waste yours and my time...
http://forum.java.sun.com/thread.jsp?thread=552805&forum=54&message=2704318 -
I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
% java -jar jaccesshelper.jar -install
I get the following error message, and the installation stopped.
Exception in thread "main" java.lang.NumberFormatException: Empty version string
at java.lang.Package.isCompatibleWith(Package.java:206)
at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
at JAccessHelper.main(JAccessHelper.java:39)
If I try to run the jar file, I get the same error message.
Does anyone know how I can fix this?
Thankssorry ab the multiple post, it was urgent for me to
know the answer.
I've JDK 1.4.2 and JAccessHelper should work with 1.3
or later
Can there be some kind of path problems?No, I doubt it. It's just some internal app failure - looks like it's trying to determine the running Java version, and is not doing a good job at it. But the failure has nothing per se to Java, it's that specific app - what are we supposed to know about that app though? -
New to java(need help on access specifier)
hi! i am new to java.plzzzzz help me i have to make a project on access specifier's i know all theroy.but
i am unable to understand how i can define all specifiers practicly.i mean in a program.
thanks.plzzzzzzzz help methe most common project i can think of is a payroll system..
you can have real implementation of all the access specifiers
good luck -
Pascal to Java Please help me!
I am truobled in creating a validation method for the user loging in....
As I am perfect at Pascal can anyone translate the following pascla code to Java Please help me with this.
PROGRAM USERLOGIN;
TYPE
USER_TYPE = RECORD
USERNAME : STRING[15];
PASSWORD : STRING[15];
END;
USFILE = FILE OF USER_TYPE;
VAR
USER: USER_TYPE;
CKUSER: USER_TYPE;
RECFILE : USFILE;
I,J : INTEGER;
BEGIN
WRITE('ENTER USERNAME:');READLN(CKUSER.USERNAME);
WRITE('ENTER PASSWORD:');READLN(CKUSER.PASSWORD);
FILESPEC :='USERFILE.USR';
ASSIGN(RECFILE, FILESPEC);
RESET(RECFILE);
WHILE NOT EOF(RECFILE) DO
BEGIN
READ(RECFILE, USER);
IF CKUSER.USERNAME = USER.USERNAME AND CKUSER.PASSWORD = USER.PASSWORD THEN
LOGIN
ELSE
WRITE('USER NOT FOUND');
END;
END.Thank youDon't bother:
http://forum.java.sun.com/thread.jsp?forum=54&thread=539277 -
Java code help needed for If-elseif statement
HI All,
Apologies for posting such a trivial thing but I am a novice in Java.
All I need is to code an If elseIF statement.
I tried the code below
String w = "SAPA";
String x = "SAPB";
if (a==w) ;
{Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP");}
else if (a==x)
{ Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP_ECQ"); }
It came back with the error
Source code has syntax error: D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map695b77619ad011dd8d0b001a4b52813a/source/com/sap/xi/tf/_MM_TRANSMISSION_CHECK_TO_GENIUS_.java:324: 'else' without 'if' else if (a==x) ^ 1 error
Appreciate if you could let me know the correct code.
Many thanks
ShirinHI Aamir,
After I removed the semi-colon iIt came back with the following error
Source code has syntax error: D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map1d9b43e09ad111dd84b7001a4b52813a/source/com/sap/xi/tf/_MM_TRANSMISSION_CHECK_TO_GENIUS_.java:328: cannot resolve symbol symbol : variable channel location: class com.sap.xi.tf._MM_TRANSMISSION_CHECK_TO_GENIUS_ accessor = LookupService.getRfcAccessor(channel); ^ 1 error
Just for reference my entire Jave UDF looks like this:
//write your code here
String w = "SAPA";
String x = "SAPB";
String content = "";
MappingTrace importanttrace;
importanttrace = container.getTrace() ;
//Filling the string with our RFC-XML (With Values)
String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZIFMS_GET_NEXT_NUMBER xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_NR_RANGE_NR>01</I_NR_RANGE_NR><I_OBJECT>ZIFMS_INT</I_OBJECT></ns0:ZIFMS_GET_NEXT_NUMBER>";
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
//1. Determine a channel (Business System, Communication channel)
if (a==w)
{Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP");}
else if (a==x)
{ Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP_ECQ"); }
//2. Get a RFC accesor for a channel.
accessor = LookupService.getRfcAccessor(channel);
//3. Create a xml input stream representing the FM request message.
InputStream inputstream = new ByteArrayInputStream(m.getBytes());
//4. Create xml Payload
XmlPayload payload = LookupService.getXmlPayload(inputstream);
//5. Execute Lookup
Payload result = accessor.call(payload);
InputStream in = result.getContent();
//This are the extra step which i dont know what it mean
//out = new ByteArrayOutputStream(1024);
//byte[] buffer = new byte1024;
//for (int read = in.read(buffer); read > 0; read = in.read(buffer))
//out.write(buffer,0,read);
//content = out.toString();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList list = document.getElementsByTagName( "E_NUMBER" );
Node node = list.item(0);
if (node != null)
node = node.getFirstChild();
if (node != null)
content = node.getNodeValue();
} catch (Exception e) {
importanttrace.addWarning("Error while closing accesor" + e.getMessage());
catch (LookupException e)
importanttrace.addWarning("Error While lookup" + e.getMessage());
//This exception is not to be catch at this step as there is no try step before this
//catch (IOException e)
//importanttrace.addWarning("Error" + e.getMessage());
finally
if(out!=null)
try{
out.close();
} catch (IOException e) {
importanttrace.addWarning("Error while closing system" + e.getMessage());
//7. close the accessor in order to free resources
if (accessor!=null) {
try{
accessor.close();
} catch (Exception e) {
importanttrace.addWarning("Error while closing accesor" + e.getMessage());
return content; -
How I can enable Java ssv helper plugin silently for win7 users with IE9
here is what happens:
when I deploy java 7.21 on win7 users, after deployment when users try to Open their IE they get a login screen and apparently it is related to Java ssv helper plugin. it is trying to enable it and needs admin account/password. I am trying to deploy this to about 3000 computers and I dont want all of them start calling helpdesk for this.
your help is appreciated.The following article describes how to create a shared preference file. You can either create preferences that individual users can override, or create locked preferences that individual users cannot override.
http://kb.mozillazine.org/Lock_Prefs
(Note: I don't have any personal experience with these files, but another volunteer might post some additional tips and tricks.) -
Mapping Help Needed - Message or Java UDF
Hello Gurus,
I have a source structure as below.
Idoc
-group_a (0 to 99999)
-- sub_groupa_1 (0 to 99999)
sga1_field_1
sga1_field_2
-- sub_groupa_2
sga2_field_1
sga2_field_2
-- sub_groupa_n
sgan_field_1
sgan_field_2
-group_n
-- sub_groupn_1
sgn1_field_1
sgn1_field_2
-- sub_groupn_2
sgn2_field_1
sgn2_field_2
-- sub_groupn_n
sgnn_field_1
sgnn_field_2
every group creates an output group (lineitem), that works fine
now my requirement is as below
a particular output field (per output group) = sum (sub_field_2s) wherever sub_field_1s = first occurence of sub_fld_1 of the corresponding group
I tried different things, but could not get the required results.
pls let me know if my explanation is not clear..
Please help..
thanks
KnowledgeQuest.Hi,
Please provide your source and target structure...Also, if possible, please provide sample inputs/outputs so that we can visualize your problem correctly.
hope this helps, -
Java.io.File give incorrect chinese filenam when using javaw.exe
I am running Chinese Win2000 Pro (SP2) with jre1.3.1 installed. If I use javaw.exe to run my application, java.io.File does not give the correct filename for chinese filename when I use it to run through a directory, though all English filenames show correctly.
When the same program is run by java.exe instead of javaw.exe, the program runs with no problem and all chinese name are obtained successfully from java.io.File. Does anyone know the reason behind this ?
I need to use javaw.exe since I am invoking Java from VC++. I don't want a black command prompt window to pop up behind my java application. Please help.Hi,
I am sorry for not replying to ur query. Infact I am facing my own problem and after reading your problem I thought you could help me out in it because you are already successful in invoking java from VC++.
My problem is that I want to invoke java class from VC++ in such a way that I want to capture the stdout of java class that I invoke from VC++ and use it in VC++. Let me explain first thing first. I am not able to invoke java class from withing vc++. I have looked at JNI help on SUN site but it is giving me lots of compilation error when I include JNI.h in my VC++ program. If you could help me out in this problem, it would be great.
Thanks in advance.
Regards
Rakesh -
** Plz help me in displaying unicode character **
Hi,
I hava a problem with the following code. Actually I want to display some arabic character with the help of unicode. Plz go through the following code.
import java.awt.*;
class Unicode extends Frame
public static void main(String args[])
Frame f = new Frame("Unicode");
f.setSize(200,200);
String str="\u0600";
TextField tf=new TextField(str);
f.add(tf);
f.setVisible(true);
I m trying to print that character on a textfield. However, this is not the requirement but for only testig purpose. I get the character '?' in the resulting textfield. plz tell me that how can I use unicode to print other languages character anywhere like on awt, swing or in html. plz reply soon . Thanks
Fahad Ahmed\u0600 is an unassigned Unicode character, so there's no way to do that. However I assume you mean you want to display Arabic characters such as \u0627, Arabic Letter Alef (ا). Then you need to find a font that can render those characters properly, and assign that font to the TextField using its setFont() method.
I notice you are using AWT, which probably means you are trying to do this in an applet. If that's the case then "find a font and use it" is going to be a big problem, because you don't know what fonts your clients' computers have available.
Maybe you are looking for
-
i hooked up my powerbook through my tv, and it works, i watched quicktime files on the tv. I was wondering if their is a way so that when i edit with final cut pro, i can have the canvas window displayed on the tv. there is probably some setting that
-
Hello! I just updated to Maverick (really late I know) and I found that I really dislike the new options for the touchpad. My question is the following: Is is possible to change it back to the old options while keeping the new OS? Hope you can help m
-
MBAir inconsistent display detection
Greetings, Apple Support, Using a brand new MacBook air with a relatively new - purchased new but slightly old - Vizio 24" monitor. At first it worked fine, and then after leaving with my machine and coming back to use the display again it simply wou
-
Continuous CTIOS silent monitoring
Hi, We recently upgraded UCCE from v8.0 to v9.0 Before the upgrade, we were using CTIOS based silent monitoring. The supervisor would pick an agent and listen to him continuously over several calls in a single silent monitoring session. The session w
-
Pick the message without recordsetstructure,*
Hi all, I want pick the message from sender without specifing in the field Recordset structure as Recordset,* in fcc 2 file scenario ex: we are mentioning in recordset structure as row,* then receiver picking all fields data. but i want select the al