Show TOC

Procedure documentationCreating Custom Web Dynpro Screen Components


You can integrate a custom view (Web Dynpro screen component) in a step of your guided procedure. To do so, implement a component controller.

Recommendation Recommendation

If you have multiple activities with different views, create these views under the same component controller.

End of the recommendation.


You are familiar with the Web Dynpro tools in the ABAP Workbench (SE80).


Creating a component controller

Create a component controller which implements the interface WD_IF_SISE_STEP.

By default, the component controller contains the following:

  • the W_MAIN window

  • the following methods of the interface controller:

    • IS_SAVE_ENABLED: to enable/disable the Save and Reset pushbuttons in the toolbar

    • SAVE: to save the changes made on the screen

    • SET_CHANGE_MODE: to set the mode to Edit or Read only

  • the REFRESH_LOG event: This event can be triggered when the log table in the view must be refreshed.

    You can use the following optional parameters:

    • To refresh the log of all activities in a step: R_STEP

    • To refresh the log of an activity only: R_ACTIVITY

    The type of the parameters is class CL_SISE_STEP_ABS.

  • the READ_ONLY context element for the mode control.

Creating a view
  1. Ensure that the view contains a reference to the activity performed in the view. The context attribute must be of type ref to the type of the class that implements the activity.

    This context attribute is instantiated by the framework by calling this view using outbound plugs. Via this context attribute, any method that is implemented in the activity class can be called.

    An implementation of a default plug as the entry point of the view is shown in the following code example:

    Syntax Syntax

    2.  DATA LR_EX         TYPE REF TO CX_ROOT.
    3.  TRY.
    4.   * Set corresponding activity object as attribute
    8.  ENDTRY.
    End of the code.
  2. To bind the context node MODE_CONROL to the corresponding context node of the component controller, drag from the component controller to the view.

  3. To create the UI elements of the view, for any UI element that is to act at the action edit/read only, bind the Enabled property to the inverted READ_ONLY attribute. To do so, in the Define Content Binding dialog box, select the Invert Attribute/Property checkbox.

  4. Implement the coding on the view level, for example the actions when pushbuttons are pressed.

    1. Implement the activity.

      An implementation of the CHECK_SAPOSS connection test is shown in the following code example:

      Syntax Syntax

      1. method ONACTIONCHECK_RFC .
      2.  TRY.
      4. 	  CATCH CX_SISE_LOG .
      5. 		CATCH CX_SISE_MODEL .
      6. 	 ENDTRY.
      7. 	 WD_THIS->REFRESH_LOG( ).
      8. endmethod.
      End of the code.
    2. To send the REFRESH_LOG event to the framework and refresh the log table for the requested step or activity, use an implementation of the refresh_log method:

      Syntax Syntax

      1. METHOD refresh_log .
      2. 		WD_COMP_CONTROLLER->fire_refresh_log_evt(
      3. 				r_step = wd_comp_controller->gr_step
      4. 				r_activity = WD_COMP_CONTROLLER->GR_ACTIVITY
      5. 		).
      6. ENDMETHOD.
      End of the code.
Implementing component controller methods

You can implement the following methods on the level of the component controller:

  • To enable or disable the Save pushbutton in a view and save the view, use the GET_SAVE_VISIBILITY method. This is useful, for example, to control steps independently if they are in the same component controller.

    Syntax Syntax

    1. method IS_SAVE_ENABLED.
    2. CASE iv_name_of_view.  
    3.  WHEN 'MAIN_VIEW'.   
    4. 	 rv_enabled = abap_true.
      	WHEN OTHERS.    
    5. 	 rv_visibility = abap_false.
    6.  ENDCASE.
    7. endmethod.
    End of the code.
  • To save information, use the SAVE method. This allows save events to be triggered and handled in a view.

    For more information about implementing the SAVE method in a view, see, for example, the WD_SISE_CUSTOM_AGS Web Dynpro component.

  • To update the UI according to the Change/Display mode context attribute, use the SET_CHANGE_MODE method.

    Syntax Syntax

    1. method SET_CHANGE_MODE .
    2. 	DATA:lo_nd_mode_control TYPE REF TO if_wd_context_node,
      			 lo_el_mode_control TYPE REF TO if_wd_context_element.
    3.  	DATA:lv_display_mode TYPE oax.
    4. 	     lo_nd_mode_control = wd_context->get_child_node( name = wd_this->wdctx_mode_control ).
    5.  		lo_el_mode_control = lo_nd_mode_control->get_element( ).
    6. 		lo_el_mode_control->set_attribute( name  = `READ_ONLY` VALUE = iv_read_only ).
    7. endmethod.
    End of the code.
  • Recommended: To implement exception handling, implement the following methods at the level of the component controller of your custom view:

    • SHOW_MSG


    For an implementation example, see the WD_SISE_CUSTOM_AGS Web Dynpro component controller.

Integrating the component controller in the used components table
  1. To create an outbound plug with a navigation link to the default inbound plug of the view, in the Defining the Component of Target View field, select the view to which to navigate.

  2. Adapt the default method of the view so that the correct outbound plug is called depending on the view that is to be displayed.

    Syntax Syntax

    1. method HANDLEDEFAULT .
    2. *SET global name OF view
    3.  	wd_comp_controller->gr_step ?= r_step.
    4. 	wd_comp_controller->gv_name_of_view = v_name_of_view.
    5. 	CASE v_name_of_view.
    6. 	WHEN 'MAIN_VIEW'.
    7. 		wd_this->FIRE_TO_MAIN_VIEW_PLG( ).
    8. 	WHEN OTHERS.
    9. 		"Nothing
    10. 	ENDCASE.
    11. endmethod.
    End of the code.
  3. For the view, do the following:

    1. To implement the inbound plug and ensure that the correct instance of the activity class is created, set the activity object as attribute.

    2. To display an error message if an error during creation of the instance occurs, implement error handling.

    Syntax Syntax

    1. method HANDLEDEFAULT .
    2.  DATA lr_ex         TYPE REF TO cx_root.
    3.  TRY.
    4. 	 * Set corresponding activity object as attribute
    5. 	 wd_this->ar_activity ?= wd_comp_controller->gr_step->get_activity( zcs_sise_act_custom_RFC=>C_CHECK_RFC ).
    6.   * Implement error handling
    7.   CATCH cx_sise_model INTO lr_ex.
    8. 		wd_comp_controller->show_message( ir_exception = lr_ex ).
    9.  ENDTRY.
    10. endmethod.
    End of the code.

More Information

For more information about integrating the custom Web Dynpro screen component into a step of your guided procedure, see Maintaining and Activating a Guided Procedure.