Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Applies to:

SAP ECC 6.0, SAP Netweaver 2007 and above.

Summary

Assistance Class in WD is used for storing common reusable logic apart from component controller. It can also be used to store Text Symbols for displaying messages or labels for the WD application. This is a sample program to pass data between views using assistance class.

Author:  Shaira Madhu

   
Company:     Applexus Technologies Private Ltd.
Created on:    24 November 2011
Author Bio
Shaira Madhu is working as SAP Technology Consultant with Applexus Technologies Private Ltd.

Assistance Class

Assistance Class in WD is used for storing common reusable logic apart from component controller. It can also be used to store Text Symbols for displaying messages or labels for the WD application
For each Web Dynpro component, you can create a uniquely assigned assistance class. This class should inherit from the abstract class CL_WD_COMPONENT_ASSISTANCE.The assistance class of a component provides the following advantages:
● You can store coding there that is required within the component, but is not linked directly with the layout or with the function of a controller. This could be, for example, a call of the application layer or UI-based editing of the data.
● The second important function of the assistance class is the management of dynamic texts. Texts that are combined at runtime only and/or contain variables can be stored in the text pool of the assistance class as text symbols.

data: my_text type string.
my_text = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( KEY = ‘001’ ).

Method calls of the assistance class are much better from a performance point of view than calls of methods of a Web Dynpro controller.
The assistance class is automatically instantiated when a component is called. The instance is available to each controller of the component through the attribute WD_ASSIST. Whenever we enter the assistance class , an attribute WD_ASSIST will be created in all views , windows and component controller under Attribute tab.
As a rule, every ABAP class can serve as an assistance class; however, the services integrated in the Web Dynpro framework are available only if the assistance class is derived from the class CL_WD_COMPONENT_ASSISTANCE. . The super class CL_WD_COMPONENT_ASSISTANCE have a public method IF_WD_COMPONENT_ASSISTANCE~GET_TEXT which will be inherited to the subclass.

This is a sample program shows how an assistance class can be used to pass data between views without context mapping.

Scenario.

Create a web Dynpro component with the following details

Create one more view.

Select the MAIN view and create an attribute ‘CARRID’ as given in below screen shot.

Select the DETAILS view and create a node for SCARR with cardinality 1:1 .

Add attributes in the node ‘SCARR’ using Wizard.

In MAIN view create OutboundPlug ‘TO_DETAILS’. This will be used to navigate to DETALIS view.

Select the DETAILS view and create an inboundPlug ‘FROM_MAIN’,

Come to the Layout tab of the MAIN view. Create InputField for the CARRID under RootElementContainer.
Bind this UI element to the CARRID. Create a Label for the InputField.

Create a Button .Create an action with the following details.

In DETAILS view select RootelementContainet under layout tab. Using Wizard create a form for the node SCARR.

In the main component there is an option to enter the assistance class. Enter the assistance class name as ‘ZCL_FLIGHT_ASSIST’ and double click the assistance class. It will create a class which inherits the super class CL_WD_COMPONENT_ASSISTANCE. Provide the package and request details.

The created class will contain a method IF_WD_COMPONENT_ASSISTANCE~GET_TEXT .

Under attribute TAB create an attribute ‘CARRID’.

Activate and come back to the web Dynpro component. We can see the component controller, views and windows are in inactive mode. Because when we create an assistance class , a new attribute WD_ASSIST with reference to the assistance class will be created under attribute tab .

Double click the Acton ‘goto_details’ for the button GO in MAIN view and write the code to read context attribute CARRID and assign this value to the CARRID of the WD_ASSIST. The code is given below.

METHOD onactiongoto_details .

  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_carrid TYPE wd_this->element_context-carrid.

*   get element via lead selection
  lo_el_context = wd_context->get_element( ).
*   @TODO handle not set lead selection
  IF lo_el_context IS INITIAL.
  ENDIF.

*   get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `CARRID`
    IMPORTING
      value = lv_carrid ).

  wd_assist->carrid = lv_carrid.


  wd_this->fire_to_details_plg(
  ).
ENDMETHOD.

In DETAILS view, double click the WDINIT and write code to read using WD_ASSIST->carrid and fetch carrier details . Refer the code given below.

METHOD wddoinit .

  DATA lo_nd_scarr TYPE REF TO if_wd_context_node.

  DATA lo_el_scarr TYPE REF TO if_wd_context_element.
  DATA ls_scarr TYPE wd_this->element_scarr.

*   navigate from <CONTEXT> to <SCARR> via lead selection
  lo_nd_scarr = wd_context->get_child_node( name = wd_this->wdctx_scarr ).


*   get element via lead selection
  lo_el_scarr = lo_nd_scarr->get_element( ).

  SELECT SINGLE  * FROM scarr INTO ls_scarr WHERE carrid = wd_assist->carrid.

*   set all declared attributes
  lo_el_scarr->set_static_attributes(
     static_attributes = ls_scarr ).


ENDMETHOD.

In WINDOW, embed the view DETAILS. Assign the navigation for the views as given below.

Create an application for the Web Dynpro component. Execute the program.

Click on Go button. We will get the CARRID entered in MAIN view in DETAILS view.

Related Content

Please include at least three references to SDN documents or web pages.
Reference 1
Assistance Class
Reference 3

Useful Information

Short quick summary to catch the reader's attention and of course the search engine

2 Comments

  1. Former Member

  2. Guest

    Refer this tutorial....................
    Easy to understand the concepts of message handling using assistance class.....

    http://theabap.blogspot.in/2012/02/message-handling-assistance-step-1-go.html