Académique Documents
Professionnel Documents
Culture Documents
Applies to:
Web DynPro ABAP. For more information, visit the Web Dynpro ABAP homepage.
Summary
Though its always better to give all the design to your WDC before running it, sometimes dynamic creation of ALV and the layout can be a good idea. It saves the effort thatd go into creating nodes and modifying the attributes time and again. This manual guides you through the creation of an ALV WebdynPro Component that builds itself up even as it runs. Author: Pushpraj Singh
Author Bio
Pushpraj Singh is currently placed as a senior ABAP consultant at Infosys. He has worked on a few Web DynPro developments and find the field very interesting.
Table of Contents
Pre requisite Skills......................................................................................................................................... 3 Steps to create a dynamically structured ALV WebdynPro Application ........................................................... 3 Related Content .......................................................................................................................................... 15 Disclaimer and Liability Notice ..................................................................................................................... 16
3. Go to the WDC (WebdynPro Component) you just created and add the usage of the ALV component (Component SALV_WD_TABLE)
4. Now go to the MAIN view and to the Properties tab. (In case your SAPGUI doesnt create the MAIN view automatically create it manually) Click on the Create Controller Usage button and choose both the ALV component usages from the pop up.
5. Go to the Layout tab of the view and create a group. In this group add a View Container UI Element with the id view_cont.
6. Now go to the Methods tab of the view and write the following code in the method WDDOMODIFYVIEW (Method for Modifying the View Before Rendering).
METHOD wddomodifyview.
"this check avoids the creation of the node 'ALV' again on "any ALV event and thus prevents dump
IF first_time EQ abap_true. TYPES : lst_sflight TYPE STANDARD TABLE OF sflight. DATA : li_sflight TYPE lst_sflight, lw_sflight TYPE sflight.
********************************************************************** "this is the portion of the code where we can add or remove fields "to or from the ALV
wd_this->fill_comp( EXPORTING fv_name = 'CARRID'
********************************************************************** "create the desired structure and assign it to a new dynamic context node
DATA: lo_root_info TYPE REF TO if_wd_context_node_info, lo_node_info TYPE REF TO if_wd_context_node_info, lo_structdescr TYPE REF TO cl_abap_structdescr.
METHOD fill_comp. DATA : lw_comp TYPE cl_abap_structdescr=>component, lv_type TYPE REF TO cl_abap_datadescr. lw_comp-name = fv_name. lv_type ?= cl_abap_typedescr=>describe_by_name( p_name = fv_data_element ). lw_comp-type = lv_type. APPEND lw_comp TO fi_comp. ENDMETHOD.
7. In order to show the ALV inside the View, we must embed the Table View of the SALV_WD_TABLE component. Go to the Window and select the View Container UI Element (view_cont) that was created earlier. Right click on it.
As we can see, without having to create (or change) the context we can get any structure we want by simply doing a few changes to the code written in the method WDDOMODIFYVIEW.
Related Content
http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/201ddd3b-b4ce-2b10-8883-880ae8147f89 http://www.saptechnical.com/Tutorials/WebDynproABAP/DynamicALV/Demo.htm ?blog=/pub/wlg/2888 For more information, visit the Web Dynpro ABAP homepage.