Show TOC

Importing the Leading ObjectLocate this document in the navigation structure

Use

You can use this function to establish the object processed by the work item. You must establish the object if you want to:

  • Display the attributes of the object on your tab page

  • Establish other data from your application via the object and its attributes

  • Offer the object's methods as functions on your tab page

Prerequisites

You must know the definition of the object type with its attributes and methods in order to be able to access it.

Insert the include <cntn01> in the TOP include of your module pool to make the macro instructions for processing containers and objects available:

include <cntn01>.
         
Features

To read the leading object of the work item, use the function module SAP_WAPI_GET_OBJECTS from the SAP WAPI interface. All the released function modules of this interface are in the function group SWRC.

This function module returns the (persistent) object reference to the leading object of the work item, in addition to other information, in its export parameter LEADING_OBJECT. You must convert this object reference into a runtime handle for further evaluation.

Example

If the leading object of your work item is of the type FORMABSENC (notification of absence), use the function module as follows in a PBO module:


DATA:
   l_absenceform LIKE swr_object,
   l_runtime     TYPE swc_object,
   l_object      LIKE swotobjid.
[...]
*- ask frame dynpro for the ID of workitem

CLEAR g_wi_id.
swl_widisp_get_wi_id g_wi_id.

CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'
   EXPORTING
      workitem_id    = g_wi_id
   IMPORTING
      leading_object = l_absenceform.

CLEAR l_runtime.
CLEAR l_object.
MOVE l_absenceform-object_id TO l_object.

*- convert to runtime handle
swc_object_from_persistent l_object l_runtime.

*- out of the object we can get the data we want to show
swc_get_property l_runtime 'PersonnelNo' swl0attr-pernr.
         

If you want to implement a method call as a function in a PAI module, use the function module as follows:


DATA:
   l_absenceform LIKE swr_object,
   l_runtime     TYPE swc_object,
   l_object      LIKE swotobjid.
swc_container l_container.

CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'
   EXPORTING
      workitem_id    = g_wi_id
   IMPORTING
      leading_object = l_absenceform.

*- we show the absence form via it's display method...
CLEAR l_runtime.
CLEAR l_object.
MOVE l_absenceform-object_id TO l_object. 

*- convert to runtime handle
swc_object_from_persistent l_object l_runtime. 
*- call method
swc_call_method_async l_runtime 'Display' l_container.