on 05-04-2009 7:26 AM
Hi All,
I have Created one Custom push button in the Standard ALV to select all check boxes in the ALV column. I have created one action in the View controller and written the code for seleting all the check boxes.
Now my problem is : How can i connect this action to my custom push button .
Kindly help me with the steps to follow.
Cheers,
srak.
Hi Srak,
Please refer to this article[Generating Self-Defined Functions for ALV|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110]. I will be helpful.
Regards
Arjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srak,
I hope that you were able to create the button and you are facing the problem in triggerring that button.
For that follow the steps:
- Create an method in the view and in the method type drop down , select event handler.
- After that click on the event cell for that event handler method and then press F4 and the select ON_FUNCTION.
- After that simply use the code given in the article.
I hope it helps.
Regards
Arjun
Hey!
First step, you need to add one self-defined button to standard toolbar of alv grid.
Code of sample :
* Add self-defined button to toolbar of alv
DATA: LR_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE,
LR_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
LR_CONFIG_TABLE TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
LR_SALV_SETTINGS TYPE REF TO IF_SALV_WD_TABLE_SETTINGS,
LR_BUTTON TYPE REF TO CL_SALV_WD_UIE_BUTTON,
LR_FUNCTION TYPE REF TO CL_SALV_WD_FUNCTION,
LR_FUNCTIONS TYPE REF TO IF_SALV_WD_FUNCTION_SETTINGS,
LR_FE_BUTTON01 TYPE REF TO CL_SALV_WD_FE_BUTTON.
LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_GRID( ).
IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
LR_CMP_USAGE->CREATE_COMPONENT( ).
ENDIF.
LR_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_GRID( ).
LR_CONFIG_TABLE = LR_INTERFACECONTROLLER->GET_MODEL( ).
LR_SALV_SETTINGS ?= LR_CONFIG_TABLE.
LR_FUNCTIONS ?= LR_CONFIG_TABLE.
CALL METHOD LR_FUNCTIONS->CREATE_FUNCTION
EXPORTING
ID = 'CUSTOMER_DETAIL'
RECEIVING
VALUE = LR_FUNCTION.
CREATE OBJECT LR_FE_BUTTON01.
CALL METHOD LR_FE_BUTTON01->SET_TEXT
EXPORTING
VALUE = 'Customer Detail'.
CALL METHOD LR_FE_BUTTON01->set_image_source
EXPORTING
VALUE = 'WEBICON_CHECKED'.
CALL METHOD LR_FUNCTION->SET_EDITOR
EXPORTING
VALUE = LR_FE_BUTTON01.
CALL METHOD LR_FUNCTION->SET_FUNCTION_STD
EXPORTING
VALUE = IF_SALV_WD_C_STD_FUNCTIONS=>DEFAULT.
Second step,you need to define your event handler method that method type is must event handler and event is must ON_FUNCTION. Then,you need to add logic code in this mehod.
Code of sample:
method DISPLAY_DETIAL .
* Define local variables
DATA: LV_FUNCTION_ID TYPE STRING,
LV_INDEX TYPE I,
LV_NO_SELECTION TYPE I,
LT_SBOOK TYPE TABLE OF SBOOK,
LS_SBOOK TYPE SBOOK,
LV_CUSTOMID TYPE SBOOK-CUSTOMID,
EXPORTING_NODE TYPE REF TO IF_WD_CONTEXT_NODE,
CUSTOMER_NODE TYPE REF TO IF_WD_CONTEXT_NODE,
LR_CMP_API TYPE REF TO IF_WD_COMPONENT,
LR_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER,
LR_API TYPE REF TO IF_WD_VIEW_CONTROLLER,
LR_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER.
CASE R_PARAM->ID.
WHEN 'CUSTOMER_DETAIL'.
* Read selected row data
EXPORTING_NODE = WD_CONTEXT->GET_CHILD_NODE( 'EXPORTING' ).
LV_INDEX = EXPORTING_NODE->GET_LEAD_SELECTION_INDEX( ).
LV_NO_SELECTION = EXPORTING_NODE->NO_SELECTION.
IF LV_INDEX <> LV_NO_SELECTION .
CALL METHOD EXPORTING_NODE->GET_STATIC_ATTRIBUTES
IMPORTING
STATIC_ATTRIBUTES = LS_SBOOK.
CUSTOMER_NODE = WD_CONTEXT->GET_CHILD_NODE( 'CUSTOMER' ).
CALL METHOD CUSTOMER_NODE->SET_ATTRIBUTE
EXPORTING
VALUE = LS_SBOOK-CUSTOMID
NAME = 'ID'.
* Popup customer detail window
LR_CMP_API = WD_COMP_CONTROLLER->WD_GET_API( ).
LR_WINDOW_MANAGER = LR_CMP_API->GET_WINDOW_MANAGER( ).
IF WD_THIS->M_POPUP is initial.
WD_THIS->M_POPUP = LR_WINDOW_MANAGER->CREATE_WINDOW(
WINDOW_NAME = 'ZWD_WINDOW02'
TITLE = 'Customer Detail Information'
BUTTON_KIND = IF_WD_WINDOW=>CO_BUTTONS_YESNOCANCEL
MESSAGE_TYPE = IF_WD_WINDOW=>CO_MSG_TYPE_QUESTION ).
CALL METHOD WD_THIS->M_POPUP->SET_WINDOW_SIZE
EXPORTING
WIDTH = '300'
HEIGHT = '500'.
ENDIF.
WD_THIS->M_POPUP->OPEN( ).
WD_THIS->M_POPUP->SET_CLOSE_IN_ANY_CASE( ABAP_FALSE ).
ELSE.
LR_API = WD_THIS->WD_GET_API( ).
LR_MESSAGE_MANAGER = LR_API->GET_MESSAGE_MANAGER( ).
CALL METHOD LR_MESSAGE_MANAGER->REPORT_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'You must select one row. Then click customer butoon.'.
ENDIF.
WHEN OTHERS.
ENDCASE.
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.