Sunteți pe pagina 1din 16

Web Dynpro for ABAP

Exercise Unit: BAPI Usage


Estimated Time: 45 minutes
NOTES: If you wish to find out more about any field, first select that field and then hit F1. Logon to the !" system and start !#!" $or%bench & E'(). Logon data is *ro+ided by your instructor. a+e all your ob,ects as local ob,ects &*ac%age name -T.").

PURPOSE: The goal of this e/ercise is to allow the *artici*ants to 0reate a $eb 1yn*ro com*onent for sim*le flight boo%ing with a single +iew. PREREQUISITES: Logon to the !" system and start !#!" $or%bench & E'(). Logon data is *ro+ided by your instructor. DEVELOPMENT OBJECTIVES: This e/ercise demonstrates the usage of #!"Is and how to im*lement a +iew with in*ut fields and a result table. PROCEDURE: 1. 0reate a $eb 1yn*ro 0om*onent and a 2iew. 3. 0reate a er+ice 0all for #!"I BAPI_FLIGHT_GETLIST. 4. 1efine the 0onte/t .a**ing 4. 1efine In*ut Fields and a #utton on the 2iew 5. 1efine an !ction and 0orres*onding !ction 5andler 6. 1efine the Table on the 2iew 7. Embedd the 2iew into the $indow '. !cti+ation, 0reation of a $eb 1yn*ro !**lication and E/ecution

Page 1

janvier 30, 2014

Web Dynpro for ABAP

1. Create a Web Dynpro Component and a View


STEPS: 1. 0reate a new $eb 1yn*ro com*onent with name 889((9#!"IFLI:5T and assign it to *ac%age -T." &local ob,ect). 3. 0reate a +iew called FLIGHTLISTVIEW. 4. a+e all the changes.

. Create a !er"ice Ca## $or BAPI BAPI%&'I()*%(E*'I!*


STEPS: $ith the hel* of the ser+ice call function it is *ossible to call an e/isting function module from within a $eb 1yn*ro com*onent.To create a ser+ice call, you ha+e an easy;to;use wi<ard at your dis*osal within the $eb 1yn*ro tools in the !#!" $or%bench. 1. 0reate tarting the $i<ard To start the wi<ard, *osition the cursor on the $eb 1yn*ro com*onent to be edited in the ob,ect list at the left margin of the wor%bench window. =*en its conte/t menu and choose the entry Create>Service Call. The wi<ard is started and leads you through the creation *rocess.

Page

janvier 30, 2014

Web Dynpro for ABAP

"ress Continue. 3. 0hoice of 0ontroller =n the second dialog window of the wi<ard, you can choose whether the ser+ice call is to be embedded in an e/isting controller or whether a new controller is to be created for this *ur*ose. er+ice calls can only always be embedded in global controllers > that is, in the com*onent controller or in additionally created custom controllers. It is not *ossible, to embed ser+ice calls in +iew controllers. a) elect radio button U e E!i tent Controller

b) 1o not change the default entry for com*onent: 889((9#!"IFLI:5T c) Enter for controller 0=."=?E?T0=?T@=LLE@ d) "ress Continue. e) Aou now select, which ser+ice ty*e should be used for this ser+ice call. elect radio button Function "o#ule. Lea+e 1estination blan%. "ress Continue. 4. er+ice Ty*e and er+ice election a) Aou now select, which ser+ice ty*e should be used for this ser+ice call. elect radio button Function "o#ule. Lea+e 1estination blan%. "ress Continue. b) elect the ser+ice: for Function .odule enter BAPI_FLIGHT_GETLIST. "ress Continue.

Page +

janvier 30, 2014

Web Dynpro for ABAP


4. The @eBuired .ethods and 0onte/t Elements =n the two subseBuent dialog windows, default +alues are listed for gi+ing names to the conte/t nodes and attributes reBuired by the ser+ice call as well as to the reBuired methods. The *ro*osed names are based on the names of the embedded ser+ice, but you can change them as reBuired. 5owe+er, heed the res*ecti+e notes in the corres*onding dialog bo/. a) !da*t 0onte/t: elect from ?odesC!ttributes $ESTI%ATI&%_T& and FLIGHT_LIST. "ress Continue. b) *ecify .ethod ?ame: lea+e all entries as *ro+ided: 0om*onent: ))_**_BAPIFLIGHT 0ontroller: C&"P&%E%TC&%T'&LLE' .ethod: E+CUTE_BAPI_FLIGHT_GETLIST ,"ress Continue. 5. 0om*leting the 0hoice $hen you ha+e confirmed the last dialog bo/, the generation is triggered. !fterwards you now ha+e the reBuired methods and conte/ts at your dis*osal for using them within your $eb 1yn*ro com*onent. The com*onent controller conte/t now contains the corres*onding conte/t nodes for the #!"I call. ?ames $ESTI%ATI&%_F'&"(

Furthermore, in the method list there is a new method EXECUTE_BAPI_FLIGHT_GETLIST, which contains the coding to read the conte/t nodes 1E TI?!T=?9F@=. and 1E TI?!TI=?9T= and their underlying conte/t attributes, calls the #!"I and assigns the resulting table to conte/t node FLI:5T9LI T.

Page ,

janvier 30, 2014

Web Dynpro for ABAP

+. De$ine t-e Context .apping


STEPS: 1. =*en +iew FLI:5TLI T2IE$ and switch to tab Conte!t. .a* conte/t nodes 1E TI?!TI=?9F@=., 1E TI?!TI=?9T= and FLI:5T9LI T to the +iew conte/t of FLI:5TLI T2IE$ using 1rag and 1ro*.

0onfirm the dialoges whether you want to co*y or ma* the different conte/t nodes. The result should loo% li%e this:

Page /

janvier 30, 2014

Web Dynpro for ABAP

3.

a+e your changes. Aou ha+e now ma**ed the com*onent controller conte/t elements to the +iew conte/t of FLI:5TLI T2IE$.

,. De$ine Inp0t &ie#ds and a B0tton on t-e View


STEPS: 1. 3. witch to tab La-out of +iew FLI:5TLI T2IE$. elect Standard Container from DI Elements Library and drag and dro* the :rou* icon to the 2iew 1esigner. The new DI element will be named G'&UP. et the following *ro*erties for G'&UP:

Page 1

janvier 30, 2014

Web Dynpro for ABAP

4. @ight;clic% on :@=D" and choose Create Container For..

4. 0lic% on the Conte!t button and create a binding with conte/t node $ESTI%ATI&%_F'&" by double; clic%ing it.

Page 2

janvier 30, 2014

Web Dynpro for ABAP

5.

elect the attributes CIT/ and C&U%T' and lea+e the tandard 0ell Editor as I%PUTFIEL$.

@e*eat the same *rocedure &3;5) to create an DI element G'&UP_0, bind it with conte/t node $ESTI%ATI&%_T& and select again the attributes CIT/ and C&U%T'.

Page 3

janvier 30, 2014

Web Dynpro for ABAP


et the following *ro*erties for G'&UP_0:

6. !dditionally, create a button within G'&UP_0, by right clic%ing the G'&UP_0 element below the '&&TUIELE"E%TC&%TAI%E' and select In ert Ele.ent from conte/t menu. 0hoose ty*e #utton as DI element and name it BUTT&%_0. The button will be *laced in the grou* container. 7. et the *ro*erty Te!t of #DTT=?91 to +alue Searc1 Fli21t .

Page 4

janvier 30, 2014

Web Dynpro for ABAP

/. De$ine an Action and Corresponding Action )and#er


STEPS: 1. 0reate an action GET_FLIGHTS which is triggered by the $eb 1yn*ro e+ent onAction. In *ro*erties table of BUTT&%_0, select the e+ent *ro*erty onAction. 0lic% the icon on the right corner &em*ty *age) to define a new action.

! double;clic% on e+ent GET_FLIGHTS will generate a s%eleton for method =%ACTI&%GET_FLIGHTS.

The code editor will o*en automatically. 3. ?ow the e+ent handler for action :ET9FLI:5T , which is method =?!0TI=?:ET9FLI:5T , needs to be modified to ma%e a call to the controller method EEE0DTE9#!"I9FLI:5T9:ETLI T. In order to do this, in+o%e the $eb 1yn*ro 0ode $i<ard and choose o*tion "et1o# Call in U e# Controller.

Page 15

janvier 30, 2014

Web Dynpro for ABAP


Enter the following data &you may use F4 5el* to get the *ossible entries). 0om*onent ?ame: 889((9#!"IFLI:5T 0ontroller ?ame: 0=."=?E?T0=?T@=LLE@ .ethod ?ame: EEE0DTE9#!"I9FLI:5T9:ETLI T

4.

elect Continue 3Enter4. The generated coding will loo% li%e this.

Page 11

janvier 30, 2014

Web Dynpro for ABAP

1. De$ine t-e *ab#e on t-e View


STEPS: 1. witch to the La-out tab of the +iew and create a table TABLE using Standard Complex from DI Elements Library in 2iew 1esigner &1rag and 1ro*).

3.

et the following *ro*erties for the new element T!#LE:

4. 0reate the data binding of DI element TABLE with conte/t node FLIGHT_LIST.

Page 1

janvier 30, 2014

Web Dynpro for ABAP

tandard 0ell Editor should be of ty*e TE+TVIEW. !cti+ate binding for all conte/t attributes.

Page 1+

janvier 30, 2014

Web Dynpro for ABAP

4. "ress button Continue 3Enter4 and sa+e all the changes.

Page 1,

janvier 30, 2014

Web Dynpro for ABAP

2. Embedd t-e View into t-e Window


STEPS: Embed the +iew FLI:5TLI T2IE$ into $indow 889((9#!"IFLI:5T. 1. =*en in the =b,ect ?a+igator tree the $indow structure and select the window 889((9#!"IFLI:5T. 3. =*en the +iew structure and drag and dro* the +iew FLI:5TLI T2IE$ inside the window structure on the right hand side. 4. =*en the window structure on the right hand side and you will see the embedded +iew FLI:5TLI T2IE$. 4. a+e your changes.

Page 1/

janvier 30, 2014

Web Dynpro for ABAP

3. Acti"ation6 Creation o$ a Web Dynpro App#ication and Exec0tion


STEPS: 1. !cti+ate all objects of $eb 1yn*ro com*onent ))_**_BAPIFLIGHT. 3. 0reate the $eb 1yn*ro a**lication 889((9#!"IFLI:5T and assign it to *ac%age -T." &local ob,ect). 4. @un your a**lication. The result should loo% li%e this.

RESULT : Aou ha+e now created a sim*le $eb 1yn*ro com*onent which uses a #!"I call for data collection. Aou ha+e seen how to use the ser+ice call wi<ard to easily create a ser+ice call from a function module.

Page 11

janvier 30, 2014

S-ar putea să vă placă și