Step by Step Guide For Using 'SUBSCRIBE - To - Button - Event' Method of A Pop-Up Window in WebDynpro ABAP
Step by Step Guide For Using 'SUBSCRIBE - To - Button - Event' Method of A Pop-Up Window in WebDynpro ABAP
‘SUBSCRIBE_to_button_Event’
Method of a pop-up Window in
WebDynpro ABAP
Applies to:
This document applies to SAP ECC 6.0, SAP NetWeaver 2004s. For more information, visit the Web Dynpro
ABAP homepage.
Summary
This article provides a step by step guide for using the „subscribe_to_button_event‟ method of a pop-up
window in WebDynpro ABAP with a simple example.
Author: Aisurya Kumar Puhan
Company: Incture Technologies Pvt Ltd.
Created on: 20 July, 2011
Author Bio
Aisurya Kumar Puhan is working as SAP NetWeaver Consultant in Incture Technologies Pvt Ltd. He
has around 3 years of experience in SAP ABAP, including 1 year in WebDynpro ABAP
development.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 1
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
Table of Contents
Introduction ......................................................................................................................................................... 3
Scenario .............................................................................................................................................................. 3
Step by Step Guide ............................................................................................................................................. 3
Step 1: Create webdynpro component ........................................................................................................... 3
Step 2: Add the standard ALV component..................................................................................................... 3
Step 3: Use the standard component to the component controller ................................................................ 4
Step 4: Node Creation in Component controller ............................................................................................. 4
Step 5: View Creation ..................................................................................................................................... 5
Step 6: Context mapping................................................................................................................................. 5
Step 7: Interface controller mapping ............................................................................................................... 5
Step 8: Business Logic.................................................................................................................................... 6
Step 9: Embed View........................................................................................................................................ 6
Step 10: Embed the standard table ................................................................................................................ 6
Step 11: Create a webdynpro application ....................................................................................................... 7
Step 12: Window creation ............................................................................................................................... 7
Step 13: View Creation ................................................................................................................................... 8
Step 14: Embed View...................................................................................................................................... 8
Step 15: Mapping ............................................................................................................................................ 8
Step 16: UI designing ...................................................................................................................................... 8
Step 17: Attribute creation .............................................................................................................................. 9
Step 18: Coding inside the button. .................................................................................................................. 9
Step 19: Creation of action. .......................................................................................................................... 10
Step 20: Coding in WDDOMODIFYVIEW ..................................................................................................... 10
Step 21: Method for message handling. ....................................................................................................... 11
Step 22: Coding inside the Action of button of pop-up . ............................................................................... 12
Step 23 : Test application.............................................................................................................................. 12
Related Content ................................................................................................................................................ 14
Disclaimer and Liability Notice .......................................................................................................................... 15
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 2
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
Introduction
This article provides a step by step guide for creating an ALV report using standard WD component and
subscribing to the action for a standard button of a Pop-up Window .
When we create an external pop-up window, we also assign somes standard buttons like YesNo ,OkCancel
etc . In most cases, end user requirement is to perform some action when the standard button is clicked in
the external window .
Scenario
Deleting a record from an ALV using the pop-up window standard button.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 3
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 4
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 5
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 6
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
Note : Our main work starts from here. Requirement is to delete the selected record with pop up , when DELETE button
is clicked.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 7
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 8
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'ZDELETE_POP_UP'
* title =
* close_in_any_case = abap_true
message_display_mode = if_wd_window=>co_msg_display_mode_selected
* close_button = abap_true
button_kind = if_wd_window=>CO_BUTTONS_YESNO
message_type = if_wd_window=>co_msg_type_none
* default_button = if_wd_window=>co_button_ok
).
wd_comp_controller->go_window = lo_window.
lo_window->open( ).
endmethod.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 9
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
Note : Here we have to subscribe the button event for “ YES “ and also create an action for this.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 10
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
method GENERATE_MSG .
lo_api_controller ?= wd_This->Wd_Get_Api( ).
* report message
CALL METHOD lo_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = 'ZTEST_POP_UP'
MSGNO = '000'
MSGTY = 'S' .
endmethod.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 11
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
method ONACTIONACT_YES .
DATA lo_nd_zdetails TYPE REF TO if_wd_context_node.
DATA lo_el_zdetails TYPE REF TO if_wd_context_element.
DATA ls_zdetails TYPE wd_this->element_zdetails.
DATA lt_zdetails TYPE wd_this->elements_zdetails.
* navigate from <CONTEXT> to <ZDETAILS> via lead selection
lo_nd_zdetails = wd_context->get_child_node( name = wd_this->wdctx_zdetails ).
wd_this->GENERATE_MSG( ).
endmethod.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 12
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
Now when you click “Yes” the selected record is deleted with success message.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 13
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
Related Content
Window Manager
Closing the main window from Pop-up window
Editable ALV Fields
For more information Visit Web Dynpro ABAP homepage.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 14
Step by Step Guide for using ‘subscribe_to_button_Event’ Method of a pop-up Window in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 15