Assistance Class Functionality in WDA
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 AL if the input to the
component is business partner number!
"tep#$ Goto transaction se%& and create the class
'"A(P)A""I"*A+,-,LA"")BP.-*AIL 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
"tep%$ ,reate the method G-*)PA/*+-/).-*AIL with the importing parameter as
partnernumber and exporting parameter as partner details as shown below
"tep0$ Add the following code inside the method G-*)PA/*+-/).-*AIL to retrieve
the partner details
method GET_PARTNER_DETAIL.
SELECT * FROM BUT000
INTO CORRESPONDING FIELDS OF TABLE lt_but000
!ERE PARTNER " #m_$%&t'e&.
e'dmethod.
"tep&$ *he class is ready and now create the 1. component '"A(P)A""I and provide
the class name as '"A(P)A""I"*A+,-,LA"")BP.-*AIL in the Assistance class
field as indicated below
"tep2$Also include the AL component since the partner details will be displayed as AL
output,,reate the view 34I/"*3 with the input field element as partner number and after
entering the partner number to search for the partner details include the button 5search6
element create the view elements as shown in the below screen
"tep7$ (ake sure that the attribute 1.)A""I"* is created in the 4I/"* 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
"tep8$ 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 ONACTIONSEARC! .
d%t% ( lt_but000 T)PE TABLE OF but000.
d%t%(
Elem_Co'te*t t+$e &e, to I,_d_Co'te*t_Eleme't-
St&u_Co'te*t t+$e I,_F#&.t"/Eleme't_Co'te*t -
Item_PARTNER l#0e St&u_Co'te*t1PARTNER.
* 2et eleme't 3#% le%d .ele4t#o'
Elem_Co'te*t " 5d_Co'te*t1/2et_Eleme't6 7.
* 2et .#'2le %tt&#bute
Elem_Co'te*t1/2et_Att&#bute6
e*$o&t#'2
N%me " 8PARTNER8
#m$o&t#'2
9%lue " Item_P%&t'e& 7.
CALL MET!OD D_ASSIST1/GET_PARTNER_DETAIL
E:PORTING
IM_PARTNER " Item_PARTNER
IMPORTING
LT_BUT000 " lt_but000
.
d%t%(
Node_P%&t'e&det%#l t+$e &e, to I,_d_Co'te*t_Node-
Elem_P%&t'e&det%#l t+$e &e, to I,_d_Co'te*t_Eleme't-
St&u_P%&t'e&det%#l t+$e I,_F#&.t"/Eleme't_P%&t'e&det%#l .
* '%3#2%te ,&om ;CONTE:T/ to ;PARTNERDETAIL/ 3#% le%d .ele4t#o'
Node_P%&t'e&det%#l " 5d_Co'te*t1/2et_Ch#ld_Node6 N%me "
IF_FIRST"/5d4t*_P%&t'e&det%#l 7.
Node_P%&t'e&det%#l1/b#'d_t%ble6 lt_but000 7.
e'dmethod.
"tep9 $ I made here to display the name details of the partner alone in the AL output so
restrict the fileds in the context node of the 4I/"* view as shown below
"tep: $ *he webynpro component using the Assistance class is created now and the
output for the same will be displayed as follows
*his tutorial is mainly concerned with the steps involved in 3how to use the assistance
class in 1ebdynpro ABAP3!