Created
February 20, 2018 13:37
-
-
Save AtomKrieg/80a1745fdb66ac9f6b027559b543504d to your computer and use it in GitHub Desktop.
Choose icon and double click it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
report icon_chooser. | |
class lcl_app definition create private. | |
public section. | |
class-methods new | |
returning value(ro_instance) type ref to lcl_app. | |
methods show. | |
private section. | |
constants mc_columns type i value 40. | |
data mt_icon type table of icon. | |
data mt_show type ref to data. | |
methods init. | |
methods create_table. | |
methods fill_table. | |
methods double_click | |
for event if_salv_events_actions_table~double_click | |
of cl_salv_events_table | |
importing row column. | |
endclass. | |
start-of-selection. | |
lcl_app=>new( )->show( ). | |
class lcl_app implementation. | |
method new. | |
create object ro_instance. | |
ro_instance->init( ). | |
endmethod. | |
method init. | |
select * from icon into table mt_icon. | |
create_table( ). | |
fill_table( ). | |
endmethod. | |
method create_table. | |
data ed type ref to cl_abap_elemdescr. | |
data lt_comp type abap_component_tab. | |
data ls_comp type abap_componentdescr. | |
data td type ref to cl_abap_tabledescr. | |
ed ?= cl_abap_typedescr=>describe_by_name( 'ICON_D' ). | |
do mc_columns times. | |
ls_comp-name = 'COL' && sy-index. | |
ls_comp-type = ed. | |
append ls_comp to lt_comp. | |
enddo. | |
td = cl_abap_tabledescr=>get( cl_abap_structdescr=>get( lt_comp ) ). | |
create data mt_show type handle td. | |
endmethod. | |
method fill_table. | |
field-symbols <table> type standard table. | |
field-symbols <line> type any. | |
field-symbols <cell> type any. | |
data ls_icon type icon. | |
data lv_offset type i. | |
assign mt_show->* to <table>. | |
loop at mt_icon into ls_icon. | |
lv_offset = ( sy-tabix - 1 ) mod mc_columns + 1. | |
if lv_offset = 1. | |
append initial line to <table> assigning <line>. | |
endif. | |
assign component lv_offset of structure <line> to <cell>. | |
if ls_icon-oleng <= 2. | |
<cell> = ls_icon-id. | |
endif. | |
endloop. | |
endmethod. | |
method show. | |
field-symbols <table> type standard table. | |
data salv type ref to cl_salv_table. | |
data events type ref to cl_salv_events_table. | |
data lo_columns type ref to cl_salv_columns_table. | |
assign mt_show->* to <table>. | |
cl_salv_table=>factory( | |
importing r_salv_table = salv | |
changing t_table = <table> ). | |
events = salv->get_event( ). | |
set handler me->double_click for events. | |
lo_columns ?= salv->get_columns( ). | |
lo_columns->set_headers_visible( abap_false ). | |
salv->display( ). | |
endmethod. | |
method double_click. | |
field-symbols <table> type standard table. | |
field-symbols <line> type any. | |
field-symbols <cell> type any. | |
data rc type i. | |
data lt_export type table of icon-name. | |
data ls_icon type icon. | |
assign mt_show->* to <table>. | |
read table <table> assigning <line> index row. | |
check sy-subrc = 0. | |
assign component column of structure <line> to <cell>. | |
check sy-subrc = 0 and <cell> is not initial. | |
read table mt_icon into ls_icon with key id = <cell>. | |
check sy-subrc = 0. | |
append ls_icon-name to lt_export. | |
cl_gui_frontend_services=>clipboard_export( | |
importing data = lt_export | |
changing rc = rc ). | |
message 'In clipboard' type 'S'. | |
endmethod. | |
endclass. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment