Skip to end of metadata
Go to start of metadata

Hello Everyone!

This application is one in which there is intregation of passing the parameters,clicking a row in a alv and passing it in the other table and the table data is displayed with the help of bapi.

The row selection and getting the value is the main thing demonstrated here. Most of the things are elaborately explained in here and major concepts of a webdynpro are covered.

Now first of all as we are going to use the alv we need to define the Used Web Dynpro Component that is  'SALV_WD_TABLE '  which is defined with a name as  'ALV_TEST2'.

Starting with creating the component of Web Dynpro....

 
 
then....as said defining ALV Component
 

 
 
 Now ,
 


These are the 2 nodes that are to be created......the creation of node can be learned simply...by practicing some simple bsic wikis given...

https://wiki.sdn.sap.com/wiki/x/QwArBg

 then the other node is created by the service call....

On Right Clicking on the Object name....

in the create you will find the option for the service call...


now You will be taken to the screen...



 
 
 
here now click on continue...


Check the radiobutton 'Use Existent Controller' and then Select the Existent Controller in it.......For the Controller inputfield by F4...and the Click Continue....




We are creating the Service Call for the Function Module so we need to check the radiobutton beside 'Function Module'......and continue...



 Now for the Function Module name enter the Bapi that you want to use....and continue...



 
 
now all those parameters that you want in your context node's attribute ,select that option as above in the listbox.....



Here enter the EXECUTE_BAPI_SBOOK_GETLIST method of that Bapi which will get the list....







An at last clicking on the complete  button you can complete your service call.....

 after this...

 you can go to you component controller context and there you can find the context there....

 Now first of all create a simple table....in the main page...with context as below.....till now we are not doing any mapping here.....with the root component controller.


create the inbound and outbound plug for the main page.

 now ,

 

and now code in method of the button...



 

AS SAID BEFORE THAT lv_carrid IS THE PARAMETER WHICH CONTAINS THE CARRID TO BE PASSED,

it is defined as a exporting Parameter.


METHOD onactionselectline .

DATA lo_nd_scarr TYPE REF TO if_wd_context_node.

DATA lo_el_scarr TYPE REF TO if_wd_context_element.

DATA ls_scarr TYPE wd_this->element_scarr.

lo_nd_scarr = wd_context->get_child_node( name ='SCARR' ).

* get element via lead selection

lo_el_scarr = lo_nd_scarr->get_element( ).

* get all declared attributes

lo_el_scarr->get_static_attributes(

IMPORTING

static_attributes = ls_scarr ).

* get single attribute

lo_el_scarr->get_attribute(

EXPORTING

name = 'CARRID'

IMPORTING

value = lv_carrid1 ).

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

lo_nd_scarr = wd_context->get_child_node( name = 'NODE1' ).

* get element via lead selection

lo_el_scarr = lo_nd_scarr->get_element( ).

CALL METHOD lo_nd_scarr->set_attribute

EXPORTING

value = lv_carrid1

name = 'LV_CARRID1' .

* THIS IS THE STEP MANDATORY AND IMPORTANT TO REMEMBER THAT DEFINE THE PARAMETER DURING EXPORTING AS IT IS A LOCAL PARAMETER

wd_this->fire_out_plg(

lv_carrid1 = lv_carrid1                                    " scarr-carrid

).
 
 

Now the work on the main that is the first page is over,

the newview where according to the carrid the ALV is being displayed.....important thing is that here the parameters are exported locally as if we define all the papameters globally it takes more of memoy so its better to pass parameters locally till it is used and wanted everywhere in the application.

now ,

in the context...

 
 
 
Also,embed the following used controllers in the NEWVIEW Proteries page in the USED Components and Controllers.
 

 
 


 

     
   


 



 

Define in the OUT_SBOOK the parameters that are to be passed to the next page in OUTBOUND Plug.

 LV_CARRIDB                      SCARR-CARRID                                                             
 LV_CONNIDB                     SPFLI-CONNID    

LV_FLDATEB                       SFLIGHT-FLDATE       


 

  

 METHOD handlein .

DATA lo_nd_sflight TYPE REF TO if_wd_context_node.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_lv_carrid LIKE ls_context-lv_carrid1.

DATA ls_sflight TYPE wd_this->elements_sflight.

DATA lv_carrid TYPE scarr-carrid.

DATA lv_carridb TYPE scarr-carrid.

DATA fs_flight LIKE LINE OF ls_sflight.

DATA ls_sflight1 TYPE wd_this->elements_sflight.

* get element via lead selection

lo_el_context = wd_context->get_element( ).

* get element via lead selection

CALL METHOD lo_el_context->set_attribute

EXPORTING

value = lv_carrid1

name = `LV_CARRID1`.

lv_carrid = lv_carrid1.

lo_nd_sflight = wd_context->get_child_node( name = 'SFLIGHT' ).

*& Fetch flight data from database table

SELECT mandt

carrid

connid

fldate

price

FROM sflight

INTO CORRESPONDING FIELDS

OF TABLE ls_sflight

WHERE carrid = lv_carrid. .

CALL METHOD lo_nd_sflight->bind_table( ls_sflight ).

ENDMETHOD.

Now,

it is IMPORTANT to instantiate the ALV AND DO THE fOLLOWING CODE TO GET THE ALV OPERATIONS TO BE PERFORMED...
METHOD wddoinit .

*Code to set ALV Editable

DATA:

lr_comp_alv TYPE REF TO if_wd_component_usage,

lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,

lr_config TYPE REF TO cl_salv_wd_config_table.
*... ALV Component Usage

lr_comp_alv = wd_this->wd_cpuse_alv_test2( ).

IF lr_comp_alv->has_active_component( ) IS INITIAL.

lr_comp_alv->create_component( ).

ENDIF.

lr_comp_if_alv = wd_this->wd_cpifc_alv_test2( ).
*... Configure ALV

lr_config = lr_comp_if_alv->get_model( ).

CALL METHOD lr_config->if_salv_wd_table_settings~set_selection_mode

EXPORTING

value = cl_wd_table=>e_selection_mode-multi_no_lead.

ENDMETHOD.    

                                                                                               

 METHOD onactiongoto_sbook_plug .

DATA: temp TYPE string.

DATA: lr_node TYPE REF TO if_wd_context_node,

wa_temp TYPE REF TO if_wd_context_element,

lt_temp LIKE STANDARD TABLE OF wa_temp,

lt_node1 TYPE wd_this->elements_sflight,

ls_node1 LIKE LINE OF lt_node1.

lr_node = wd_context->get_child_node( name = 'SFLIGHT' ).

* This would now contain the references of all the selected rows

lt_temp = lr_node->get_selected_elements( ).

LOOP AT lt_temp INTO wa_temp.

*Use the references to get the exact row data

CALL METHOD wa_temp->get_static_attributes

IMPORTING

static_attributes = ls_node1.

APPEND ls_node1 TO lt_node1.

ENDLOOP.

DATA ls_context TYPE wd_this->element_context.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA lv_lv_carridb LIKE ls_context-lv_carridb.

DATA lv_lv_connidb LIKE ls_context-lv_connidb.

DATA lv_lv_fldateb LIKE ls_context-lv_fldateb.

FIELD-SYMBOLS <lt_node1> TYPE wd_this->element_sflight.

READ TABLE lt_node1 FROM ls_node1 ASSIGNING <lt_node1> .

lv_carridb = <lt_node1>-carrid.

lv_connidb = <lt_node1>-connid.

lv_fldateb = <lt_node1>-fldate.

* get element via lead selection

wa_temp = wd_context->get_element( ).

* get single attribute

wa_temp->get_attribute(

EXPORTING

name = `LV_CARRIDB`

IMPORTING

value = lv_lv_carridb ).

CALL METHOD wa_temp->set_attribute

EXPORTING

value = lv_carridb

name = `LV_CARRIDB`.

* get element via lead selection

wa_temp = wd_context->get_element( ).

* get single attribute

wa_temp->get_attribute(

EXPORTING

name = `LV_CONNIDB`

IMPORTING

value = lv_lv_connidb ).

CALL METHOD wa_temp->set_attribute

EXPORTING

value = lv_connidb

name = `LV_CONNIDB`.

* get element via lead selection

wa_temp = wd_context->get_element( ).

* get single attribute

wa_temp->get_attribute(

EXPORTING

name = `LV_FLDATEB`

IMPORTING

value = lv_lv_fldateb ).

CALL METHOD wa_temp->set_attribute

EXPORTING

value = lv_fldateb

name = `LV_FLDATEB`.

BREAK-POINT.

wd_this->fire_out_sbook_plg(

lv_carridb = lv_carridb                 " scarr-carrid

lv_connidb = lv_connidb               " spfli-connid

lv_fldateb = lv_fldateb                 " sflight-fldate

).

ENDMETHOD.
 

Now the Last Page the SBOOK data is being Displayed.

here the Layout Goes this Way.

 
 
 The service call bapi created is to be mapped here.



 
 
 Map the Changing Parameters of the BAPI.
 
 


 

 In the Handlein of the SBOOK get the import parameters and get the table displayed.

 
 
 METHOD handlein_sbook .

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_lv_carridb LIKE ls_context-lv_carridb.

DATA lv_lv_connidb LIKE ls_context-lv_connidb.

* get element via lead selection

lo_el_context = wd_context->get_element( ).

* get single attribute

 lo_el_context->get_attribute(

EXPORTING

name = `LV_CARRIDB`

IMPORTING

value = lv_lv_carridb ).

lv_lv_carridb = lv_carridb.

CALL METHOD lo_el_context->set_attribute

EXPORTING

value = lv_lv_carridb

name = `LV_CARRIDB`.

* get element via lead selection

lo_el_context = wd_context->get_element( ).

* get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `LV_CONNIDB`

IMPORTING

value = lv_lv_connidb ).

lv_lv_connidb = lv_connidb.

* SETTING THE ATTRIBURES  AIRLINECARRIER , CONNECTIONNUMBER , DATEOFFLIGHT

DATA lo_nd_bapi_sbook_getlist TYPE REF TO if_wd_context_node.

DATA lo_nd_importing TYPE REF TO if_wd_context_node.

DATA lo_el_importing TYPE REF TO if_wd_context_element.

DATA ls_importing TYPE wd_this->element_importing.

DATA lv_connectionnumber LIKE ls_importing-connectionnumber.

DATA lv_airlinecarrier LIKE ls_importing-airlinecarrier.

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

lo_nd_bapi_sbook_getlist = wd_context->get_child_node( name = wd_this->wdctx_bapi_sbook_getlist ).

* navigate from <BAPI_SBOOK_GETLIST> to <IMPORTING> via lead selection

lo_nd_importing = lo_nd_bapi_sbook_getlist->get_child_node( name = wd_this->wdctx_importing ).

* get element via lead selection

lo_el_importing = lo_nd_importing->get_element( ).

* get single attribute

lo_el_importing->get_attribute(

EXPORTING

name = `CONNECTIONNUMBER`

IMPORTING

value = lv_connectionnumber ).

* get single attribute

lo_el_importing->get_attribute(

EXPORTING

name = `AIRLINECARRIER`

IMPORTING

value = lv_airlinecarrier ).

CALL METHOD lo_el_importing->set_attribute

EXPORTING

value = lv_lv_carridb

name = `AIRLINECARRIER`.

CALL METHOD lo_el_importing->set_attribute

EXPORTING

value = lv_lv_connidb

name = `CONNECTIONNUMBER`.

CALL METHOD lo_el_importing->set_attribute

EXPORTING

value = lv_fldateb

name = `DATEOFFLIGHT`.

 * AFTER THE PARAMETERS TO BE IMPORTED ARE FILLED THE execute_bapi_sbook_getlist fUNCTION MODULE IS EXECUTED.

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .

lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).

lo_componentcontroller->execute_bapi_sbook_getlist(

).
ENDMETHOD.


This Completes the Application by creating a WEBDYNPRO APPLICATION for the Whole.

AT LAST ...................THE OUTPUT LOOKS LIKE THIS............................