Upload
carlos-rivas-parra
View
217
Download
0
Embed Size (px)
Citation preview
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 1/18
Working with ALV and SelectOptions
Appl ies to:
WebDynpro ABAP. For more information, visit the User Interface Technology homepage.
Summary
This tutorial explains about Step-By-Step procedure for creating select options and displaying data using ALV. This tutorial is about displaying material as select option and displays those material details in the formof ALV
Author : Preethi Myneni
Company: Intelligroup Asia Pvt. Ltd.
Created on: 18 November 2008
Author Bio
Preethi Myneni is a senior consultant currently working for Intelligroup Asia Pvt. Ltd. She has goodknowledge in ABAP WebDynpro.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 1
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 2/18
Working with ALV and Select Options
Table of Contents
Introduction .........................................................................................................................................................3
Creating WebDynpro Component ......................................................................................................................3
Specify Used Components .................................................................................................................................3
Creating Context Attributes and Implement the Methods...................................................................................5
Create View ........................................................................................................................................................8
Embed the View in to Window..........................................................................................................................11
Creating WebDynpro Application .....................................................................................................................15
Result................................................................................................................................................................16
Related Content................................................................................................................................................17
Disclaimer and Liability Notice..........................................................................................................................18
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 2
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 3/18
Working with ALV and Select Options
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 3
Introduction
Create material number as select options and display those material details in ALV format.
Creating WebDynpro Component
Create WebDynpro component ZWD_MAT_DETAILS in SE80.
Specify Used Components
To create select options we have to use the existing component WDR_SELECT_OPTIONS. For using thiscomponent in our WebDynpro component we need to specify this in used components tab in our WebDynprocomponent.
To display data using ALV we have to use the existing component SALV_WD_TABLE. Specify this also inour WebDynpro component.
To use the component WDR_SELECT_OPTIONS in to our component we need to call this in currentcomponent controller.
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 4/18
Working with ALV and Select Options
For using the method in the component WDR_SELECT_OPTIONS into our component we need to call theinterface controller of WDR_SELECT_OPTIONS in current component controller.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 4
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 5/18
Working with ALV and Select Options
Creating Context Att ributes and Implement the Methods
In component context specify the attributes. We are taking material number as input and displaying materialdata as output. So create these attributed in the context of component controller.
Select the fields you want to display from the table MARA using “Add attribute from structure” button.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 5
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 6/18
Working with ALV and Select Options
Select what ever fields you want to display in the table.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 6
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 7/18
Working with ALV and Select Options
For creating the select options we need to do the following steps before displaying the WebDynproapplication.
• Instantiate the component controller
• Call the interface controller
• Init the selection screen.
• Create range tables.
• Assign selection fields to the range tableFor this we need to write the code in WDDOINIT method of component controller. This method will triggerbefore the application displayed. The following logic need to write in the WDDOINIT method.
*Instantiate the component controller
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_selection( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
*Call the interface controller and init the selection screen.
DATA lo_interfacecontroller TYPE REF TO iwci_wdr_select_options .
lo_interfacecontroller = wd_this->wd_cpifc_selection( ).
wd_this->g_handler = lo_interfacecontroller->init_selection_screen(
).
*Create Range table
DATA it_ran TYPE REF TO data.
CALL METHOD wd_this->g_handler->create_range_table
EXPORTING
i_typename = 'MATNR'
RECEIVING
rt_range_table = it_ran.
*Add the Selection fields to the range table
CALL METHOD wd_this->g_handler->add_selection_field
EXPORTING
i_id = 'MATNR'
it_result = it_ran.
G_handelr will be the global attribute of component controller of type IF_WD_SELECT_OPTIONS.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 7
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 8/18
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 9/18
Working with ALV and Select Options
Create view container element in the layout of the view. In this view container we need to place the selectoptions.
Crate one button. If you click this button material information will display in the table. In button properties giveaction as GO.
If you give the property as GO, then one event handler will generate for this button with nameONACTIONGO. In this handler you need to write the code that you want to execute when ever button ispressed.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 9
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 10/18
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 11/18
Working with ALV and Select Options
Embed the View in to Window
In window embed the view MAIN_VIEW.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 11
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 12/18
Working with ALV and Select Options
Embed SELECTION_SCREEN view in view container element. SELECTION_SCREEN view is the usedcomponent WDR_SELECT_OPTIONS view.
After embedding SELECTION_SCREEN view
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 12
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 13/18
Working with ALV and Select Options
In view contained element 1 embeds the TABLE view. This view is from the used componentSALV_WD_TABLE
After embedding the table view
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 13
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 14/18
Working with ALV and Select Options
In interface controller of the component usage map the DATA with the node MATERIAL of the componentcontroller context, as we are going to display MATERIAL contents in ALV.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 14
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 15/18
Working with ALV and Select Options
Creating WebDynpro Application
Create WebDynpro application. And save it.
Activate the WebDynpro component.
Test the WebDynpro application.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 15
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 16/18
Working with ALV and Select Options
Result
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 16
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 17/18
Working with ALV and Select Options
Related Content
Web Dynpro for ABAP - Getting Started
WDA Tutorial II: Using Select Optionsin a WDA Application
For more information, visit the User Interface Technology homepage.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com
© 2008 SAP AG 17
8/12/2019 Working With ALV and Select Options
http://slidepdf.com/reader/full/working-with-alv-and-select-options 18/18
Working with ALV and Select Options
Disclaimer and Liabili ty Notice
This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is notsupported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article orcode sample, including any liability resulting from incompatibility between the content within this document and the materials andservices offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of thisdocument.