Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Capture external copy event in ABAP

former_member182550
Active Contributor
0 Kudos

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

10 REPLIES 10

gaurav_b_chaudhary
Discoverer
0 Kudos

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

0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

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?

0 Kudos

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

0 Kudos

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?

I use the cl_Gui_Toolbar instance.

0 Kudos

Full OO 😉

0 Kudos

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

0 Kudos

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.

0 Kudos

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