Calling An Interface View of Another Abap Web Dynpro Application

You might also like

You are on page 1of 5

Calling an interface view of another abap web dynpro application

Attachments:9
Added by Ravi Aswani, last edited by Craig Cmehil on Dec 28, 2009 (view change)
Senario: get the personnal number in one view of web dynpro application and call the view of another web dynpro application to display
employee details w.r.t the pernr enered intially in first application.
1.) Create a web dynpro application in SE80 say YHPERSON_COMPONENT and create a view FIRST_VIEW *with UI elements to display
the employee details and Window as *MAIN_WINDOW as shown :

2.) Create Global Context in component controller to store employee address, mail and name and map it to the context of First_View. ( drap
& drop to left context)

3.) In the context tab of the MAIN_WINDOW create the same context as shown above..
4.) Create an Inbound Plug (IN) for the MAIN_WINDOW as shown ....

5.) IN the HANDLEIN method of the MAIN_WINDOW create an import parameter PERNR type PERSNO and give the following code :
method HANDLEIN .
data:
ls_pa0006 type pa0006,
ls_pa0105 type pa0105,
ls_pa0002 type pa0002.
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->display(
EXPORTING
persno
= pernr
importing
persaddress = ls_pa0006
persemail
= ls_pa0105
persname
= ls_pa0002
).
DATA lo_nd_persname TYPE REF TO if_wd_context_node.
DATA lo_el_persname TYPE REF TO if_wd_context_element.
DATA ls_persname TYPE wd_this->element_persname.
*

navigate from <CONTEXT> to <PERSNAME> via lead selection


lo_nd_persname = wd_context->get_child_node( name = wd_this->wdctx_persname ).

get element via lead selection


lo_el_persname = lo_nd_persname->get_element( ).

@TODO fill static attributes


data:
lw_char(80).

@TODO fill static attributes


ls_persname-pernr = ls_pa0002-pernr.
concatenate ls_pa0002-NACHN ls_pa0002-VORNA into lw_char.
ls_persname-empname = lw_char.

set all declared attributes


lo_el_persname->set_static_attributes(
static_attributes = ls_persname ).
DATA lo_nd_persaddress TYPE REF TO if_wd_context_node.
DATA lo_el_persaddress TYPE REF TO if_wd_context_element.
DATA ls_persaddress TYPE wd_this->element_persaddress.

* navigate from <CONTEXT> to <PERSADDRESS> via lead selection


lo_nd_persaddress = wd_context->get_child_node( name = wd_this->wdctx_persaddress ).
* get element via lead selection
lo_el_persaddress = lo_nd_persaddress->get_element( ).
ls_persaddress-stras
ls_persaddress-ort01
ls_persaddress-pstlz
ls_persaddress-land1

=
=
=
=

ls_pa0006-stras
ls_pa0006-ort01
ls_pa0006-pstlz
ls_pa0006-land1

.
.
.
.

* set all declared attributes


lo_el_persaddress->set_static_attributes(
static_attributes = ls_persaddress ).
DATA
DATA
DATA
DATA

lo_nd_persmail TYPE REF TO if_wd_context_node.


lo_el_persmail TYPE REF TO if_wd_context_element.
ls_persmail TYPE wd_this->Element_persmail.
lv_mail TYPE wd_this->Element_persmail-mail.

* navigate from <CONTEXT> to <PERSMAIL> via lead selection


lo_nd_persmail = wd_context->get_child_node( name = wd_this->wdctx_persmail ).
* get element via lead selection
lo_el_persmail = lo_nd_persmail->get_element( ).
lv_mail

= ls_pa0105-usrid_long.

* set single attribute


lo_el_persmail->set_attribute(
name = `MAIL`
value = lv_mail ).
endmethod.

6.) save , activate the component.


7.) Create another component in SE80 to call the component created above by name YHTEST_COMPONENT and create view as MAIN and
window as yhtest_window
also in the properties tab create used components as YHPERSON_COMPONENT as shown ...

8.) Create an attribute in Context tab of MAIN view called PERNR type PERSNO .
9.) Create used components in the Properties tab of the Component
Controller

10.) Create an outbound plug (OUTPLUG) and pass the parameter PERNR of type PERSNO as shown
...

11.) For the button on the layout of the view MAIN create an event GETDETAILS with the outbound plug and give the following code in it ...
method ONACTIONONGETDETAILS .
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_pernr TYPE wd_this->Element_context-pernr.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `PERNR`
IMPORTING
value = lv_pernr ).
wd_this->fire_outplug_plg(
pernr = lv_pernr
).
endmethod.

12.) in the window provide embed the MAIN_WINDOW and MAIN view also provide the navigation link for the OUTPLUG to the IN plug of the
MAIN_WINDOW as
shown:

13.) Save and activate your application , make sure that the used component is also active ....and execute the application
YHTEST_COMPONENT.

You might also like