Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Kiran_Valluru
Active Contributor
15,872

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.

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.

Enter description and Click on Ok.

Save the Web Dynpro ABAP Application.

Result

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

Enter Employee ID and Click on Register.

Now we can see the success message.

Now go to SBWP Transaction and Click on Inbox.

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.


10 Comments
Labels in this area