Skip to Content
Author's profile photo Kiran Kumar Valluru

How to Create and Trigger Class Based Workflow from Web Dynpro ABAP – Part 4

How to create and trigger class based workflow – Part 3 Continue..

Now go to Methods tab of Main View and Double click on ONACTIONREGISTER Method.

/wp-content/uploads/2012/03/54_83764.jpg

Enter below Code in OnActionRegister Event.

ONACTIONREGISTER

method ONACTIONREGISTER .

* Data Declaration for Employee Node
DATA lo_nd_employee TYPE REF TO if_wd_context_node.
DATA lo_el_employee TYPE REF TO if_wd_context_element.
DATA ls_employee TYPE wd_this->Element_employee.
DATA lv_emp_id TYPE wd_this->Element_employee-emp_id.

*  Data Declaration for Class

DATA lr_wf_demo TYPE REF TO ZCL_WF_DEMO.

*   Data Declaration for Message Manager
DATA lo_api_controller     type ref to if_wd_controller.
DATA lo_message_manager    type ref to if_wd_message_manager.

*   navigate from <CONTEXT> to <EMPLOYEE> via lead selection
lo_nd_employee = wd_context->get_child_node( name = wd_this->wdctx_employee ).

*   get element via lead selection
lo_el_employee = lo_nd_employee->get_element( ).

*   getting Employee ID
lo_el_employee->get_attribute(
EXPORTING
name = 
`EMP_ID`
IMPORTING
value = lv_emp_id ).

*   Trigger Workflow

CREATE OBJECT lr_wf_demo.

lr_wf_demo->register_employee( exporting i_empid = lv_emp_id ).

  IF sy-subrc = 0.
*     Get Message Manager
lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = lo_message_manager.

*    report message
CALL METHOD lo_message_manager->REPORT_SUCCESS
EXPORTING
MESSAGE_TEXT =
‘Registered Successfully..’.

ENDIF.

endmethod.

( Refer How to create and trigger class based workflow – part 1 for quick code reference of class zcl_wf_demo )

Step 3: Create Application.

Save and Activate the Web Dynpro Component.  Create the Web Dynpro Application and Save it.

/wp-content/uploads/2012/03/55_83771.jpg

Enter description and Click on Ok.

/wp-content/uploads/2012/03/56_83772.jpg

Save the Web Dynpro ABAP Application.

Result

Right Click on the Web Dynpro ABAP Application and click on Test.

/wp-content/uploads/2012/03/57_83773.jpg

Enter Employee ID and Click on Register.

/wp-content/uploads/2012/03/58_83774.jpg

Now we can see the success message.

/wp-content/uploads/2012/03/59_83775.jpg

Now go to SBWP Transaction and Click on Inbox.

/wp-content/uploads/2012/03/60_83776.jpg

Conclusion

Here I demonstrated a simple Web Dynpro ABAP Application which triggers Workflow. This helps to create ABAP Class, Workflow and Triggering Workflow from Web Dynpro ABAP as per Our Requirements.


Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Very Nice..

      Author's profile photo Former Member
      Former Member

      Good Work.....Very helpful

      Author's profile photo Former Member
      Former Member

      nice documents...very helpful to me...

      Author's profile photo Former Member
      Former Member

      Verry Nice Thank You,

      i think i can need this...

      Author's profile photo Former Member
      Former Member

      Hello,

      First of all thanks for such valuable info its really appriciable.

      I did it step by step as shown in sceen shot but unfortunately it did not work

      in my case .

      For more clarification of my problem i have attached sceen shots.

      Please help to sort out my problem.

      Regards

      Kumar.

      1)

      2)

      3)

      4)

      5)

      6)

      Author's profile photo Former Member
      Former Member

      Hello,

      I am waiting for response if somebody help me out.

      Thanks & Regards

      Kumar

      Author's profile photo Wei Zhu
      Wei Zhu

      HI Kumar,

      Please  debug your register_employee method and check the emmp_id have correct transport into the workflow class.

      Author's profile photo Hicham KHALLOUKI
      Hicham KHALLOUKI

      Hi Kumar,

      Try to change the level of method GET_EMPNAME to Static Method

      Regards

      Author's profile photo Perinba Rani Maniraj
      Perinba Rani Maniraj

      Hi Kiran Kumar,

      Kiran Kumar Valluru

      I have got a question. Im doing custom workflow for SAP SRM ROS process. I have a workflow class as you mentioned, workflow template design as you mentioned, now i do want to trigger this workflow from a standard sap class (once after Save – Business partner). So can we implement the same webdynpro workflow trigger code to the post exit of the sap standard class?

      Appreciating your help!

       

      Thanks,

      Rani.

       

      Author's profile photo Kiran Kumar Valluru
      Kiran Kumar Valluru
      Blog Post Author

      Hello,

       

      All you have to do is to raise the event as described in https://blogs.sap.com/2012/03/17/how-to-create-and-trigger-class-based-workflow-from-web-dynpro-abap-part-1/ (either OO event or the Function module mentioned).

       

      Furthermore, use discussions section to get quick responses from fellow members.

       

      Regards,

      Kiran