Show TOC

Calls with References to the Logical SystemLocate this document in the navigation structure

Example

HR forwards payroll results to Accounting. Here the appropriate documents are posted. Each document in Accounting has a reference to the source document in HR. The logical system in which the HR document was created is included in the reference.

The method to be called is named, for example, HRDoc.Display. Field BKPF-AWREF contains the ID of the reference document in HR and field BKPF-AWSYS contains the name of the logical system.

The source code below shows how the HR document display is called from the document display in Accounting:

...
DATA:
  HEAD LIKE BKPF,
  RETURN LIKE BAPIRET2,
  SERVER_DEST LIKE TBLSYSDEST-RFCDEST,
  MSG_TXT(80) TYPE C.
...
* get RFC-Destination for remote method call
CALL FUNCTION 'OBJ_METHOD_GET_RFC_DESTINATION'
  EXPORTING
    OBJECT_TYPE                   = 'HRDOC'
    METHOD                        = 'DISPLAY'
    LOGICAL_SYSTEM                = HEAD-AWSYS
  IMPORTING
    RFC_DESTINATION               = SERVER_DEST
  EXCEPTIONS
    NO_RFC_DESTINATION_MAINTAINED = 1
    ERROR_READING_METHOD_PROPS    = 2
    OTHERS                        = 3.
IF SY-SUBRC <> 0.
  IF SY-SUBRC = 1.
* application specific message saying document can't be displayed
   ...
  ELSE. 
*   hard error
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDIF.
* call display function. If SERVER_DEST is initial, it's a local call.
CALL FUNCTION 'BAPI_HRDOC_DISPLAY'
  DESTINATION SERVER_DEST
  EXPORTING
    DOCUMENT_ID = HEAD-AWREF
  IMPORTING
    RETURN = RETURN
  EXCEPTIONS
    COMMUNICATION_FAILURE = 1 MESSAGE MSG_TXT
    SYSTEM_FAILURE        = 2 MESSAGE MSG_TXT.
IF SY-SUBRC <> 0.
* handle remote exceptions
  MESSAGE E777(B1) WITH 
    'HRDoc.Display' HEAD-AWSYS HEADER-AWSYS 
    MSG_TXT(50) MSG_TXT+50(30).
ELSEIF NOT RETURN-TYPE IS INITIAL.
* handle return parameter
 ...
ENDIF.

         

The message B1 777 is a generic message. An application-specific message could be used instead.