Assistance Class in web dynpro Abap :- Assistance class is a way of writing a separate class and using the functionality or logic defined in its method within your web dynpro application.
It is useful where you have some piece of logic which is reusable at many places.
plus Assistance class is also used in internationalization of the WD application.
You can declare the text in the assistance class and then afterwards can use it in your WD application.
Concept is almost straight forward and easy.
You declare a class with some methods having the required functionality.
and can declare some text elements also if you want to use them.
and you have to make this class subclass of a class CL_WD_COMPONENT_ASSISTANCE.
However this is not a mandatory steps but declaring this class as superclass makes services available in web dynpro framework work.
WD_ASSIST attribute will be getting created automatically in each of the controllers in the web dynpro component.
Now lets have one step by step example of working with this feature of assistance class.
1. Go to txn se24 and create a class . give a relevant name and press on create.
and click on save.
2. Go to the methods tab and create methods. In the current case, I am creating a method name
'Get Name' and with one import and one export parameter.
functionality of the method is to give name of the dealer based on the ID.
3. Save and activate the class.
4. You can test the functionality of the method by using the TEST option as shown below.
5. ON the properties tab you can find one field called super class there give the name
CL_WD_COMPONENT_ASSISTANCE.
save and activate the class.
6. Go to SE80 and open the WD component where you want to use the assistance class.
give the name of the class in the assistance class field.
7. Automatically the attribute WD_ASSIST of type instance of class will be created in the component controller and view controller.
8. In the view we will use the assistance class method "GET_NAME". for that i have created some context attribute and then in the view layout, have designed two input fields and one button.
we will enter dealer id and then click on submit button. In the eventhandler of the button we will
call the method GET_NAME of the assistance class using the attribute WD_ASSIST and fetch the name form the database after passing ID.
9. Create an application and test it .
10. Now lets check out the other usage of assistance class. i.e. declaring the text elements in the class and then using it for translation according to the language chosen.
Here we will have one page with one simple text view translated according to the language chosen.
go to se24 and open the class and Goto-> Text elements.
12. Select the from and to language and then give the translated texts for each of the text elements. Save it and activate the class again.
I have used one text view which is bound to one context attribute of type string.
WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( KEY = ' ').
method of the interface for getting the data.
it will give the text according to the language selected in the application.
15. Test the application and we can see the text got automatically translated according to the
language selected.
Thanks :)
thanks
gill