#Get tab-separated tabular data from clipboard and parse it
#
TYPES:
BEGIN OF ty_clipdata,
data TYPE c LENGTH 500,
END OF ty_clipdata.
DATA: lt_clipdata TYPE STANDARD TABLE OF ty_clipdata.
DATA: ls_clipdata LIKE LINE OF lt_clipdata.
DATA: lv_clip_len TYPE i.
CONSTANTS: c_tab TYPE c VALUE cl_bcs_convert=>gc_tab.
DATA: lt_record TYPE STANDARD TABLE OF ty_clipdata.
DATA: ls_record LIKE LINE OF lt_record.
FIELD-SYMBOLS: <lfs_field> TYPE any.
TYPES: BEGIN OF lty_agr,
myfield1 TYPE myfield,
myfield2 TYPE urfield,
END OF lty_agr.
DATA: lt_data TYPE STANDARD TABLE OF lty_agr,
ls_data TYPE lty_agr,
lt_agr_db TYPE STANDARD TABLE OF lty_agr.
FIELD-SYMBOLS: <lfs_data> LIKE LINE OF lt_data.
*&---------------------------------------------------------------------*
*& Form GET_CLIP_DATA
*&---------------------------------------------------------------------*
* Get tab-separated tabular data from clipboard and parse it
*----------------------------------------------------------------------*
FORM get_clip_data .
* --- Get clipboard ---
cl_gui_frontend_services=>clipboard_import(
IMPORTING
data = lt_clipdata
length = lv_clip_len
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4 ).
IF sy-subrc NE 0.
MESSAGE 'Error while importing data from clipboard' TYPE 'E'.
ENDIF.
* --- Parse data ---
LOOP AT lt_clipdata INTO ls_clipdata.
SPLIT ls_clipdata AT c_tab INTO TABLE lt_record.
" SPE >>>
IF lt_record[ 1 ]-data(2) <> 'ZS'. " Your filter
CONTINUE.
ENDIF.
" <<< SPE
APPEND INITIAL LINE TO lt_data ASSIGNING <lfs_data>.
LOOP AT lt_record INTO ls_record.
ASSIGN COMPONENT sy-tabix OF STRUCTURE <lfs_data> TO <lfs_field>.
IF sy-subrc EQ 0.
<lfs_field> = ls_record-data.
ENDIF.
ENDLOOP.
ENDLOOP.
IF lt_data[] IS INITIAL.
MESSAGE 'No data parsed from clipboard' TYPE 'E'.
ENDIF.
ENDFORM. " GET_CLIP_DATA