36
8/3/2019 Gets Rows http://slidepdf.com/reader/full/gets-rows 1/36 Log In Register About Us How to Contribute Store Welcome Guest SDN Community BPX Community Business Analytics University Alliances SAP EcoHub Home Forums Wiki  Blogs Articles eLearning Downloads Code Exchange Career Center Events InnoCentive Idea Place SAP Help Portal  Browse 1. My Home > 2. Web Dynpro ABAP > 3. Web Dynpro ABAP Home > 4. Getting the Row Selected In the ALV.... and Much More.. Tools Getting the Row Selected In the ALV....and Much More.. Attachments:37 Added by Richa Tripathi, last edited by Richa Tripathi on Jun 08, 2009 (view change ) 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. þÿ

Gets Rows

Embed Size (px)

Citation preview

Page 1: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 1/36

• Log In

• Register 

• About Us

• How to Contribute

• StoreWelcome Guest

• SDN Community

• BPX Community

• Business Analytics

• University Alliances

• SAP EcoHub

• Home

• Forums

• Wiki 

• Blogs

• Articles• eLearning

• Downloads

• Code Exchange

• Career Center 

• Events

• InnoCentive

• Idea Place

• SAP Help Portal 

• Browse

1. My Home >

2. Web Dynpro ABAP >

3. Web Dynpro ABAP Home >

4. Getting the Row Selected In the ALV....and Much More..

• Tools

Getting the Row Selected In the ALV....and Much More..

• Attachments:37

• Added by Richa Tripathi, last edited by Richa Tripathi on Jun 08, 2009 (view change)

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.

þÿ

Page 2: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 2/36

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

 

Page 3: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 3/36

 

Now ,

 

Page 4: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 4/36

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...

Page 5: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 5/36

 

Page 6: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 6/36

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....

Page 7: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 7/36

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

Module'......and continue...

Page 8: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 8/36

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

Page 9: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 9/36

 

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

Page 10: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 10/36

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

Page 11: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 11/36

Page 12: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 12/36

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.

Page 13: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 13/36

create the inbound and outbound plug for the main page.

now ,

Page 14: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 14/36

and now code in method of the button...

Page 15: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 15/36

 

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(

Page 16: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 16/36

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.

 

Page 17: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 17/36

 

Page 18: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 18/36

 

Page 19: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 19/36

 

Page 20: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 20/36

 

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

Page 21: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 21/36

 

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.

Page 22: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 22/36

* 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.

Page 23: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 23/36

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.

Page 24: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 24/36

 

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' ).

Page 25: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 25/36

* 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`.

Page 26: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 26/36

* 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.

Page 27: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 27/36

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.

Page 28: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 28/36

 

Map the Changing Parameters of the BAPI.

 

Page 29: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 29/36

 

Page 30: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 30/36

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(

Page 31: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 31/36

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( ).

Page 32: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 32/36

* 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(

Page 33: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 33/36

).

ENDMETHOD.

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

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

Page 34: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 34/36

 

Page 35: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 35/36

Page 36: Gets Rows

8/3/2019 Gets Rows

http://slidepdf.com/reader/full/gets-rows 36/36