top of page
Writer's pictureERPGenie

Invoking a business object method from another system

Updated: Aug 5, 2019

It is rather useful to be able to call a business object method in another system much like you can call an RFC in another system. How do we do that? Here's how...


Firstly, use transaction BD97 to link the Logical system and the RFC together.


OPTION 1: Instance independent call to specified method.


In the receiving system (my example is SCM) perform the following steps:

  1. Transaction: SWO1

  2. Enter your Z object type. e.g. ZEH_DISP

  3. Add method. eg. EHList (Attributes: Dialog, Synchronous, Instance-Independent)

  4. Code: eg. call transaction '/SAPTRX/EH_LIST'.

In the sending system (my example is ECC) perform the following code:


data: w_handle type swo_objhnd.

it_container type table of swcont.


call function 'SWO_CREATE'

exporting

objtype = 'ZEH_DISP'

logical_system = 'SCM'

importing

object = w_handle

exceptions

no_remote_objects = 1

others = 2.

if sy-subrc <> 0.

message i001(z1) with 'No object created!'.

endif.


call function 'SWO_INVOKE'

exporting

object = w_handle

verb = 'EHList'

tables

container = it_container.


OPTION 2: Instance dependent call to specified method.


In the receiving system (my example is SCM) perform the following steps:

  1. Transaction: SWO1

  2. Enter your Z object type. e.g. ZEH_DISP

  3. Add method. eg. DisplayEH (Attributes: Dialog, Synchronous)

  4. Code: eg.

DATA : w_guid TYPE /saptrx/eh_hdr-eh_guid.


SELECT SINGLE eh_guid

FROM /saptrx/eh_hdr

INTO w_guid

WHERE ao_id = object-key.


CALL FUNCTION '/SAPTRX/EH_DETAILS'

EXPORTING

i_guid = w_guid.


In the sending system (my example is ECC) perform the following code:

data: w_handle type swo_objhnd.

it_container type table of swcont.


call function 'SWO_CREATE'

exporting

objtype = 'ZEH_DISP'

objkey = '0350000001000010'

logical_system = 'SCM'

importing

object = w_handle

exceptions

no_remote_objects = 1

others = 2.

if sy-subrc <> 0.

message i001(z1) with 'No object created!'.

endif.


call function 'SWO_INVOKE'

exporting

object = w_handle

verb = 'DisplayEH'

tables

container = it_container.


OPTION 3: Instance dependent call to default method.

  1. SWO1

  2. Enter your Z object type. e.g. ZEH_DISP

  3. Add method. eg. DisplayEH (Attributes: Dialog, Synchronous)

  4. Code: eg.

DATA : w_guid TYPE /saptrx/eh_hdr-eh_guid.


SELECT SINGLE eh_guid

FROM /saptrx/eh_hdr

INTO w_guid

WHERE ao_id = object-key.


CALL FUNCTION '/SAPTRX/EH_DETAILS'

EXPORTING

i_guid = w_guid.


In the sending system (my example is ECC) perform the following code:

data: w_handle type swo_objhnd.

it_container type table of swcont.


call function 'SWO_CREATE'

exporting

objtype = 'ZEH_DISP'

objkey = '0350000001000010'

logical_system = 'SCM'

importing

object = w_handle

exceptions

no_remote_objects = 1

others = 2.

if sy-subrc <> 0.

message i001(z1) with 'No object created!'.

endif.


call function 'SWO_INVOKE'

exporting

object = w_handle

* verb = 'DisplayEH'

tables

container = it_container.

72 views0 comments

Comments


bottom of page