转 Call instance method from workflow using class

Call instance method from workflow using class

By Rakesh Dhudipala from Link

Scenario:

Below document explains how to call instance Method from Workflow task  

Prerequisites:

ABAP objects  

Step by step Procedure:  

Go to SE24, create a class by name ZCL_TEST_WORKFLOW.  

转 Call instance method from workflow using class

Implement interface IF_WORKFLOW in the class.

转 Call instance method from workflow using class

Create one instance method called GET_RESULT

转 Call instance method from workflow using class

Define below attributes in the Attributes TAB

转 Call instance method from workflow using class

Create below methods in the methods tab.

转 Call instance method from workflow using class

1)     Constructor:

Define with below parameters.

转 Call instance method from workflow using class

In the 'Constructor' write the below code.

method CONSTRUCTOR.

  m_lpor-INSTID = i_id.
  m_lpor-CATID = 'CL'.
  m_lpor-TYPEID = 'ZCL_TEST_WORKFLOW'.
endmethod.

2)     GET_RESULT:

Method contains below parameters.

转 Call instance method from workflow using class 

Write the below code in the GET_RESULT method.

method GET_RESULT.
  p3 = p1 * p2.
endmethod.  

3)    Create:

Create method contains below parameters.

Write the below logic in the CREATE method.

method CREATE.
  CREATE OBJECT e_instance
    TYPE
      zcl_test_workflow
    EXPORTING
      i_id              = i_id.
endmethod.

In BI_PERSISTENT~FIND_BY_LPOR interface method write the below code

method BI_PERSISTENT~FIND_BY_LPOR.
  CREATE OBJECT result
    TYPE
      zcl_test_workflow
    EXPORTING
      i_id              = lpor-instid(10).
endmethod.

In the BI_PERSISTENT~LPOR method write the below code

method BI_PERSISTENT~LPOR.
  result = me->M_Lpor.
endmethod.

Go to SWDD transaction and create new workflow.  

转 Call instance method from workflow using class

Create new activity  

转 Call instance method from workflow using class

Create new task and enter the CREATE method

转 Call instance method from workflow using class
This will map the below parameters  

转 Call instance method from workflow using class

Create one more task and enter the get_result method in the task like below  

转 Call instance method from workflow using class

 

Now container mapping with the below parameters

转 Call instance method from workflow using class

Assign the agents to the task  

转 Call instance method from workflow using class 

Make task as general task

转 Call instance method from workflow using class

Now if we run the workflow it will executes the instance method.

相关推荐