*&---------------------------------------------------------------------*
*& Report ZP_DV17_EXPLODE_INCLUDE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report zp_dv17_explode_include.
parameters report type rs38m-programm.
at selection-screen on value-request for report.
call function 'REPOSITORY_INFO_SYSTEM_F4'
exporting
object_type = 'PROG'
object_name = report
suppress_selection = 'X'
importing
object_name_selected = report
exceptions
cancel = 0.
class zcl_dv17_inclex_main definition
final
create public.
public section.
methods explode_to_clipboard
importing source_program type repid.
methods show_exploded_includes.
protected section.
private section.
types source_line type c length 255.
types source_lines type standard table of source_line with empty key.
types: begin of source,
repid type repid,
end of source,
sources type standard table of source with empty key.
data exploded_sources type sources.
methods explode
importing source type repid
returning value(result) type source_lines.
methods explode_line
importing line type source_line
returning value(result) type source_lines.
methods extract_source_name
importing line type source_line
returning value(result) type repid.
methods export_to_clipboard
importing value(source_lines) type source_lines.
endclass.
class zcl_dv17_inclex_main implementation.
method explode.
data source_lines type source_lines.
read report source into source_lines.
insert value #( repid = source ) into table exploded_sources.
result =
value #(
for line in source_lines
( lines of explode_line( line ) ) ).
endmethod.
method explode_line.
data(match) = match( val = line regex = `^ *include` case = abap_false ).
if match is not initial.
result = explode(
extract_source_name( line ) ).
else.
result = value #( ( line ) ).
endif.
endmethod.
method explode_to_clipboard.
export_to_clipboard( explode( source_program ) ).
endmethod.
method export_to_clipboard.
data clipboard_return type i.
cl_gui_frontend_services=>clipboard_export(
importing data = source_lines
changing rc = clipboard_return ).
if clipboard_return = 0.
message 'Exploded lines are in the clipboard now' type 'I'.
endif.
endmethod.
method extract_source_name.
result =
to_upper(
match(
val = segment( val = condense( line ) index = 2 )
regex = '\w+' ) ).
endmethod.
method show_exploded_includes.
try.
cl_salv_table=>factory(
importing r_salv_table = data(alv)
changing t_table = exploded_sources ).
alv->get_display_settings( )->set_list_header( 'Exploded sources' ).
alv->display( ).
catch cx_salv_error.
endtry.
endmethod.
endclass.
start-of-selection.
data(app) = new zcl_dv17_inclex_main( ).
app->explode_to_clipboard( report ).
app->show_exploded_includes( ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |