Search code examples
abapsaprfcbapifunction-module

Pass object instances to RFC function modules


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


Solution

  • 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.