8/17/2019 Assistance Class Use in WebDynpro ABAP
1/28
Assistance Class Use in WebDynpro ABAP
Prepared by:
Pallavi Gupta (Emp. Code – 00662K)
Email ID –[email protected]
January 28, 2012
8/17/2019 Assistance Class Use in WebDynpro ABAP
2/28
Contents
Use of Assistance Class:..............................................................................................
Advantages of Assistance Class:...................................................................................
Overview...................................................................................................................
Creation of DDIC Objects............................................................................................Creation of Assistance Class........................................................................................
Add Inheritance.........................................................................................................
Create Methods in the Class.........................................................................................
Create Text Eleents..................................................................................................
Create !ebD"n#ro Co#onent....................................................................................
Object for the Class....................................................................................................
Code.........................................................................................................................
Test..........................................................................................................................Create A##lication...................................................................................................
$eference%s&..............................................................................................................
8/17/2019 Assistance Class Use in WebDynpro ABAP
3/28
Use of Assistance Class:
A #iece of code which is getting 'sed again and again in a co#onent can be added
to the ethod of an assistance class. (ow this ethod can be called ever" tie that
#artic'lar code has to be exec'ted.
Advantaes of Assistance Class:• Calling a ethod of an assistance class gives 'ch i#roved #erforance
than calling a ethod of a controller.• Use of d"naic texts. Text can be saved as text s"bols in an assistance
class and can be 'sed at r'n tie.
!ve"vie#
In this Doc'ent) I*ll dis#la" the sales doc'ent details. The 'ser will have to enter
the creation date+ all the doc'ents with that creation date will be dis#la"ed. !hen
'ser selects an" #artic'lar sales doc'ent) the line ites of that #artic'lar sales
doc'ent will be dis#la"ed
Steps:
C"eation of $$%C !&'ects
Create , str'ct'res as show below in -E.
8/17/2019 Assistance Class Use in WebDynpro ABAP
4/28
(ow create , Table T"#es 'sing the str'ct'res created above.
-ave and activate.
C"eation of Assistance Class
/o to transaction -E,0 to create a new assistance class.
8/17/2019 Assistance Class Use in WebDynpro ABAP
5/28
Clic1 on create.
/ive the nae of the class.
Add %ne"itance
(ote: All the assistance classes inherit fro C23!D3COM4O(E(T3A--I-TA(CE.
To add the nae of the s'#erclass) clic1 on the b'tton next to class nae field) a
new field for s'#erclass will a##ear. Add the nae of the s'#erclass.
8/17/2019 Assistance Class Use in WebDynpro ABAP
6/28
Clic1 on -ave.
The following screen will a##ear.
Two ethods get a'toaticall" created. These are inherited fro the s'#erclass.
I53!D3COM4O(E(T3A--I-TA(CE6/ET3TE7T ethod is 'sed to get the d"naic
texts.
8/17/2019 Assistance Class Use in WebDynpro ABAP
7/28
C"eate etods in te Class
In the Methods tab) create , ethods:
& /ET3-A2E-3DOCUME(T-,& /ET3-A2E-3DOCUME(T3DETAI2-
-elect the 8/ET3-A2E-3DOCUME(T-* ethod and clic1 on #araeters b'tton.
Add , #araeters as shown below.
C"eation of Assistance Class
/o to transaction -E,0 to create a new assistance class.
Clic1 on create.
/ive the nae of the class.
8/17/2019 Assistance Class Use in WebDynpro ABAP
8/28
Add %ne"itance
(ote: All the assistance classes inherit fro C23!D3COM4O(E(T3A--I-TA(CE.
To add the nae of the s'#erclass) clic1 on the b'tton next to class nae field) a
new field for s'#erclass will a##ear. Add the nae of the s'#erclass.
Clic1 on -ave.
8/17/2019 Assistance Class Use in WebDynpro ABAP
9/28
The following screen will a##ear.
Two ethods get a'toaticall" created. These are inherited fro the s'#erclass.
I53!D3COM4O(E(T3A--I-TA(CE6/ET3TE7T ethod is 'sed to get the d"naic
texts.
C"eate etods in te Class
In the Methods tab) create , ethods:
9& /ET3-A2E-3DOCUME(T-0& /ET3-A2E-3DOCUME(T3DETAI2-
-elect the 8/ET3-A2E-3DOCUME(T-* ethod and clic1 on #araeters b'tton.
Add , #araeters as shown below.
8/17/2019 Assistance Class Use in WebDynpro ABAP
10/28
-iilarl") add #araeters for /ET3-A2E-3DOCUME(T3DETAI2-* ethod.
(ow) do'ble clic1 on the 8/ET3-A2E-3DOCUME(T-* ethod nae. In the editor
screen) enter the following code.
select ;E2( E$DAT E$ i3erdat.
-iilarl") add the following code in the 8/ET3-A2E-3DOCUME(T3DEATAI2-* ethod.
8/17/2019 Assistance Class Use in WebDynpro ABAP
11/28
select ;E2( 4O-($ MAT($ MAT!A A$=T7 4-T? MEI(- fro ;A4 into table e3vba# where ;E2( e> i3vbeln.
C"eate *e+t Elements
Assistance class allows 's to 'se the d"naic texts. In order to create the) clic1 on
/OTO TE7T E2EME(T-.
Add text eleents. -ave and activate.
8/17/2019 Assistance Class Use in WebDynpro ABAP
12/28
The assistance is read" to be 'sed. !e can test the wor1ing of o'r class b" clic1ingthe exec'te b'tton.
C"eate ,e&$-np"o Component
/o to -E@ and create a new webd"n#ro co#onent.
Do'ble clic1 on the co#onent nae. In the Assistance class field) add the nae of
the class.
8/17/2019 Assistance Class Use in WebDynpro ABAP
13/28
/o to the ain view and go to the context tab.
Create the following nodes and attrib'tes:
Clic1 on Add Attrib'te fro -tr'ct're b'tton.
8/17/2019 Assistance Class Use in WebDynpro ABAP
14/28
Clic1 on Add Attrib'te fro -tr'ct're b'tton.
8/17/2019 Assistance Class Use in WebDynpro ABAP
15/28
Create an attrib'te of DAT- t"#e.
Create , string attrib'tes: TE7T and TE7T,. These will be 'sed to dis#la" thed"naic texts. 5inall" the nodes and attrib'tes wo'ld loo1 this:
8/17/2019 Assistance Class Use in WebDynpro ABAP
16/28
/o to the la"o't tab and insert the UI eleents.
Insert , Table UI eleents. One to dis#la" the header lines of the sales doc'entsand other to dis#la" the line ites of the selected sales doc'ent.
$ight clic1 on the table UI eleent) clic1 on create binding.
8/17/2019 Assistance Class Use in WebDynpro ABAP
17/28
Clic1 on Context b'tton.
-elect the ;A= node.
8/17/2019 Assistance Class Use in WebDynpro ABAP
18/28
-iilarl" create another table UI eleent and do the binding.
8/17/2019 Assistance Class Use in WebDynpro ABAP
19/28
5or the second table) select ;A4 node.
Create a b'tton UI eleent) and create an onAction event hander with the naeO(-EA$CB.
8/17/2019 Assistance Class Use in WebDynpro ABAP
20/28
Create an On2ead-elect event handler for the first table. This event handler will becalled ever" tie when a row in the first table is selected.
;ind the Ca#tion of both the tables with attrib'te TE7T and TE7T, res#ectivel".
8/17/2019 Assistance Class Use in WebDynpro ABAP
21/28
The final UI eleent will loo1 li1e this:
8/17/2019 Assistance Class Use in WebDynpro ABAP
22/28
!&'ect fo" te Class
/o to the Attrib'tes tab of the view) an object for the assistance class !D3A--I-T will be a'toaticall" created.
Code
/o the !DDOI(IT ethod of the view and 'se the following code:
The following code calls the I53!D3COM4O(E(T3A--I-TA(CE6/ET3TE7T ethodof the assistance class. This ethod ta1es the essage n'ber as in#'t andret'rns the text eleent corres#onding to it. These texts are then set to TE7Tand TE7T, attrib'te and will a##ear on the ca#tion of the table.
ethod !DDOI(IT .
data: header t"#e string) header, t"#e string) Ele3Context t"#e ref to If3!d3Context3Eleent)
-tr'3Context t"#e If3Main3iewFEleent3Context) Ite3TE7T li1e -tr'3ContextGTE7T.
* get element via lead selection
Ele3Context wd3ContextGFget3Eleent% &.
header !D3A--I-TGFI53!D3COM4O(E(T3A--I-TA(CE6/ET3TE7T% =E? HH &. header, !D3A--I-TGFI53!D3COM4O(E(T3A--I-TA(CE6/ET3TE7T% =E? H,H &.
* set single attribute
Ele3ContextGFset3Attrib'te%
ex#orting (ae TE7T al'e header &.
* set single attribute
Ele3ContextGFset3Attrib'te% ex#orting (ae TE7T, al'e header, &.
8/17/2019 Assistance Class Use in WebDynpro ABAP
23/28
endethod.
(ow go to O(ACTIO(O(-EA$CB ethod and 'se the following code:
The following code gets the creation date entered b" the 'ser on the selection andthen calls the /ET3-A2E-3DOCUME(T- ethod of the assistance class withcreation date as in#'t #araeters and ret'rns an internal table.
ethod O(ACTIO(O(-EA$CB .
* Read the user entered date
data: Ele3Context t"#e ref to If3!d3Context3Eleent) -tr'3Context t"#e If3Main3iewFEleent3Context ) Ite3C$EATIO(3DATE li1e -tr'3ContextGC$EATIO(3DATE) (ode3ba1 t"#e ref to If3!d3Context3(ode)
Ele3ba1 t"#e ref to If3!d3Context3Eleent) -tr'3ba1 t"#e If3Main3iewFEleent3ba1 ) it3vba1 t"#e Jvba13tt.* get element via lead selection Ele3Context wd3ContextGFget3Eleent% &.
* navigate from to via lead selection
(ode3ba1 wd3ContextGFget3Child3(ode% (ae I53MAI(3IE!Fwdctx3ba1 &.
* get element via lead selection
Ele3ba1 (ode3ba1GFget3Eleent% &.
* get single attribute Ele3ContextGFget3Attrib'te% ex#orting (ae C$EATIO(3DATE i#orting al'e Ite3Creation3Date &.
CA22 METBOD !D3A--I-TGF/ET3-A2E-3DOCUME(T- E74O$TI(/ I3E$DAT Ite3Creation3Date IM4O$TI(/ E3;A= it3vba1.
I5 not it3vba1KL I- initial.
(ode3ba1GFbind3table% it3vba1 &.
E(DI5.
endethod.
8/17/2019 Assistance Class Use in WebDynpro ABAP
24/28
The ethod of the class can called 'sing 4attern b'tton.
/ive the instance nae %object nae& of the class) which is !D3A--I-T in o'rcase. 4rovide the class nae and ethod to be called. Code will be generated b"the s"ste.
Use the following code on the On2ead-elect ethod of the first table.
The following code will get the selected sales doc'ent n'ber %;E2(& and will#ass it to the /ET3-A2E-3DOCUME(T3DETAI2- ethod of the class to get the lineites corres#onding to that sales doc'ent n'ber.
ethod O(ACTIO(O(-E2ECT .
data:
(ode3ba1 t"#e ref to If3!d3Context3(ode) Ele3ba1 t"#e ref to If3!d3Context3Eleent) -tr'3ba1 t"#e If3Main3iewFEleent3ba1 ) (ode3ba# t"#e ref to If3!d3Context3(ode) Ele3ba# t"#e ref to If3!d3Context3Eleent) -tr'3ba# t"#e If3Main3iewFEleent3ba# ) it3vba# t"#e Jvba#3tt.* navigate from to via lead selection (ode3ba1 wd3ContextGFget3Child3(ode% (ae I53MAI(3IE!Fwdctx3
8/17/2019 Assistance Class Use in WebDynpro ABAP
25/28
ba1 &.
* get element via lead selection Ele3ba1 (ode3ba1GFget3Eleent% &.
* navigate from to
8/17/2019 Assistance Class Use in WebDynpro ABAP
26/28
Initial -creen
Enter thecreation
8/17/2019 Assistance Class Use in WebDynpro ABAP
27/28
date and clic1 on -earch b'tton. -ales doc'ents created on that date getsdis#la"ed.
-elect an" sales doc'ent) line ites corres#onding to that sales doc'ent getsdis#la"ed.
8/17/2019 Assistance Class Use in WebDynpro ABAP
28/28
efe"ence(s)
. 4roject Ex#erience,. htt#:www.sdn.sa#.co9. htt#:hel#.sa#.co
http://www.sdn.sap.com/http://help.sap.com/http://www.sdn.sap.com/http://help.sap.com/