on 09-07-2010 11:47 AM
Hi ,,
I am trying to work on a scenario , in which RFC LOOKUP ( UDF) VerSION 7.0 is Implemented referencing Some Blog.
Now the Response of RFC LOOKUP is XML Structure , Which I Need to parse ....
But How thats i want know ?????????????
I know For This I need DOM / SAX Parsar..
Now My question is Can I directly Write UDF for This ..or this is Some other way ...?????????????????/
as i know for DOM ........org.w3c.dom this package is reqd.......Is this already present in SAP 7.0 ..
or i have to deploye some jar files for this ...if yes then where ??????????????????
we are on Java JDK version 1.4.4
Please Guide me ,,,,
Regards
Prabhat
Solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prabhat ,
Could you let me know how this was resolved ?
Did you use the code snippet proviede by Swetha ?
I am not understanding the following part of code
int Start_Index , End_Index ;
Start_Index = out.toString().indexOf("<E_Result>") + 10; ///E_Result is field name in RFC response, 10 is length of //<E_Result>,fieldname including angle brackets.Other XML fields can be accessed in similar way
End_Index = Start_Index + 2; ///length of field in response XML instead of 2
String result = out.toString().substring(Start_Index , End_Index);
How would the String ''result'' will have the values for E_Result.
Thanks,
C
Hello Collins,
Sorry for the late reply.
int Start_Index , End_Index ;
Start_Index = out.toString().indexOf("<E_Result>") + 10; ///E_Result is field name in RFC response, 10 is length of //<E_Result>,fieldname including angle brackets.Other XML fields can be accessed in similar way
End_Index = Start_Index + 2; ///length of field in response XML instead of 2
String result = out.toString().substring(Start_Index , End_Index);
out would contain RFC response in XML format. so it should have <E_Result>10</E_Result>
In my case,output is 2 digits ex.10
So,start index would be index of XML tag <E_Result> plus length of this tag which is 10
and end index should be 2 added to this start index as length of output is 2.
I am just extracting this value from Response XML using standard string operations.
Please let us know if you still have doubts.
Thanks.
Regards,
Shweta
Solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Prabhat,
You can do this using following UDF:
java.io.;com.sap.aii.mapping.lookup.; //Imports section
public String getValue(String arg1,String arg2,String arg3,Container container){
try{
Channel channel = LookupService.getChannel("ABCCLNT010","CC_RFC_Receiver"); //Create an RFC receiver //CC_RFC_Receiver to connect to R/3 system ABCCLNT010
RfcAccessor accessor = LookupService.getRfcAccessor(channel);
String rfcxml ="<ns0:Z_RFC xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">" +
" <I_arg1>" + arg1 + "</I_arg1>" + // I_arg1.,etc..import parameters to RFC Z_RFC
" <I_arg2>" + arg2 + "</I_arg2>" +
" <I_arg3>" + arg3 + "</I_arg3>" +
"</ns0:Z_RFC> " ;
InputStream inputStream =new ByteArrayInputStream(rfcxml.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
Payload rfcOutPayload = accessor.call(payload);
InputStream in = rfcOutPayload.getContent();
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
for (int read = in.read(buffer); read > 0; read = in.read(buffer)) {
out.write(buffer, 0, read);
}
String content = out.toString();
int Start_Index , End_Index ;
Start_Index = out.toString().indexOf("<E_Result>") + 10; ///E_Result is field name in RFC response, 10 is length of //<E_Result>,fieldname including angle brackets.Other XML fields can be accessed in similar way
End_Index = Start_Index + 2; ///length of field in response XML instead of 2
String result = out.toString().substring(Start_Index , End_Index);
return result;
}
catch(Exception e)
{
throw new RuntimeException("Error message"+e)
}
Let us know if this helps.
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.