cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to close Web UI Pop Up from GUI

former_member184390
Participant
0 Kudos

Hello All, We are looking at reducing the clicks for the end user and one such requirement is to automatically close the UI Pop Up based on the asynchronous inbound web service call. Below is the more information and back ground. 1) User clicks on Process Payment Button. It opens a pop up  and in the background makes a call to third party system to validate the information. 2) The third party application sends back asynchronous message with payment status information and updates a ztable. Currently users checks the status information in the ztable and accordingly performs reprocessing/closure options in the pop up manually. 3) We want to automatically close the UI pop up based on the status update from asynchronous call back. This way it will minimize the user clicks. I am aware that it's practically not possible to control the UI Elements( Pop Up) outside the session i.e. from GUI FM or any other object. However, i want to reach out to experts opinion in this group for any possible options how to close the UI Pop up based on the response from asynchronous call. is it possible to write the POP UP Information( like pop up instance information) in runtime memory and try accessing the same from GUI Object. Thank you. Regards, Uday

View Entire Topic
anborck
Participant
0 Kudos

Hello Uday,

the best way to do this would be via Javascript.

You can use the method CL_CRM_WEB_UTILITY=>CREATE_SERVICE_SCRIPT to add a server communication to your popup. The classname IV_HANDLER_CLASS_NAME needs to implement the interface IF_CRM_WEB_CALLBACK.

Now you can poll the server (eg every 500ms) and the return (eg boolean) of your call-back class needs to be given to the Javascript callback function IV_JS_CALLBACK_FUNCTION. There it should be possible to close the window by Javascript.

It could happen that the browser does not allow closing the window by itself. Then you need to implement this solution in the parent window, which always should have the permission to close the child window.

Hope this helps

Andre

former_member184390
Participant
0 Kudos

Hello Andre, Many thanks for your valuable inputs. Much appreciated. This has given us a firm confirmation that this is possible via java script. Incase you have any examples or references on the implementation of your classes, pl share. It would be very helpful as there were only2-3 objects found in where used search in sap crm. While waiting for inputs yesterday, we have come up with below design approach which is slightly in similar lines of your view point. 1) User clicks on Process Payment Button. It opens a pop up  and in the background makes a call to third party system to validate the information. Soln Step1:At this point, we were planning to import the guid information of the transaction along with a Boolean variable to memory using Export statement. 2) The third party application sends back asynchronous message with payment status information and updates a ztable. Currently users checks the status information in the ztable and accordingly performs reprocessing/closure options in the pop up manually. Soln Step2: Up on the receipt of asynchronous update, import the values from memory and set the Boolean variable accordingly as per the payment status. 3) We want to automatically close the UI pop up based on the status update from asynchronous call back. This way it will minimize the user clicks. Soln Step 3: Create a new button and hide the button from the display. Have a javascript in the pop up.htm to trigger the server event up on change in the Boolean variable in memory . This is achieved through constantly checking the variable value in set time intervals. Trigger the user click event( Pop UP Close) using the javascript method button.click(). Pl let me know your thoughts on the above approach. Thanks, Uday

anborck
Participant
0 Kudos

Hello Uday,

yes I think this will work. I already analysed a ticket which has similar requirements and came up with this approach. I did not have the chance to complete the solution yet, but here is the first idea how to handle it.

The pro-approach would be to use an APC (ABAP Push Channel) instead of the polling mechanism. Therefore you can check out this blog:

The security measures of the browser are the most unpredictable part for me on this solution. I am not sure if it is so easy to close the browser window by invoking the button. Please let me know if this works for you. I would be also glad if you could send me an example of a working script for closing the browser window.

Here some snippets that might be helpful:

For the BSP-page:

lo_page_context ?= me->_m_page_context.

lv_ajax_script = cl_crm_web_utility=>create_service_script(

                iv_handler_class_name = 'ZCL_DET_AJAX_HANDL'

                iv_controller_id      = lo_page_context->m_page_id

                iv_js_callback_function = 'closeDetailView' ).

<script type="text/javascript">

  function getCloseFlagAjaxCall(){

    <%= lv_ajax_script %>

  }

  function closeDetailView(reqObj) {

    var response = reqObj.request.responseText;

    if(response=="CLOSE"){

      alert("TEST");

      window.close();

    }else{

      setTimeout(getCloseFlagAjaxCall, 3000);

    }

  }

</script>

Implementation in the callback class ZCL_DET_AJAX_HANDL:

METHOD if_crm_web_callback~handle_request.

  lo_view_controller ?= ir_controller->m_parent.

  lo_comp_controller ?= lo_view_controller->m_parent.

  lo_appl_controller ?= lo_comp_controller->m_parent.

  lo_cuco = lo_appl_controller->go_cuco.

  IF lo_cuco->gv_close_popup = abap_true.

    CLEAR lo_pmr_cuco->gv_close_popup.

    ir_server->response->set_cdata('CLOSE').

  ENDIF.

ENDMETHOD.

For the in-memory variable you need to check if it is set and read by the same user. If not you can use shared memory objects.

Glad that I could help

Andre

former_member184390
Participant
0 Kudos

Many Thanks Andre for your swift response and sharing helpful information. I will surely share the solution details once my team completes the proof of concept. Once again, thank you and have a nice day. Regards, Uday