cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass an array to JCo

nicola_martella2
Participant
0 Kudos

Hi,

I've a jco that invokes an RFC.

I need to pass an array as parameter to the RFC.

The RFC signature is

*"----------------------------------------------------------------------
*"*"Interfaccia locale:
*"  IMPORTING
*"     VALUE(OPCODE) LIKE  ZZXI_NODI-OPCODE
*"  EXPORTING
*"     VALUE(RESULT) LIKE  ZZXI_NODI-ZRESULT
*"  TABLES
*"      EXPORT STRUCTURE  ZZXI_NODI OPTIONAL
*"      ZGUID STRUCTURE  ZZXI_GUID
*"  EXCEPTIONS
*"      EXCEPTION
*"----------------------------------------------------------------------

and I would supply in input from jco the ZGUID structure.

The ZGUID structure is composed only from a char(36), GUID --> ZGUID-GUID.

In my java user-defined function I have this code:

	
String b[] = {"aaaa", "bbbb"};
final String rfcxml = "<?xml version="1.0" encoding="UTF-8"?><ns0:ZZXI_TRASC_ARTICOLI_3 xmlns:ns0="urn:sap-com:document:sap:rfc:functions"><my_param_name>" + b + "</my_param_name></ns0:ZZXI_TRASC_ARTICOLI_3>";
Channel channel = LookupService.getChannel(sysId,commChannel);
accessor = LookupService.getRfcAccessor(channel);
InputStream inputStream = new ByteArrayInputStream(rfcxml.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
plResult = accessor.call(payload);

but seems that the RFC in ABAP side is not invoked.

Could be the cause the rfcxml format?

How can I pass an array as parameter for a RFC via jco?

Thank you for your attention?

Nicola

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Nicola,

to me it seems that the structure of your RFC XML is not correct. you create a tag <myparam> to pass your parameter but actually in the RFC it is called ZGIUD, so this is the name it has to have in the RFC XML as well.

To get the correct RFC XML structure you need to supply, you can import your RFC in the Repository, from where you can get the XSD of the RFC. That should help to come up with the right structure.

Also have a look at Mortens Weblog, where he shows how you can construct a RFC XML message using a DocumentBuilder. /people/morten.wittrock/blog/2006/03/30/wrapping-your-mapping-lookup-api-code-in-easy-to-use-java-classes

Regards

Christine