on 09-16-2009 10:08 AM
Hi there
I am trying to do a table lookup from XI in my message mapping by calling an remote RFC. The return values must return ALL the value for a specific column. The code I have here returns a blank value. Can someone see what my problem may be?
My variables for my UDF is:
public String UDF_RFC(String DBTABLE,String MATNR,String FIELDS,String businessSystem,String communicationChannel,Container container)
And my Code:
"My code appears to mess up my message structure, I will attach it in a responce..
Thanks,
Jan
Edited by: Jan de Lange on Sep 16, 2009 11:09 AM
Edited by: Jan de Lange on Sep 16, 2009 11:09 AM
first test you RFC function module .if it works fine then it will be better if you test your code for parsing the xml that is returned by RFC lookup in NWDS (with the expected xml
returned by RFC lookup)and then use it in message mapping
does ## use to add context change?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One of teh resons can be
if you create a UDF selecting VALUE then you can return only on string.
You have to use context while creating the UDF
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
// declare parameters
String returnValue = "";
String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZINT_XI_GET_SITES xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><LT_SITES><item><WERKS></WERKS></item></LT_SITES></ns0:ZINT_XI_GET_SITES>";
AbstractTrace trace = container.getTrace();
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
{
// 1. Determine a communication channel (Business system + Communication channel)
Channel channel = LookupService.getChannel(businessSystem,communicationChannel);
// 2. Get a RFC accessor for the channel.
accessor = LookupService.getRfcAccessor(channel);
// 3. Create an XML input stream that represents the RFC request message.
InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());
// 4. Create the XML Payload
XmlPayload payload = LookupService.getXmlPayload(inputStream);
// 5. Execute the lookup.
Payload result = null;
result = accessor.call(payload);
InputStream in = result.getContent();
// 6. Create a DOM structure from the input XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList nodelist = document.getElementsByTagName("*");
Node node;
Element element;
NamedNodeMap nnm = null;
String attrname;
String attrval;
int i, len;
len = nodelist.getLength();
for (int j=0; j < len; j++) {
element = (Element)nodelist.item(j);
System.out.println(element.getTagName() + ":");
nnm = element.getAttributes();
}
if (nnm != null) {
for (i=0; i<nnm.getLength(); i++) {
node = nnm.item(i);
attrname = node.getNodeName();
attrval = node.getNodeValue();
returnValue += attrname + " = " + attrval + "##";
}
}
// 7. To free resources, close the accessor..
if (accessor!=null) {
try {
accessor.close();
} catch (LookupException e) {
trace.addWarning("Error while closing accessor " + e.getMessage() );
}
}
} catch (Exception e) {
trace.addWarning("Error" + e);
}
// 8. return a single id value to the message mapping
return returnValue;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.