There may be a requirement where you may display certain data’s in the pop up and by performing some action in the pop up the action has to be completed and the web browser has to be closed automatically.
In the following post we are going to see how to close the web browser by the action on the window.
Take any component which was previously developed by you and we will proceed from there.
Step 1: In order to close the browser the application parameter close_window of the Webdynpro application has to be set to ‘X’. Go to the application created for your component and in parameters tab include the parameter close_window.
When the value of this parameter close_window is set to X the system will close the browser.
Step 2: Go to the layout tab of the view controller and insert a UI element.
Provide the text and create an action for the UI element.
Step 3: Go to the window controller and created an outbound plug of type exit plug.
Step 4: In the event handler for the method do the following.
1. Get the reference of the view controller
2. Get the reference of the window in which the view is contained.
3. Set the parameter of the close_window as x and specify the outbound plug to be triggered.
Getting the reference variable of the view controller.
Using code wizard generate the code for getting the getting the reference of the view controller.
Call the wd_get_api method of the current controller to get the reference of the current controller.
Code will be generated as below.
Now the reference of the view V_MAIN will be in the variable lo_api_v_main.
In the interface type of the reference variable there is a method called GET_EMBEDDING_WINDOW_CTLR which will return the reference of the window in which the current view has been embedded.
Call this method using pattern to generate the codes.
Code will be generated as below.
Modify the code as below.
Now using the reference of the window controllers set the application parameter and pass the plug to be triggered as shown below.
Using the method fire_plug of the interface for window pass the application parameter value and the plug to be triggerd.
Check the parameters of the method for better understanding of below code. This method contains two importing parameters.
If you check the table type wdr_event_parameter_list the value of the parameters is passed as the data reference variable. Hence format the data to be passed to the importing parameters “PARAMETERS” and pass it to the method.
Populating an internal table to be passed to import parameter “PARAMETER”.
Pass the data to the method as below.
Code will be generated as below.
Modify the code as below.
Code in the method:
DATA LO_API_V_MAIN TYPE REF TO IF_WD_VIEW_CONTROLLER.
LO_API_V_MAIN = WD_THIS->WD_GET_API( ).
DATA : LO_WINDOW TYPE REF TO IF_WD_WINDOW_CONTROLLER.
CALL METHOD LO_API_V_MAIN->GET_EMBEDDING_WINDOW_CTLR
RECEIVING
RESULT = LO_WINDOW.
DATA : IT_PARAMETERS TYPE wdr_event_parameter_list,
WA_PARAMETERS TYPE wdr_event_parameter,
LV_DATA TYPE REF TO DATA.
FIELD-SYMBOLS : <FS_PARA> TYPE ANY.
CREATE DATA LV_DATA TYPE C.
ASSIGN LV_DATA->* TO <FS_PARA>.
<FS_PARA> = 'X'.
WA_PARAMETERS-NAME = 'CLOSE_WINDOW'.
WA_PARAMETERS-VALUE = LV_DATA.
INSERT WA_PARAMETERS INTO TABLE IT_PARAMETERS.
CLEAR WA_PARAMETERS.
CALL METHOD LO_WINDOW->IF_WD_VIEW_CONTROLLER~FIRE_PLUG
EXPORTING
PARAMETERS = IT_PARAMETERS
PLUG_NAME = 'EXIT_PLUG' .
LO_API_V_MAIN = WD_THIS->WD_GET_API( ).
DATA : LO_WINDOW TYPE REF TO IF_WD_WINDOW_CONTROLLER.
CALL METHOD LO_API_V_MAIN->GET_EMBEDDING_WINDOW_CTLR
RECEIVING
RESULT = LO_WINDOW.
DATA : IT_PARAMETERS TYPE wdr_event_parameter_list,
WA_PARAMETERS TYPE wdr_event_parameter,
LV_DATA TYPE REF TO DATA.
FIELD-SYMBOLS : <FS_PARA> TYPE ANY.
CREATE DATA LV_DATA TYPE C.
ASSIGN LV_DATA->* TO <FS_PARA>.
<FS_PARA> = 'X'.
WA_PARAMETERS-NAME = 'CLOSE_WINDOW'.
WA_PARAMETERS-VALUE = LV_DATA.
INSERT WA_PARAMETERS INTO TABLE IT_PARAMETERS.
CLEAR WA_PARAMETERS.
CALL METHOD LO_WINDOW->IF_WD_VIEW_CONTROLLER~FIRE_PLUG
EXPORTING
PARAMETERS = IT_PARAMETERS
PLUG_NAME = 'EXIT_PLUG' .
Save and activate the whole component test the application.
Output:
Click on the close link your browser will be closed.
It was good information shared by you
ReplyDeleteSAP Training institute in Noida
SAP Training institute in Delhi
Thanks for posting
ReplyDeleteSAP pp training institute in Delhi
SAP pp training institute in Noida
Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.pmp certification in malaysia
ReplyDelete