Skip to Content

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.


To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Suresh Kumar

    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)

    (0) 

Leave a Reply