Creating Custom button in ALV toolbar in webdynpro

..Previous

10. Go to methods tab and in WDDOINIT method on MAIN view using code wizard set the ‘table’ node as table operation. As shown below.

Source code in WDDOINIT

 DATA LO_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.

    
DATA LT_TABLE TYPE WD_THIS->ELEMENTS_TABLE.
    
data ls_table like LINE OF LT_TABLE.
SELECT * 
from vbap
into CORRESPONDING FIELDS OF TABLE LT_TABLE
UP TO 20 rows.

*   navigate from <CONTEXT> to <TABLE> via lead selection
    LO_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_TABLE ).

*
    LO_ND_TABLE->BIND_TABLE( NEW_ITEMS = LT_TABLE SET_INITIAL_ELEMENTS = ABAP_TRUE ).

11.     Go to Component Usage and under properties tab click create to add the ZD_ALV_ROWCOLOR component.

Select the ZD_ALV_ROWCOLOR component to add it.

12. Go to Component Usage and under Context tab Map the ALV node TABLE of the component controller to the DATA of the interface controller of ALV

13.     Go to layout tab of MAIN view and create a VIEWCONTAINER UI element under rootelementcontainer.

14. Go again to methods tab and in WDDOINIT method on MAIN view using code wizard instantiate and Create an instance of ALV Interface Controller. In the below code the Function code BUTTON is set to the button

Complete source code of wddoinit

method WDDOINIT .
*----------Alv column settings declarations---------*
  
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
        lt_columns         
TYPE salv_wd_t_column_ref,
        ls_columns         
LIKE LINE OF lt_columns,
        l_column   
TYPE REF TO cl_salv_wd_column.    
*----------alv toolbar button declarations---------*
  
DATA lr_buttonui TYPE REF TO cl_salv_wd_fe_button.
  
DATA button1 TYPE REF TO cl_salv_wd_function.    
    
    
DATA LO_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.
    
DATA LT_TABLE TYPE WD_THIS->ELEMENTS_TABLE.
    
data ls_table like LINE OF LT_TABLE.
SELECT *
from vbap
into CORRESPONDING FIELDS OF TABLE LT_TABLE
UP TO 20 rows.


*   navigate from <CONTEXT> to <TABLE> via lead selection
    LO_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_TABLE ).

*
    LO_ND_TABLE->BIND_TABLE( NEW_ITEMS = LT_TABLE SET_INITIAL_ELEMENTS = ABAP_TRUE ).

"instantiate
DATA LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.

LO_CMP_USAGE =   WD_THIS->WD_CPUSE_VBAP_ALV( ).
IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
  LO_CMP_USAGE->CREATE_COMPONENT( ).
ENDIF.
"get model
DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
LO_INTERFACECONTROLLER =   WD_THIS->WD_CPIFC_VBAP_ALV( ).

  
DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
  LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(
  ).
*----------Button creation on the alv toolbar---------*
  
CREATE OBJECT lr_buttonui.
  lr_buttonui->set_text(
'Button')."setting the text of the button on alv toolbar
  button1 = lv_value->if_salv_wd_function_settings~create_function( 
id = 'BUTTON')."creating the function for alv button
  button1->set_editor( lr_buttonui ). 

Click here to continue...

SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image