Skip to Content
0
Oct 12, 2006 at 02:04 AM

CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_IMPORT

174 Views

Hello everyone,

I Call the method in my program, I want to get some data from clipboard from MS excel,then divide up the data into work area by key split at '#'.But sy-subrc = 4 when pass the sentence.

The codes as following:

TYPES: BEGIN OF TY_OUTPUT,
       TEXT1(10),
       TEXT2(10),
       TEXT3(30),
       END OF TY_OUTPUT.
DATA: OUTPUT_TAB TYPE TY_OUTPUT OCCURS 0 WITH HEADER LINE.
TYPES: BEGIN OF TY_DATA,
      TEXT(80) ,
      END OF TY_DATA.
DATA: DATA_TAB TYPE TY_DATA OCCURS 0 .
DATA: DATA_WA TYPE TY_DATA.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_IMPORT
  IMPORTING
    DATA                 = DATA_TAB
*      LENGTH               =
    EXCEPTIONS
    CNTL_ERROR           = 1
    ERROR_NO_GUI         = 2
    NOT_SUPPORTED_BY_GUI = 3
    OTHERS               = 4.
IF SY-SUBRC = 0.
  LOOP AT DATA_TAB INTO DATA_WA-TEXT.
    SPLIT DATA_WA-TEXT AT '#' INTO
       OUTPUT_TAB-TEXT1
       OUTPUT_TAB-TEXT2
       OUTPUT_TAB-TEXT3.

    IF SY-SUBRC = 0 .
      APPEND OUTPUT_TAB.
    ELSEIF SY-SUBRC = 4.
      WRITE: / 'Split error:', DATA_WA-TEXT.
    ENDIF.
  ENDLOOP.
ELSE.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Copy the following MS Excel data to clipboard:

ZT00101 AB001 ABC01

ZT00102 AB002 ABC02

ZT00103 AB003 ABC03

ZT00104 AB004 ABC04

ZT00105 AB005 ABC05

ZT00106 AB006 ABC06

ZT00107 AB007 ABC07

Error list after run it:

Split error: ZT00101#AB001#ABC01

Split error: ZT00102#AB002#ABC02

Split error: ZT00103#AB003#ABC03

Split error: ZT00104#AB004#ABC04

Split error: ZT00105#AB005#ABC05

Split error: ZT00106#AB006#ABC06

Split error: ZT00107#AB007#ABC07

Why can not split the DATA_WA-TEXT?

Could you give me any idea?

Thanks and Regards,

Colin.

Message was edited by: Colin

Message was edited by: Colin