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

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Hartmut Pfarr
  • 5,534
  • 5
  • 36
  • 42

3 Answers3

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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
mydoghasworms
  • 18,233
  • 11
  • 61
  • 95
  • If I remember correctly this only became available in Basis release 2004s (Was that ECC5?) But worth a shot. – Esti Jul 04 '11 at 21:01
  • I will give it a try as soon as possible - thank you for the answer! – Hartmut Pfarr Jul 06 '11 at 15:16
  • Unfortunatelly CALL TRANSFORMATION is *not* available in 4.6C – Hartmut Pfarr Jul 07 '11 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 – mydoghasworms Jul 25 '22 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/

Erik Grant
  • 49
  • 3
  • 1
    I included the part of your answer about a `String` parameter into mydoghasworms' answer (which already contained the important `IF_SERIALIZABLE_OBJECT`) – Sandra Rossi May 04 '19 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.

Guven
  • 2,280
  • 2
  • 20
  • 34
  • 1
    Hey Guven I really wished that that would work, but it didn't. +1 for the willingness.... – Jordão Oct 26 '16 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 Apr 07 '20 at 13:08