Global include TO display the ALV report by using the final internal table
WE have to execute the below perform.*************************************************************************
perform display_fullscreen tables gdt_report
using 'X' 'X'.
*Here Gdt_report is the final internal table
By defaultly it will take the headers also for the ALV from the dataelement of the o/p table.
if we want to chane the column names of the ALV we have to execute below perform.****************************************************************************
perform fill_columns.*************************************************************************
*&---------------------------------------------------------------------*
*& Form FILL_COLUMNS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fill_columns .
clear: gds_columns.
gds_columns-column = 'FRA1'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'FRA1'.
gds_columns-mtext = 'FRA1'.
gds_columns-ltext = 'FRA1'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'FRC1'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'FRC1'.
gds_columns-mtext = 'FRC1'.
gds_columns-ltext = 'FRC1'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'ZOA1'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'ZOA1'.
gds_columns-mtext = 'ZOA1'.
gds_columns-ltext = 'ZOA1'.
append gds_columns to gdt_columns.
** Start of chnages by SR_INC000007436972 702061451 EJ3K952018
clear: gds_columns.
gds_columns-column = 'ZTAX'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'ZTAX'.
gds_columns-mtext = 'ZTAX'.
gds_columns-ltext = 'ZTAX'.
append gds_columns to gdt_columns.
** End of chnages by SR_INC000007436972 702061451 EJ3K952018
clear: gds_columns.
gds_columns-column = 'ZOC1'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'ZOC1'.
gds_columns-mtext = 'ZOC1'.
gds_columns-ltext = 'ZOC1'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'ZOH1'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'ZOH1'.
gds_columns-mtext = 'ZOH1'.
gds_columns-ltext = 'ZOH1'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'ZOHC'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'ZOHC'.
gds_columns-mtext = 'ZOHC'.
gds_columns-ltext = 'ZOHC'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'ICON'.
gds_columns-changetxt = gcf_x.
gds_columns-icon = gcf_x.
gds_columns-hotspot = gcf_x.
gds_columns-stext = 'Error'.
gds_columns-mtext = 'Error'.
gds_columns-ltext = 'Error'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'DATAB'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'Valid From'.
gds_columns-mtext = 'Valid From'.
gds_columns-ltext = 'Valid From'.
append gds_columns to gdt_columns.
clear: gds_columns.
gds_columns-column = 'DATBI'.
gds_columns-changetxt = gcf_x.
gds_columns-stext = 'Valid To'.
gds_columns-mtext = 'Valid To'.
gds_columns-ltext = 'Valid To'.
append gds_columns to gdt_columns.
endform. " FILL_COLUMNS
**********************************************
ALV Global include:
ZEX01I0001**********************************************
*&---------------------------------------------------------------------*
*& Report ZEX01R0001 *
*& *
*&---------------------------------------------------------------------*
*& Program :ALV Include Program *
*& Creator :TSLATTER *
*& Create Date :2009/08/19 *
*& Function Number :TC-TR-001S *
*&---------------------------------------------------------------------*
*& Summary & *
*& 1. ALV Report Include (displays list, grids and hierarchy ALV) *
*&---------------------------------------------------------------------*
*& renewal resume &
*
*& renew date transport No change by contents *
*&---------------------------------------------------------------------*
include <color>.
include <icon>.
include <symbol>.
types:
begin of gts_columns,
column type lvc_fname, "Column (field) Name
level type i, "Hierarchy Level
stext type scrtext_s, "Short Text
mtext type scrtext_m, "Medium text
ltext type scrtext_l, "Long Text
subtotal type c, "Subtotal Column
key type c, "Key
hotspot type c, "Is a Hotspot (include form on_single_click in calling program)
excep type c, "Exception Field
icon type c, "Field is an icon (type ICON_D)
symbol type c, "Field is a symbol
checkbox type c, "Field is a checkbox (Type CHAR1)
button type c, "Field is a button (single_click form)
tech type c, "No Display
total type c, "Total Column (numerical)
sort type c, "Sort on this column
changetxt type c, "Change the text
hide type c, "Hide the Column
sign type c, "Show Sign
lead_zero type c, "Display Leading Zeros
opt type c, "Optimise Field Width
curr_col type lvc_cfname, "Name of the Currency Column (e.g. WAERS)
currency type lvc_curr, "Currency for whole column (e.g. 'AUD')
uom_col type lvc_qfname, "Unit of Measure Column (e.g. MEINS)
uom type lvc_quan, "Unit of Measure for Column (e.g. 'EA')
decimals type lvc_decmls, "Decimals Shown (e.g. 2)
dec_col type lvc_dfname, "Decimals Column
colour type lvc_s_colo, "Colour of cell.
out_len type lvc_outlen, "Set the Output Length
align type salv_de_alignment, "Set Alignment 1=Left 2=Right 3=Centred
end of gts_columns.
types:
begin of gts_header,
text(60) type c,
end of gts_header.
constants: gcf_true type sap_bool value 'X',
gcf_false type sap_bool value space.
constants: gcf_repid type sy-repid value sy-repid.
*... §6 Definition is later
class gcl_handle_events definition deferred.
data: gdr_table type ref to cl_salv_table.
data: gdr_hier type ref to cl_salv_hierseq_table.
*... §6 object for handling the events of cl_salv_table
data: gdr_events type ref to gcl_handle_events.
data: gdf_okcode type syucomm.
data: gdt_columns type standard table of gts_columns,
gds_columns type gts_columns.
data: gdt_header type standard table of gts_header,
gds_header type gts_header.
data: gdf_opt_col type sap_bool value 'X'.
*---------------------------------------------------------------------*
* CLASS gcl_handle_events DEFINITION
*---------------------------------------------------------------------*
* §6.1 define a local class for handling events of cl_salv_table
*---------------------------------------------------------------------*
class gcl_handle_events definition.
public section.
methods:
on_double_click for event double_click of cl_salv_events_table
importing row column,
on_single_click for event link_click of cl_salv_events_table
importing row column,
on_double_click_hier for event double_click of cl_salv_events_hierseq
importing row column,
on_single_click_hier for event link_click of cl_salv_events_hierseq
importing row column.
endclass. "gcl_handle_events DEFINITION
*---------------------------------------------------------------------*
* CLASS gcl_handle_events IMPLEMENTATION
*---------------------------------------------------------------------*
* §6.2 implement the events for handling the events of cl_salv_table
*---------------------------------------------------------------------*
class gcl_handle_events implementation.
method on_double_click.
perform on_double_click in program (gcf_repid)
if found using row column.
endmethod. "on_double_click
method on_single_click.
perform on_hotspot_click in program (gcf_repid)
if found using row column.
endmethod. "on_single_click
method on_double_click_hier.
perform on_double_click in program (gcf_repid)
if found using row column.
endmethod. "on_double_click
method on_single_click_hier.
perform on_hotspot_click in program (gcf_repid)
if found using row column.
endmethod. "on_single_click_hier
endclass. "gcl_handle_events IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Form display_fullscreen
*&---------------------------------------------------------------------*
* Display the List (modify colour, icons, buttons etc)
*----------------------------------------------------------------------*
form display_fullscreen tables pvt_alv type standard table
using pvf_list " List or Grid
pvf_head. "create ALV header (fill GDT_HEADER)
*... §2 create an ALV table
* §2.2 just create an instance and do not set LIST_DISPLAY for
* displaying the data as a Fullscreen Grid
try.
cl_salv_table=>factory(
exporting list_display = pvf_list
importing
r_salv_table = gdr_table
changing
t_table = pvt_alv[] ).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.
if not pvf_head is initial.
perform create_header.
endif.
perform set_layout_key.
perform set_functions.
perform set_display_settings.
perform manipulate_columns.
perform set_events.
*... §8 display the table
gdr_table->display( ).
endform. " display_fullscreen
*&---------------------------------------------------------------------*
*& Form display_hierarchy
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form display_hierarchy tables pvt_head type standard table
pvt_item type standard table
using pvf_master "master field
pvf_slave " slave field
pvf_head. "create ALV header (fill GDT_HEADER)
data: ldt_binding type salv_t_hierseq_binding,
lds_binding like line of ldt_binding.
lds_binding-master = pvf_master.
lds_binding-slave = pvf_slave.
append lds_binding to ldt_binding.
try.
cl_salv_hierseq_table=>factory(
exporting
t_binding_level1_level2 = ldt_binding
importing
r_hierseq = gdr_hier
changing
t_table_level1 = pvt_head[]
t_table_level2 = pvt_item[] ).
catch cx_salv_msg. "#EC NO_HANDLER
catch cx_salv_not_found. "#EC NO_HANDLER
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
if not pvf_head is initial.
perform create_header.
endif.
perform set_layout_key.
perform set_functions.
perform set_display_settings.
perform manipulate_columns_hier using 1.
perform manipulate_columns_hier using 2.
perform set_events_hier.
*... §8 display the table
gdr_hier->display( ).
endform. "display_hierarchy
*&---------------------------------------------------------------------*
*& Form CREATE_HEADER
*&---------------------------------------------------------------------*
* Create Report Header
*----------------------------------------------------------------------*
form create_header .
data: lo_header type ref to cl_salv_form_layout_grid,
lo_h_label type ref to cl_salv_form_label.
data: ldf_row type i.
* Create the Header Li
* header object
create object lo_header exporting columns = 5 .
clear ldf_row.
loop at gdt_header into gds_header.
ldf_row = ldf_row + 1.
lo_h_label = lo_header->create_label( row = ldf_row column = 1 ).
lo_h_label->set_text( gds_header-text ).
endloop.
if not gdr_table is initial.
* set the top of list using the header for Online.
gdr_table->set_top_of_list( lo_header ).
* set the top of list using the header for Print.
gdr_table->set_top_of_list_print( lo_header ).
else.
* set the top of list using the header for Online.
gdr_hier->set_top_of_list( lo_header ).
* set the top of list using the header for Print.
gdr_hier->set_top_of_list_print( lo_header ).
endif.
endform. " CREATE_HEADER
*&---------------------------------------------------------------------*
*& Form SET_FUNCTIONS
*&---------------------------------------------------------------------*
* Set application tool bar settings
*----------------------------------------------------------------------*
form set_functions .
*... §3 Functions
data: ldr_functions type ref to cl_salv_functions_list.
if not gdr_table is initial.
ldr_functions = gdr_table->get_functions( ).
else.
ldr_functions = gdr_hier->get_functions( ).
endif.
*... §3.1 activate ALV generic Functions
ldr_functions->set_all( gcf_true ).
endform. " SET_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form SET_DISPLAY_SETTINGS
*&---------------------------------------------------------------------*
* Set the display settings - ZEBRA
*----------------------------------------------------------------------*
form set_display_settings .
data: ldr_display type ref to cl_salv_display_settings.
if not gdr_table is initial.
ldr_display = gdr_table->get_display_settings( ).
else.
ldr_display = gdr_hier->get_display_settings( ).
endif.
ldr_display->set_striped_pattern( cl_salv_display_settings=>true ).
endform. " SET_DISPLAY_SETTINGS
*&---------------------------------------------------------------------*
*& Form SET_EVENTS
*&---------------------------------------------------------------------*
* Set the events
*----------------------------------------------------------------------*
form set_events .
*... §7 register to the events of cl_salv_table
data: ldr_events type ref to cl_salv_events_table.
ldr_events = gdr_table->get_event( ).
create object gdr_events.
*... §7.2 register to the event DOUBLE_CLICK
set handler gdr_events->on_double_click for ldr_events.
*... §7.3 register to the event LINK_CLICK
set handler gdr_events->on_single_click for ldr_events.
endform. " SET_EVENTS
*&---------------------------------------------------------------------*
*& Form SET_EVENTS
*&---------------------------------------------------------------------*
* Set the events
*----------------------------------------------------------------------*
form set_events_hier.
*... §7 register to the events of CL_SALV_EVENTS_HIERSEQ
data: ldr_events type ref to cl_salv_events_hierseq.
ldr_events = gdr_hier->get_event( ).
create object gdr_events.
*... §7.2 register to the event DOUBLE_CLICK
set handler gdr_events->on_double_click_hier for ldr_events.
*... §7.3 register to the event LINK_CLICK
set handler gdr_events->on_single_click_hier for ldr_events.
endform. " SET_EVENTS
*&---------------------------------------------------------------------*
*& Form MANIPULATE_COLUMNS
*&---------------------------------------------------------------------*
* Delete Columns, add colour, hotspots, icons, symbols etc etc
*----------------------------------------------------------------------*
form manipulate_columns .
data: ldr_agg type ref to cl_salv_aggregations.
data: ldr_sorts type ref to cl_salv_sorts.
*... set the columns technical
data: ldr_columns type ref to cl_salv_columns_table,
ldr_column type ref to cl_salv_column_table.
*... §4.9 set icon tooltips
data: ldr_functional_settings type ref to cl_salv_functional_settings.
ldr_columns = gdr_table->get_columns( ).
ldr_columns->set_optimize( gdf_opt_col ).
ldr_functional_settings = gdr_table->get_functional_settings( ).
loop at gdt_columns into gds_columns.
* Set keys.
if gds_columns-key eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_key( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
* technical
if gds_columns-tech = gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.1 set exception column
if gds_columns-excep eq gcf_true.
try.
ldr_columns->set_exception_column( gds_columns-column ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
endif.
* Set alignment.
if not gds_columns-align is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_alignment( gds_columns-align ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.1 set output length
if not gds_columns-out_len is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_output_length( gds_columns-out_len ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
endif.
* Totals
if gds_columns-total eq gcf_true.
try.
ldr_agg = gdr_table->get_aggregations( ).
ldr_agg->add_aggregation( gds_columns-column ).
catch cx_salv_data_error.
catch cx_salv_not_found.
catch cx_salv_existing.
endtry.
endif.
* Sorting
if gds_columns-sort eq gcf_true.
try.
ldr_sorts = gdr_table->get_sorts( ).
ldr_sorts->add_sort( columnname = gds_columns-column subtotal = gds_columns-subtotal ).
catch cx_salv_data_error.
catch cx_salv_not_found.
catch cx_salv_existing.
endtry.
endif.
*... §4.2 set icon text
if gds_columns-changetxt eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set optimal width
if not gds_columns-opt is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_optimized( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set currency column
if not gds_columns-curr_col is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_currency_column( gds_columns-curr_col ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set currency for all column
if not gds_columns-currency is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_currency( gds_columns-currency ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set decimal column
if not gds_columns-dec_col is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_decimals_column( gds_columns-dec_col ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set uom col
if not gds_columns-uom_col is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_quantity_column( gds_columns-uom_col ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set uom for all column
if not gds_columns-uom is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_quantity( gds_columns-uom ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set uom col
if not gds_columns-decimals is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_decimals( gds_columns-decimals ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set leading zeros
if gds_columns-lead_zero eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_leading_zero( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set icon visible
if gds_columns-hide eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_visible( if_salv_c_bool_sap=>false ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
if gds_columns-sign eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_sign( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set icon column
if gds_columns-icon eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_icon( if_salv_c_bool_sap=>true ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.3 set symbol column
if gds_columns-symbol eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_symbol( if_salv_c_bool_sap=>true ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.4 set checkbox column
if gds_columns-checkbox eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_cell_type( if_salv_c_cell_type=>checkbox ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.5 set hotspot column
if gds_columns-hotspot eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.6 set button column
if gds_columns-button eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_cell_type( if_salv_c_cell_type=>button ).
ldr_column->set_icon( if_salv_c_bool_sap=>true ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found cx_salv_method_not_supported. "#EC NO_HANDLER
endtry.
endif.
if not gds_columns-colour is initial.
try.
ldr_columns->set_color_column( gds_columns-column ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
endif.
endloop.
endform. " MANIPULATE_COLUMNS
*&---------------------------------------------------------------------*
*& Form MANIPULATE_COLUMNS_HIER
*&---------------------------------------------------------------------*
* Delete Columns, add colour, hotspots, icons, symbols etc etc
*----------------------------------------------------------------------*
form manipulate_columns_hier using pvf_level.
data: ldr_agg type ref to cl_salv_aggregations.
data: ldr_sorts type ref to cl_salv_sorts.
*... set the columns technical
data: ldr_columns type ref to cl_salv_columns_hierseq,
ldr_column type ref to cl_salv_column_hierseq.
*... §4.9 set icon tooltips
data: ldr_functional_settings type ref to cl_salv_functional_settings.
try.
ldr_columns = gdr_hier->get_columns( pvf_level ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
ldr_columns->set_optimize( gdf_opt_col ).
ldr_functional_settings = gdr_hier->get_functional_settings( ).
loop at gdt_columns into gds_columns where level eq pvf_level.
* Set keys.
if gds_columns-key eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_key( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
* technical column
if gds_columns-tech eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
* Totals
if gds_columns-total eq gcf_true.
try.
ldr_agg = gdr_hier->get_aggregations( pvf_level ).
ldr_agg->add_aggregation( gds_columns-column ).
catch cx_salv_data_error.
catch cx_salv_not_found.
catch cx_salv_existing.
endtry.
endif.
*... §4.1 set output length
if not gds_columns-out_len is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_output_length( gds_columns-out_len ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
endif.
* Set alignment.
if not gds_columns-align is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_alignment( gds_columns-align ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
* Sorting
if gds_columns-sort eq gcf_true.
try.
ldr_sorts = gdr_hier->get_sorts( pvf_level ).
ldr_sorts->add_sort( columnname = gds_columns-column subtotal = gds_columns-subtotal ).
catch cx_salv_data_error.
catch cx_salv_not_found.
catch cx_salv_existing.
endtry.
endif.
*... §4.1 set exception column
if gds_columns-excep eq gcf_true.
try.
ldr_columns->set_exception_column( gds_columns-column ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set optimal width
if not gds_columns-opt is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_optimized( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set icon column
if gds_columns-changetxt eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set leading zeros
if gds_columns-lead_zero eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_leading_zero( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set currency for all column
if not gds_columns-currency is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_currency( gds_columns-currency ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set decimal column
if not gds_columns-dec_col is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_decimals_column( gds_columns-dec_col ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set icon visible
if not gds_columns-curr_col is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_currency_column( gds_columns-curr_col ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set uom col
if not gds_columns-uom_col is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_quantity_column( gds_columns-uom_col ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set uom for all column
if not gds_columns-uom is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_quantity( gds_columns-uom ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set uom col
if not gds_columns-decimals is initial.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_decimals( gds_columns-decimals ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set icon visible
if gds_columns-hide eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_visible( if_salv_c_bool_sap=>false ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
if gds_columns-sign eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_sign( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.2 set icon column
if gds_columns-icon eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_icon( if_salv_c_bool_sap=>true ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.3 set symbol column
if gds_columns-symbol eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_symbol( if_salv_c_bool_sap=>true ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.4 set checkbox column
if gds_columns-checkbox eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_cell_type( if_salv_c_cell_type=>checkbox ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.5 set hotspot column
if gds_columns-hotspot eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endif.
*... §4.6 set button column
if gds_columns-button eq gcf_true.
try.
ldr_column ?= ldr_columns->get_column( gds_columns-column ).
ldr_column->set_cell_type( if_salv_c_cell_type=>button ).
ldr_column->set_icon( if_salv_c_bool_sap=>true ).
if not gds_columns-ltext is initial.
ldr_column->set_long_text( gds_columns-ltext ).
endif.
if not gds_columns-mtext is initial.
ldr_column->set_medium_text( gds_columns-mtext ).
endif.
if not gds_columns-stext is initial.
ldr_column->set_short_text( gds_columns-stext ).
endif.
catch cx_salv_not_found cx_salv_method_not_supported. "#EC
endtry.
endif.
if not gds_columns-colour is initial.
try.
ldr_columns->set_color_column( gds_columns-column ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
endif.
endloop.
endform. " MANIPULATE_COLUMNS
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT_KEY
*&---------------------------------------------------------------------*
* Allow layouts to be saved etc
*----------------------------------------------------------------------*
form set_layout_key .
data: ldr_layout type ref to cl_salv_layout.
data: lds_key type salv_s_layout_key.
if not gdr_table is initial.
ldr_layout = gdr_table->get_layout( ).
else.
ldr_layout = gdr_hier->get_layout( ).
endif.
lds_key-report = sy-repid.
ldr_layout->set_key( lds_key ).
ldr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
endform. " SET_LAYOUT_KEY
No comments:
Post a Comment