在ABAP中的 CLASS :CL_GUI_FRONTEND_SERVICES中提供了两个方法来控制与剪贴板内容的导入导出,分别是:CLIPBOARD_EXPORT和CLIPBOARD_IMPORT。
CLIPBOARD_EXPORT是将一个内表的内容导入到剪贴板中,示例程序如下:
DATA rc TYPE i.
DATA:BEGIN OF itab OCCURS 0,
line(200) TYPE c ,
END OF itab.
itab-line = 'This is a test for abap'.
APPEND itab.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = itab[]
CHANGING
rc = rc
* EXCEPTIONS
* CNTL_ERROR = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLIPBOARD_IMPORT是将剪贴板中的内容导入到一个定义好的内表当中,示例程序如下:
DATA rc TYPE i.
DATA:BEGIN OF itab OCCURS 0,
line(200) TYPE c ,
END OF itab.
CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
DATA = itab[]
LENGTH = rc
* EXCEPTIONS
* CNTL_ERROR = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:'Total:' ,rc,' lines'.
loop at itab.
write / itab-line.
endloop.
转载:http://www.itpub.net/forum.php?mod=viewthread&tid=992169&extra=&ordertype=1&page=2