cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Fields in RFC call in UDF

Former Member
0 Kudos

In my Message Mapping I am calling a RFC using a UDF, this works fine but only for 1 field. Like in my BAPI I have 1 Field in the Input parameters. Does anyone know how to import more than 1 parameter? Here is some sample code from my UDF:

Calling the RFC, I specify this: <?xml version=\"1.0\" encoding=\"UTF-8\"?><p2:ZTEST xmlns:p2=\"urn:sap-com:document:sap:rfc:functions\"><INPUT_VALUE>4500014790</INPUT_VALUE></p2:ZTEST>

Where ZTEST is my BAPI name and INPUT_Value is my import parameter. My question is how would I specify more than 1 import parameter in my xml string? I tried <INPUT_VALUE1>4500014790</INPUT_VALUE1><INPUT_VALUE2>33</INPUT_VALUE3> but then it does not return anything..


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\"?><p2:ZTEST xmlns:p2=\"urn:sap-com:document:sap:rfc:functions\"><INPUT_VALUE>4500014790</INPUT_VALUE></p2:ZTEST>";
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
{
// 1. Determine a channel (Business system, Communication channel)
Channel channel = LookupService.getChannel("ECDCLNT999","CC_ECD999_RFC");
// 2. Get a RFC accessor for a channel.
accessor = LookupService.getRfcAccessor(channel);
// 3. Create a xml input stream representing the function module 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();
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);
}
content = out.toString();

}
catch(LookupException e)
{
importanttrace.addWarning("Error while lookup " + e.getMessage() );
}
catch(IOException e)
{
importanttrace.addWarning("Error " + e.getMessage() );
}
finally
{
if (out!=null) {
try {
out.close();
} catch (IOException e) {
importanttrace.addWarning("Error while closing stream " + e.getMessage() );
}
}
// 7. close the accessor in order to free resources.
if (accessor!=null) {
try {
accessor.close();
} catch (LookupException e) {
importanttrace.addWarning("Error while closing accessor " + e.getMessage() );
}
}
}

//returning the result u2013 RFC-XML.response
return content;

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member569226
Participant
0 Kudos

Hi Jan de Lange ,

Can you send the UDF code for the above. Even I was having the same problem ie., sending multiple values in the input file.

I want to send three PO numbers.

String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><p2:ZXI_GET_PO_DETAILS xmlns:p2=\"urn:sap-com:document:sap:rfc:functions\">

<PO_NUM>4500000005</PO_NUM>

<PO_NUM>4500000020</PO_NUM>

<PO_NUM>4500000021</PO_NUM></p2:ZXI_GET_PO_DETAILS>";

Best Regards

Suresh

Former Member
0 Kudos

Jan,

Check out this :

Regards,