You are likely to be using CTRL-X and CTRL-Y all day long, copy and paste texts or other objects using the windows clipboard. Reading this clipboard and setting it's content can be done with function modules CLPB_IMPORT
and CLPB_EXPORT
. Texts only.
The object-oriented way to do this is also available under class cl_gui_frontend_services
methods clipboard_export
and clipboard_import
.
data: lv_returncode type i, lt_textlines type standard table of tline. append 'The information you needed' to lt_textlines. cl_gui_frontend_services=>clipboard_export( importing data = lt_textlines changing rc = lv_returncode exceptions others = 4 ). if sy-subrc = 0 and lv_returncode = 0. message 'Information placed on clipboard' type 'S'. endif.
Btw: the function modules also use the object-oriented way. It's the preferred way ! And another btw: I tried passing a table of strings to this method which didn't go very well (raise exception "SYSTEM_FAILURE". Make sure your data table is defined as something character type (as per example CLPB_EXPORT
8000+ characters is no problem).
Oops version
This functionality is also captured under the class CL_GUI_FRONTEND_SERVICES
methods CLIPBOARD_EXPORT
and CLIPBOARD_IMPORT
.