Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
708 views6 pages

Programming Dynamic ALV in WebDynpro For ABAP

The document describes how to create a dynamic ALV table in a WebDynpro for ABAP application based on user selections. It involves: 1) Creating a WebDynpro component and view to contain the ALV 2) Defining the SALV_WD_TABLE component and controller usage 3) Embedding the SALV component's TABLE view into the view container 4) Reading a dynamic context node to determine which data fields were selected 5) Dynamically building the ALV structure based on the selections 6) Passing the dynamic structure to the ALV interface controller.

Uploaded by

Adriano Oliveira
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
708 views6 pages

Programming Dynamic ALV in WebDynpro For ABAP

The document describes how to create a dynamic ALV table in a WebDynpro for ABAP application based on user selections. It involves: 1) Creating a WebDynpro component and view to contain the ALV 2) Defining the SALV_WD_TABLE component and controller usage 3) Embedding the SALV component's TABLE view into the view container 4) Reading a dynamic context node to determine which data fields were selected 5) Dynamically building the ALV structure based on the selections 6) Passing the dynamic structure to the ALV interface controller.

Uploaded by

Adriano Oliveira
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 6

Programming dynamic ALV in WebDynpro for ABAP

By Rodrigo Arenas Arriola, Eidon Software, Mexico

Scenario: To create a dynamic ALV based on a dynamic context node in Web Dynpro for ABAP. As a Case study, well use the SFLIGHT flight data to select which data fields we want to show in an ALV. Procedure: 1. First, well create the ZWD_SFLIGHT Web Dynpro component.

2.

Next, we create a view

So, we have a WD component and a view. Now, we can insert a ViewContainerUIElement element in the view to show the ALV. The components name must be VCU_ALV.

We can activate in this moment. 3. In the Used Components tab of the Web Dynpro Component, we have to define the SALV_WD_TABLE component in order to use the ALV component model within the view.

4.

Next, we must define a Controller Usage in the COMPONENTCONTROLLER and in the View Properties tab. To do that, press the button .

Then, we have an ALV component as well as its controller.

5. 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 ViewContainerUIElement (VCU_ALV) that we have created before.

6.

Then, select the next option.

7.

Now, we are ready to build the dynamic context node to give ALV its structure. For example purposes, well create 5 checkboxes which means the columns that can be showed (not necessary all of them) in the ALV. In this case, well use CARRID, CONNID, FLDATE, PRICE and CURRENCY of SFLIGHT transparent table.

NOTE: You also have to create a button and an event handler method where you will validate which checkboxes are marked in order to know which fields you will show in the ALV. 8. We have to validate checkboxes entries to know which fields we must include in the ALV. Next code reads the context node and validates each checkbox in order to build the structure.

******* First, read the context node: ******* DATA: node_param TYPE REF TO if_wd_context_node, elem_param TYPE REF TO if_wd_context_element, stru_param TYPE if_v_main=>element_param . * navigate from <CONTEXT> to <PARAM> via lead selection

node_param = wd_context->get_child_node( name = if_v_main=>wdctx_param ). * get element via lead selection elem_param = node_param->get_element( ). * get all declared attributes elem_param->get_static_attributes( IMPORTING static_attributes = stru_param ). ******* Next, validate which fields you will use as ALV columns ******* DATA: ls_component TYPE cl_abap_structdescr=>component, lr_type TYPE REF TO cl_abap_datadescr, lt_components TYPE cl_abap_structdescr=>component_table. IF stru_param-carrid = 'X'. lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'S_CARR_ID' ). ls_component-name = 'CARRID'. ls_component-type = lr_type . APPEND ls_component TO lt_components. ENDIF. IF stru_param-connid = 'X'. lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'S_CONN_ID' ). ls_component-name = 'CONNID'. ls_component-type = lr_type . APPEND ls_component TO lt_components. ENDIF. IF stru_param-fldate = 'X'. lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'S_DATE' ). ls_component-name = 'FLDATE'. ls_component-type = lr_type . APPEND ls_component TO lt_components. ENDIF. IF stru_param-price = 'X'. lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'S_PRICE' ). ls_component-name = 'PRICE'. ls_component-type = lr_type . APPEND ls_component TO lt_components. ENDIF. IF stru_param-currency = 'X'. lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'S_CURRCODE' ). ls_component-name = 'CURRENCY'. ls_component-type = lr_type . APPEND ls_component TO lt_components. ENDIF. ******* Next, create a new structure and assign it to a new dynamic context node ******* DATA: lr_root_info TYPE REF TO if_wd_context_node_info , lr_node_info TYPE REF TO if_wd_context_node_info, lr_structdescr TYPE REF TO cl_abap_structdescr. call method cl_abap_structdescr=>create exporting p_components = lt_components receiving p_result = lr_structdescr. * Get context node info

lr_root_info = wd_context->get_node_info( ). * Generate new node with the dynamic structure CALL METHOD lr_root_info->add_new_child_node EXPORTING name = 'DATA' is_initialize_lead_selection = abap_false static_element_rtti = lr_structdescr is_static = abap_false RECEIVING child_node_info = lr_node_info. * get instance of new node DATA: dyn_node TYPE REF TO if_wd_context_node. dyn_node = wd_context->get_child_node( name = 'DATA' ). ******* Last, Get reference to model ******* DATA: lo_interfacecontroller type ref to iwci_salv_wd_table. lo_interfacecontroller = wd_this->wd_cpifc_alv( ). lo_interfacecontroller->set_data( dyn_node ).

9.

Now, you need to create a Web Dynpro Application.

10. After that, lets run our program. We can show an ALV table with a dynamic structure based on the checked fields.

You might also like