06-13-2017 11:19 AM
Hi,
A user selects some data in word or excel or some other non-sap application and then copies that data to the clipboard. Is there any way in ABAP to capture that event or message ?
I'm not talking about using sapevt or BP_EVENT_RAISE, I'm talking about a listener in an Abap class that will detect a windows copy event.
Thanks and regards,
Rich
06-13-2017 1:59 PM
Hi Rich,
Have you tried method CLIPBOARD_IMPORT of class CL_GUI_FRONTEND_SERVICES?
Although you will need to parse data in desired format.
Regards,
Gaurav Chaudhary
06-13-2017 2:59 PM
Hi Gaurav,
Thanks for the reply
Yes, I use that method when I am actually processing a 'paste' request. The problem is not importing data into SAP from the clipboard but telling whether there is any data there in the first place. (See my reply to Raymonds answer below).
Rich
06-13-2017 2:26 PM
Using CL_GUI_TIMER to periodically try some CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_IMPORT would not be very satisfactory...
So you could look for a copy of "SAP GUI Scripting API for the Windows and Java Platforms" to implement an Event Listener?
06-13-2017 2:48 PM
Hi Raymond,
Thanks for that. This is part of an interactive report where I want the paste button to be disabled until there is data to paste. I have tried with the timer approach but the one problem with that approach is that when the timer fires it causes a PAI which then causes all sorts of funny stuff with the cursor which makes the report hard to use and as you say would not be very satisfactory.
Having said that, the current code enables and disables the button correctly based upon the contents of the clipboard but the user has to perform some sort of action that ends up in a redisplay of the grid.
I shall have a look at your suggestion of "SAP GUI Scripting API for the Windows and Java Platforms" though.
Regards,
Rich
06-13-2017 3:06 PM
Don't trigger a PAI/PBO cycle on every trigger of CL_GUI_TIMER->FINISHED event with some CL_GUI_CFW=>SET_NEW_OK_CODE, trigger it only when status actually change, there was no copied data available and now there are some or vice-versa. Anyway you will be required to trigger the PAI/PBO cycle to change the status of the paste button or did you use some CL_GUI_TOOLBAR occurence?
06-13-2017 3:09 PM
06-13-2017 3:16 PM
06-13-2017 3:53 PM
Hi Raymond,
I had a nagging feeling I've been around this loop....
Even if I don't issue a CL_GUI_CFW=>SET_NEW_OK_CODE, you still get a PAI when the timer triggers even if you do nothing (unless you know something I don't ??)
Rich
06-14-2017 6:44 AM
AFAIK Not an actual PAI but a sync of the automation queue, often requiring to use some cursor/focus method to minimize impact on currently displayed screen?
test:
REPORT ztimercheck.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
on_finished
FOR EVENT finished OF cl_gui_timer
IMPORTING sender.
ENDCLASS. "lcl_event_receiver DEFINITION
PARAMETERS: p_date TYPE d.
DATA: event TYPE REF TO lcl_event_receiver,
timer TYPE REF TO cl_gui_timer,
texte TYPE c LENGTH 80.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD: on_finished.
GET TIME.
CONCATENATE 'Event triggered at' sy-uzeit INTO texte SEPARATED BY space.
MESSAGE texte TYPE 'S'.
CALL METHOD timer->run.
ENDMETHOD. "on_finished
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
AT SELECTION-SCREEN OUTPUT.
IF event IS INITIAL.
CREATE OBJECT: event, timer.
SET HANDLER event->on_finished FOR timer.
ENDIF.
timer->interval = 2.
CALL METHOD timer->run.
CONCATENATE 'PBO actually triggered at' sy-uzeit INTO texte SEPARATED BY space.
MESSAGE texte TYPE 'S'.
AT SELECTION-SCREEN.
CONCATENATE 'PAI actually triggered at' sy-uzeit INTO texte SEPARATED BY space.
MESSAGE texte TYPE 'S'.
LEAVE PROGRAM.
06-14-2017 8:28 AM
Morning Raymond!
Your example exactly shows the problem. Whilst it may not be a PAI as such it still screws the screen up. I'll continue digging for a little while and If I find something I'll add it to this thread.
Thanks for your help and suggestions though!
Rich