5

With ABAP construction STARTING NEW TASK I can start a separate task running independently of the current, e.g. for batch execution.

I would like to hand over an Object instance RFC functions don't accept these kind of parameters. Is there somebody out there who wanted to pass over an object instance too and found a workaround to this?

Today my workaround is to pass structured data and re-create the objects inside module, so I do the "marshalling" by hand.

Perhaps there is a nicer way to to that? Or can I run methods of object instance in a separate background task?

P.S. I am using SAP R3 4.6C

2
  • Hello Hartmut, just out of interest: Is this an evaluation version you are running or is this an actual client still using 4.6C? Commented Jul 6, 2011 at 5:44
  • this is really 4.6C - quite old but running like a charm - I don't use an evaluation version Commented Jul 6, 2011 at 15:13

3 Answers 3

7

In 4.6C, there's no solution to pass an instance to an RFC-enabled function module. It's only possible to re-instantiate it from scratch inside the function module.

But from ABAP 6.20, it's possible to serialize an instance to a STRING or XSTRING variable, by including the interface IF_SERIALIZABLE_OBJECT in the instance class, and by calling the ID transformation via CALL TRANSFORMATION, as explained in this part of the ABAP documentation:

To export objects that are referenced by reference variables, use the statement CALL_TRANSFORMATION to serialize and export these objects if the class of these objects implements the interface IF_SERIALIZABLE_OBJECT.

This way, you may pass the serialized instance to the RFC-enabled function module, via a parameter of type STRING or XSTRING.

4
  • If I remember correctly this only became available in Basis release 2004s (Was that ECC5?) But worth a shot.
    – Esti
    Commented Jul 4, 2011 at 21:01
  • I will give it a try as soon as possible - thank you for the answer! Commented Jul 6, 2011 at 15:16
  • Unfortunatelly CALL TRANSFORMATION is not available in 4.6C Commented Jul 7, 2011 at 13:58
  • I just read this answer again and though to myself: Wow, did I really write such a good answer? Then I saw it was edited by Sandra Rossi and she had basically rewritten my answer and all the good parts are hers. Thank you Sandra :-D Commented Jul 25, 2022 at 10:27
3

I realize this thread is about 5 years old so I'm doing a bit of thread necromancy here, but it still comes up in the first couple hits for "abap rfc objects" so I hope everybody forgives me.

The correct way to do this in modern ABAP is probably to use the IF_SERIALIZABLE_OBJECT interface. It will basically allow you to convert your object to an XML string, which can then be passed into the FM as an importing string parameter and deserialized back into an object in the target system.

Guide: https://rvanmil.wordpress.com/2011/05/20/serialization/

1
  • 1
    I included the part of your answer about a String parameter into mydoghasworms' answer (which already contained the important IF_SERIALIZABLE_OBJECT) Commented May 4, 2019 at 17:44
-1

I don't know if this will work in 4.6C (I am using a more recent version), but I would do the following:

i) Create a structure via SE11.
ii) The components(fields) of the structure should support the TYPE REF TO option. That means, you should be able to specify a class name here.
iii) Pass in the structure (that you have just created) to the RFC.

Hope that works in 4.6C.

2
  • 1
    Hey Guven I really wished that that would work, but it didn't. +1 for the willingness....
    – Jordão
    Commented Oct 26, 2016 at 18:53
  • Not true, reference types even inside structures are still not allowed in RFC modules, just checked on latest 7.52 system
    – Suncatcher
    Commented Apr 7, 2020 at 13:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.