Register Login

Use of Assistance Class in Webdynpro

Updated May 18, 2018

Assistance class functionality in WDA 

Generally in webdynpro ABAP,we use to write all the coding part within the component itself but there is a provision with which we can write the necessary business logic outside the component that is in a class and we can use that class as the assistance class in the current component, In this tutorial i will explain the steps involved in using this assistance class

I took an example of displaying the business partner details in an ALV if the input to the component is business partner number.

Step1: Goto transaction se24 and create the class ZSAMP_ASSISTANCECLASS_BPDETAIL as shown below,this class will contain the logic to retrieve the partner details and it will be used as the assistance class in the webdynpro component

 

Step2: Create the method  GET_PARTNER_DETAIL with the importing parameter as partnernumber and exporting parameter as partner details as shown below

 Step3: Add the following code inside the method GET_PARTNER_DETAIL to retrieve the partner details

method GET_PARTNER_DETAIL.
SELECT * FROM BUT000
INTO CORRESPONDING FIELDS OF TABLE lt_but000
WHERE PARTNER = im_partner.
 
endmethod.

Step4: The class is ready and now create the WD component ZSAMP_ASSI and provide the class name as  ZSAMP_ASSISTANCECLASS_BPDETAIL in the Assistance class field as indicated below

Step5:Also include the ALV component since the partner details will be displayed as ALV output,Create the view 'FIRST' with the input field element as partner number and after entering the partner number to search for the partner details include the button (search) element create the view elements as shown in the below screen

Step6: Make sure that the attribute WD_ASSIST is created in the FIRST view as shown below since this is the reference attribute of the assistance class  which will be used to access the business logic of the class

Step7: After entering the partner number in the partner field the search button will be pressed so provide the following code in the event handler method of the search button to retrieve the partner details using the assistance class

method ONACTIONSEARCH .
data : lt_but000 TYPE TABLE OF but000.
data:
Elem_Context type ref to If_Wd_Context_Element,
Stru_Context type If_First=>Element_Context ,
Item_PARTNER like Stru_Context-PARTNER.
* get element via lead selection
Elem_Context = wd_Context->get_Element( ).
* get single attribute
Elem_Context->get_Attribute(
exporting
Name = `PARTNER`
importing
Value = Item_Partner ).
CALL METHOD WD_ASSIST->GET_PARTNER_DETAIL
EXPORTING
IM_PARTNER = Item_PARTNER
IMPORTING
LT_BUT000 = lt_but000
.
data:
Node_Partnerdetail type ref to If_Wd_Context_Node,
Elem_Partnerdetail type ref to If_Wd_Context_Element,
Stru_Partnerdetail type If_First=>Element_Partnerdetail .
* navigate from
<context>to <partnerdetail> via lead selection
Node_Partnerdetail = wd_Context->get_Child_Node( Name = IF_FIRST=>wdctx_Partnerdetail ).
Node_Partnerdetail->bind_table( lt_but000 ).
endmethod.

Step8 : I made here to display the  name details of the partner alone in the ALV output so restrict the fileds in the context node of the FIRST view as shown below

Step9 : The webynpro component using the Assistance class is created now and the output for the same will be displayed as follows

This tutorial is mainly concerned with the steps involved in 'how to use the assistance class in Webdynpro ABAP'.

 


×