Skip to content

Instantly share code, notes, and snippets.

@sandraros
Last active October 3, 2023 08:07
Show Gist options
  • Save sandraros/4a728fa1f4a524241c30f6cab0a00de4 to your computer and use it in GitHub Desktop.
Save sandraros/4a728fa1f4a524241c30f6cab0a00de4 to your computer and use it in GitHub Desktop.
*"* use this source file for any type of declarations (class
*"* definitions, interfaces or type declarations) you need for
*"* components in the private section
* Copyright SAP pieces of IF_SALV_GUI_GRID_DATA_SOURCE in ABAP 7.57 SP 0
INTERFACE lif_salv_gui_grid_data_source.
TYPES: BEGIN OF ys_field_references,
fieldname TYPE lvc_fname,
field_reference_type TYPE salv_de_celltype,
END OF ys_field_references.
TYPES: yts_field_references TYPE SORTED TABLE OF ys_field_references WITH UNIQUE KEY fieldname.
METHODS get_r_appl_data
IMPORTING as_a_copy TYPE abap_bool DEFAULT abap_false
RETURNING VALUE(rt_appl_data) TYPE REF TO data .
METHODS get_structure_descriptor
RETURNING VALUE(o_structdescr) TYPE REF TO cl_abap_structdescr.
ENDINTERFACE.
* Copyright SAP pieces of IF_SALV_LOGGER in ABAP 7.57 SP 0
INTERFACE lif_salv_logger.
TYPES y_component TYPE salv_csqt_component. " char30
TYPES y_class_shortened_name TYPE salv_csqt_tool. " char30
TYPES y_class_name TYPE salv_csqt_tool. " char30
TYPES y_task TYPE salv_csqt_task. " char61
METHODS log_task_begin
IMPORTING
VALUE(task) TYPE y_task
!text TYPE string OPTIONAL
!data TYPE any OPTIONAL .
METHODS log_task_end
IMPORTING
VALUE(task) TYPE y_task
text TYPE string OPTIONAL
!data TYPE any OPTIONAL .
ENDINTERFACE.
* Copyright SAP pieces of if_salv_gui_grid_facade in ABAP 7.57 SP 0
INTERFACE lif_salv_gui_grid_facade.
METHODS data_source RETURNING VALUE(o_data_source) TYPE REF TO lif_salv_gui_grid_data_source.
ENDINTERFACE.
* Copyright SAP pieces of IF_SALV_GUI_GRID_LVC_DATA in ABAP 7.57 SP 0
INTERFACE lif_salv_gui_grid_lvc_data.
METHODS get_data_package
IMPORTING
!firstline TYPE if_salv_grm_listview_service=>y_table_line
!lastline TYPE if_salv_grm_listview_service=>y_table_line
!gui_type TYPE if_salv_gru_view_ctrl=>y_gui_type
!delete_entries_not_in_range TYPE char01
!view TYPE ui_func
EXPORTING
!rt_data TYPE REF TO lvc_t_data .
METHODS get_model_modus
RETURNING
VALUE(value) TYPE string .
ENDINTERFACE.
* Copyright SAP pieces of CL_SALV_GUI_GRID_FACADE in ABAP 7.57 SP 0
CLASS lcl_salv_gui_grid_facade DEFINITION.
PUBLIC SECTION.
INTERFACES if_alv_rm_grid_friend.
INTERFACES lif_salv_gui_grid_facade.
INTERFACES lif_salv_gui_grid_lvc_data.
METHODS constructor
IMPORTING o_grid TYPE REF TO cl_gui_alv_grid
o_logger TYPE REF TO lif_salv_logger OPTIONAL.
PROTECTED SECTION.
DATA o_grid TYPE REF TO cl_gui_alv_grid.
DATA o_data_source TYPE REF TO lif_salv_gui_grid_data_source. "ToDo: delete IF from Facade
DATA o_logger TYPE REF TO lif_salv_logger.
METHODS adapt_lvc_data
IMPORTING
VALUE(t_sort) TYPE lvc_t_sort
VALUE(t_fieldcatalog) TYPE lvc_t_fcat
t_filter_miss_index TYPE lvc_t_fidx
from_x_y_cell TYPE sytabix
to_x_y_cell TYPE sytabix
CHANGING
xt_data TYPE lvc_t_data.
PRIVATE SECTION.
METHODS do_paging_semi_optimized
IMPORTING
gui_type TYPE i
view TYPE ui_func
firstline TYPE if_salv_grm_listview_service=>y_table_line
lastline TYPE if_salv_grm_listview_service=>y_table_line
EXPORTING
table_lines TYPE if_salv_grm_listview_service=>y_table_line
rt_data TYPE REF TO lvc_t_data
rt_info TYPE REF TO lvc_t_info
rt_idpo TYPE REF TO lvc_t_idpo
rt_poid TYPE REF TO lvc_t_poid
rt_roid TYPE REF TO lvc_t_roid
t_start_index TYPE lvc_t_stin .
METHODS do_paging_optimized
IMPORTING
gui_type TYPE i
view TYPE ui_func
firstline TYPE if_salv_grm_listview_service=>y_table_line
lastline TYPE if_salv_grm_listview_service=>y_table_line
delete_entries_not_in_range TYPE abap_bool DEFAULT abap_true
EXPORTING
table_lines TYPE if_salv_grm_listview_service=>y_table_line
rt_data TYPE REF TO lvc_t_data
rt_info TYPE REF TO lvc_t_info
rt_idpo TYPE REF TO lvc_t_idpo
rt_poid TYPE REF TO lvc_t_poid
rt_roid TYPE REF TO lvc_t_roid
t_start_index TYPE lvc_t_stin .
METHODS transfer_data_2_requester
CHANGING
ct_lvc_data TYPE lvc_t_data.
ENDCLASS.
CLASS zcl_gui_alv_grid_sort_merge DEFINITION
PUBLIC
INHERITING FROM cl_gui_alv_grid
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_alv_rm_grid_friend .
METHODS constructor
IMPORTING
VALUE(i_shellstyle) TYPE i DEFAULT 0
VALUE(i_lifetime) TYPE i OPTIONAL
VALUE(i_parent) TYPE REF TO cl_gui_container
VALUE(i_appl_events) TYPE char01 DEFAULT space
!i_parentdbg TYPE REF TO cl_gui_container OPTIONAL
!i_applogparent TYPE REF TO cl_gui_container OPTIONAL
!i_graphicsparent TYPE REF TO cl_gui_container OPTIONAL
VALUE(i_name) TYPE string OPTIONAL
!i_fcat_complete TYPE sap_bool DEFAULT space
EXCEPTIONS
error_cntl_create
error_cntl_init
error_cntl_link
error_dp_create .
PROTECTED SECTION.
METHODS on_before_send REDEFINITION.
PRIVATE SECTION.
DATA castme TYPE REF TO cl_gui_alv_grid.
DATA _o_grid_facade TYPE REF TO lcl_salv_gui_grid_facade.
ENDCLASS.
CLASS zcl_gui_alv_grid_sort_merge IMPLEMENTATION.
METHOD constructor.
super->constructor(
i_shellstyle = i_shellstyle
i_lifetime = i_lifetime
i_parent = i_parent
i_appl_events = i_appl_events
i_parentdbg = i_parentdbg
i_applogparent = i_applogparent
i_graphicsparent = i_graphicsparent
i_name = i_name
i_fcat_complete = i_fcat_complete ).
castme = CAST cl_gui_alv_grid( me ).
_o_grid_facade = NEW lcl_salv_gui_grid_facade( o_grid = me ).
ENDMETHOD.
METHOD on_before_send.
super->on_before_send( firstline = firstline
lastline = lastline ).
get_actual_view( IMPORTING e_view = DATA(l_view) ).
DATA(rt_data) = REF #( castme->mt_data ).
_o_grid_facade->lif_salv_gui_grid_lvc_data~get_data_package(
EXPORTING
firstline = firstline
lastline = lastline
gui_type = m_gui_type
delete_entries_not_in_range = abap_false
view = l_view
IMPORTING
rt_data = rt_data ).
ENDMETHOD.
ENDCLASS.
*"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations
* Copyright SAP pieces of CX_SALV_API_DYNAMIC in ABAP 7.57 SP 0
CLASS lcx_salv_api_dynamic DEFINITION
INHERITING FROM cx_dynamic_check
ABSTRACT
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_t100_message .
METHODS constructor
IMPORTING
!textid LIKE if_t100_message=>t100key OPTIONAL
!previous LIKE previous OPTIONAL .
ENDCLASS.
* Copyright SAP pieces of CX_SALV_API_CONTRACT_VIOLATION in ABAP 7.57 SP 0
CLASS lcx_salv_api_contract_violatio DEFINITION
INHERITING FROM lcx_salv_api_dynamic
CREATE PUBLIC .
PUBLIC SECTION.
CONSTANTS:
BEGIN OF lcx_salv_api_contract_violatio,
msgid TYPE symsgid VALUE 'SALV_X_API',
msgno TYPE symsgno VALUE '021',
attr1 TYPE scx_attrname VALUE '',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF lcx_salv_api_contract_violatio .
CONSTANTS:
BEGIN OF src_data_changed_w_o_notice,
msgid TYPE symsgid VALUE 'SALV_X_API',
msgno TYPE symsgno VALUE '025',
attr1 TYPE scx_attrname VALUE '',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF src_data_changed_w_o_notice .
CONSTANTS:
BEGIN OF src_ref_not_bound,
msgid TYPE symsgid VALUE 'SALV_X_API',
msgno TYPE symsgno VALUE '087',
attr1 TYPE scx_attrname VALUE '',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF src_ref_not_bound .
CONSTANTS:
BEGIN OF call_currently_not_allowed,
msgid TYPE symsgid VALUE 'SALV_X_API',
msgno TYPE symsgno VALUE '094',
attr1 TYPE scx_attrname VALUE '',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF call_currently_not_allowed .
CONSTANTS:
BEGIN OF functionality_not_supported,
msgid TYPE symsgid VALUE 'SALV_X_API',
msgno TYPE symsgno VALUE '130',
attr1 TYPE scx_attrname VALUE '',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF functionality_not_supported .
METHODS constructor
IMPORTING
!textid LIKE if_t100_message=>t100key OPTIONAL
!previous LIKE previous OPTIONAL .
ENDCLASS.
* Copyright SAP pieces of CX_SALV_INDEX_TABLE_NOT_SORTED in ABAP 7.57 SP 0
CLASS lcx_salv_index_table_not_sorte DEFINITION
INHERITING FROM lcx_salv_api_contract_violatio
CREATE PUBLIC .
PUBLIC SECTION.
CONSTANTS:
BEGIN OF lcx_salv_index_table_not_sorte,
msgid TYPE symsgid VALUE 'SALV_X_API',
msgno TYPE symsgno VALUE '022',
attr1 TYPE scx_attrname VALUE 'TABLE_NAME',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF lcx_salv_index_table_not_sorte .
DATA table_name TYPE string .
METHODS constructor
IMPORTING
!textid LIKE if_t100_message=>t100key OPTIONAL
!previous LIKE previous OPTIONAL
!table_name TYPE string OPTIONAL .
ENDCLASS.
* Copyright SAP pieces of IF_SALV_SERVICE_TYPES in ABAP 7.57 SP 0
INTERFACE lif_salv_service_types.
TYPES y_row_index TYPE sytabix .
TYPES:
yt_row_index TYPE STANDARD TABLE OF y_row_index WITH KEY table_line .
TYPES:
BEGIN OF ys_range,
from TYPE y_row_index,
to TYPE y_row_index,
END OF ys_range .
TYPES:
yt_range TYPE STANDARD TABLE OF ys_range WITH KEY from .
ENDINTERFACE.
* Copyright SAP pieces of IF_SALV_GUI_TYPES_INT_IDA in ABAP 7.57 SP 0
INTERFACE lif_salv_gui_types_int_ida.
TYPES: BEGIN OF ys_cell_info,
result_index TYPE sytabix,
fieldname TYPE fieldname,
text TYPE lvc_value,
END OF ys_cell_info.
TYPES: yt_cell_info TYPE STANDARD TABLE OF ys_cell_info.
TYPES:
yts_column_width TYPE SORTED TABLE OF lvc_s_coll WITH UNIQUE KEY col_id .
TYPES:
BEGIN OF yt_tb_appl_func,
buttons_before TYPE ttb_button,
buttons_behind TYPE ttb_button,
END OF yt_tb_appl_func .
TYPES:
BEGIN OF ys_tb_hidden_functions,
details TYPE abap_bool,
sort TYPE abap_bool,
group TYPE abap_bool,
filter TYPE abap_bool,
aggregation TYPE abap_bool,
print TYPE abap_bool,
export TYPE abap_bool,
settings_dialog TYPE abap_bool,
END OF ys_tb_hidden_functions .
TYPES:
BEGIN OF ys_lvc_grouping_value,
row_type(1) TYPE c,
sequence(1) TYPE c,
ui_level(2) TYPE n, "1=*, 2=**, 3=***, ...
sum_level(2) TYPE n, "2->1->0 (<-highest)
is_collapsed TYPE abap_bool,
subrow_number(10) TYPE n,
dummy(6) TYPE c,
group_index(10) TYPE n,
END OF ys_lvc_grouping_value .
TYPES:
BEGIN OF ys_current_cell,
field_name TYPE fieldname, "if_salv_gui_types_ida=>y_field_name,
ui_line_number TYPE sytabix,
int_value TYPE REF TO data,
value TYPE lvc_value,
column_index TYPE i,
s_grouping_info TYPE ys_lvc_grouping_value,
current_row_data TYPE REF TO data,
END OF ys_current_cell .
TYPES:
yt_table_column TYPE TABLE OF string WITH DEFAULT KEY .
TYPES:
BEGIN OF ys_x_y_list,
index TYPE sytabix,
row_index TYPE sytabix,
column_name TYPE string,
column_pos TYPE sytabix,
END OF ys_x_y_list .
TYPES:
yt_x_y_list TYPE STANDARD TABLE OF ys_x_y_list WITH DEFAULT KEY .
TYPES:
BEGIN OF ys_x_y_list_compact,
s_source_index_range TYPE if_salv_service_types=>ys_range,
s_row_pos_range TYPE if_salv_service_types=>ys_range,
column_name TYPE string,
column_order TYPE sytabix,
END OF ys_x_y_list_compact .
TYPES:
yt_x_y_list_compact TYPE STANDARD TABLE OF ys_x_y_list_compact WITH DEFAULT KEY .
TYPES:
BEGIN OF ys_required_fields_for_calc,
fieldname TYPE char30,
tabname TYPE char30,
END OF ys_required_fields_for_calc .
TYPES:
yth_required_fields_for_calc TYPE HASHED TABLE OF ys_required_fields_for_calc
WITH UNIQUE KEY tabname fieldname .
TYPES yt_ui_index TYPE lvc_t_rows .
TYPES:
BEGIN OF ys_selected_data,
t_ui_index TYPE yt_ui_index,
r_data TYPE REF TO data,
END OF ys_selected_data .
TYPES:
BEGIN OF ys_data_external_format,
fieldname TYPE cl_salv_gui_field_catalog_ida=>y_field_name,
columntext TYPE lvc_text,
value TYPE lvc_value,
END OF ys_data_external_format .
TYPES:
yt_data_external_format TYPE STANDARD TABLE OF ys_data_external_format WITH DEFAULT KEY .
TYPES:
yt_grouping_data_ext TYPE STANDARD TABLE OF yt_data_external_format WITH DEFAULT KEY .
CONSTANTS:
BEGIN OF c_ui_visiblity,
visible TYPE string VALUE 'VISIBLE',
technical TYPE string VALUE 'TECHNICAL',
invisible TYPE string VALUE 'INVISIBLE',
END OF c_ui_visiblity .
CONSTANTS:
BEGIN OF c_calculate_field_type,
icon TYPE string VALUE 'ICON',
standard TYPE string VALUE 'STANDARD',
" exception type string value 'EXCEPTION', do not take as its handled terrible!!!
END OF c_calculate_field_type .
TYPES: BEGIN OF ys_domvalue,
domvalue_l TYPE domvalue_l,
ddtext TYPE val_text,
END OF ys_domvalue.
TYPES: yt_domvalue TYPE TABLE OF ys_domvalue WITH DEFAULT KEY.
ENDINTERFACE.
* Created from scratch (not looking at original LCL_INACTIVE_LOGGER).
CLASS lcl_inactive_logger DEFINITION
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES lif_salv_logger.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_GUI_TABLE_WRITER_IDA in ABAP 7.57 SP 0
CLASS lcl_salv_gui_table_writer_ida DEFINITION
CREATE PROTECTED.
PUBLIC SECTION.
TYPES:
y_line_type(1) TYPE c .
TYPES BEGIN OF ys_sort_fieldname_info.
INCLUDE TYPE lif_salv_gui_types_int_ida=>ys_x_y_list_compact.
TYPES: s_lvc_data_range TYPE lif_salv_service_types=>ys_range.
TYPES: sort_rule_sequence_nr TYPE i.
TYPES END OF ys_sort_fieldname_info.
TYPES : yt_sort_field_name_info TYPE STANDARD TABLE OF ys_sort_fieldname_info WITH DEFAULT KEY.
*
CONSTANTS mc_row_indicator TYPE string VALUE '###+++ROW_INDICATOR+++###' ##NO_TEXT.
CONSTANTS:
BEGIN OF mc_line_type,
"(T)otal (S)ubtotal (A)invisible subtotal (G)rouping (D)ata
grouping_total TYPE y_line_type VALUE 'Z',
total TYPE y_line_type VALUE 'T',
subtotal TYPE y_line_type VALUE 'S',
hidden_subtotal TYPE y_line_type VALUE 'A',
grouping TYPE y_line_type VALUE 'G',
data TYPE y_line_type VALUE 'D',
more_data_lines TYPE y_line_type VALUE 'L',
more_grouped_lines TYPE y_line_type VALUE 'M',
END OF mc_line_type .
"! xt_lvc_data has to be sorted according to COL_POS
CLASS-METHODS stop_merge_cells_by_sort_level
IMPORTING
t_appl_data_index_range TYPE lif_salv_service_types=>yt_range
t_appl_data TYPE STANDARD TABLE
line_type_excluding TYPE c
VALUE(rs_previous_result_data) TYPE REF TO data
o_logger TYPE REF TO lif_salv_logger
CHANGING
xt_sort_fieldname_col_pos TYPE yt_sort_field_name_info
xt_lvc_data TYPE lvc_t_data.
PROTECTED SECTION.
CLASS-METHODS get_condition_4_sort_rule
IMPORTING fieldname TYPE lvc_fname
t_sort_fieldname_col_pos TYPE yt_sort_field_name_info
RETURNING VALUE(merge_condition) TYPE string.
CLASS-METHODS find_row_boundaries_4_mapping
IMPORTING
t_lvc_data TYPE lvc_t_data
CHANGING
xt_sort_fieldname_info TYPE yt_sort_field_name_info.
CLASS-METHODS set_stop_merge_style
IMPORTING
VALUE(t_sort_fieldname_info) TYPE yt_sort_field_name_info
t_appl_data_range TYPE lif_salv_service_types=>yt_range
t_appl_data TYPE STANDARD TABLE
o_logger TYPE REF TO lif_salv_logger
CHANGING
xrs_previous_result_data TYPE REF TO data
xt_lvc_data TYPE lvc_t_data.
"1st segment must not be included into result e.g. when first page
CLASS-METHODS get_switch_level_4_sort_rule
IMPORTING
!s_result_index_range TYPE lif_salv_service_types=>ys_range
!t_result_data TYPE INDEX TABLE
!fieldname TYPE lvc_fname
!t_sort_fieldname_col_pos TYPE yt_sort_field_name_info
CHANGING
!xrs_previous_result_data TYPE REF TO data
RETURNING
VALUE(t_switch_level_4_sort_rule) TYPE lif_salv_service_types=>yt_range .
ENDCLASS.
*-----------------------------------------
* Class LCL_SALV_GUI_GRID_FACADE is declared in the section "class-relevant local types".
*-----------------------------------------
*CLASS lcl_salv_gui_grid_facade DEFINITION.
*ENDCLASS.
* Copyright SAP pieces of CL_SALV_GUI_GRID_LINE_XY_CONV in ABAP 7.57 SP 0
CLASS lcl_salv_gui_grid_line_xy_conv DEFINITION
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
CLASS-METHODS get_list
IMPORTING
table_size TYPE sytabix OPTIONAL
it_column_order TYPE string_table
start_list_index TYPE sytabix
end_list_index TYPE sytabix
EXPORTING
t_list TYPE lif_salv_gui_types_int_ida=>yt_x_y_list.
CLASS-METHODS get_list_compact
IMPORTING
it_column_order TYPE string_table
start_list_index TYPE sytabix
end_list_index TYPE sytabix
EXPORTING
t_list_compact TYPE lif_salv_gui_types_int_ida=>yt_x_y_list_compact.
CLASS-METHODS get_start_and_end_line_indizes
IMPORTING
it_column_order TYPE string_table
include_row_indicator TYPE abap_bool DEFAULT abap_true
start_list_index TYPE sytabix
end_list_index TYPE sytabix
EXPORTING
start_table_line_index TYPE sytabix
end_table_line_index TYPE sytabix.
CLASS-METHODS get_start_and_end_x_y_indizes
IMPORTING
nr_of_columns TYPE sytabix
include_row_indicator TYPE abap_bool DEFAULT abap_true
start_table_line_index TYPE sytabix
end_table_line_index TYPE sytabix
EXPORTING
start_list_x_y_index TYPE sytabix
end_list_x_y_index TYPE sytabix.
PRIVATE SECTION.
CLASS-METHODS get_line_and_offset
IMPORTING
list_index TYPE sytabix
it_column_order TYPE string_table
EXPORTING
line_index TYPE sytabix
line_offset TYPE sytabix.
CLASS-METHODS get_list_for_area
IMPORTING
table_size TYPE sytabix OPTIONAL
it_column_order TYPE string_table
start_line_index TYPE sytabix
start_line_column_offset TYPE sytabix
end_line_index TYPE sytabix
end_line_column_offset TYPE sytabix
EXPORTING
t_list TYPE lif_salv_gui_types_int_ida=>yt_x_y_list.
CLASS-METHODS get_list_compact_for_area
IMPORTING
it_column_order TYPE string_table
start_line_index TYPE sytabix
start_line_column_offset TYPE sytabix
end_line_index TYPE sytabix
end_line_column_offset TYPE sytabix
EXPORTING
t_list_compact TYPE lif_salv_gui_types_int_ida=>yt_x_y_list_compact.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_LOGGER in ABAP 7.57 SP 0
CLASS lcl_salv_logger DEFINITION
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES lif_salv_logger.
CLASS-METHODS create_logger
IMPORTING VALUE(component) TYPE lif_salv_logger=>y_component
VALUE(class_shortened_name) TYPE lif_salv_logger=>y_class_shortened_name
RETURNING VALUE(o_logger) TYPE REF TO lif_salv_logger.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA gv_is_initialized TYPE abap_bool.
CLASS-DATA go_inactive_logger TYPE REF TO lif_salv_logger.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_RANGE_TOOLS in ABAP 7.57 SP 0
CLASS lcl_salv_range_tools DEFINITION
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES y_index TYPE lif_salv_service_types=>y_row_index .
CLASS-METHODS convert_indexes_to_ranges
IMPORTING
!it_sorted_index TYPE lif_salv_service_types=>yt_row_index
EXPORTING
!et_range TYPE lif_salv_service_types=>yt_range
RAISING
lcx_salv_index_table_not_sorte .
ENDCLASS.
* Copyright SAP pieces of CL_SALV_STV_ITAB_SRV_UTILS in ABAP 7.57 SP 0
CLASS lcl_salv_stv_itab_srv_utils DEFINITION
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES ytt_row_index TYPE STANDARD TABLE OF lif_salv_service_types=>yt_row_index WITH DEFAULT KEY.
CLASS-METHODS get_opposite_range
IMPORTING t_normalized_range TYPE lif_salv_service_types=>yt_range
range_size TYPE sytabix
EXPORTING t_opposite_range TYPE lif_salv_service_types=>yt_range.
ENDCLASS.
* Copyright SAP pieces of LCL_GRID_DATASOURCE in class CL_SALV_GUI_GRID_FACADE in ABAP 7.57 SP 0
CLASS lcl_grid_datasource DEFINITION.
PUBLIC SECTION.
INTERFACES lif_salv_gui_grid_data_source.
INTERFACES if_alv_rm_grid_friend.
METHODS constructor
IMPORTING o_grid TYPE REF TO cl_gui_alv_grid OPTIONAL
o_parent TYPE REF TO lcl_salv_gui_grid_facade.
PROTECTED SECTION.
DATA o_grid TYPE REF TO cl_gui_alv_grid.
DATA o_parent TYPE REF TO lcl_salv_gui_grid_facade.
ENDCLASS.
* Created from scratch (not looking at original LCL_INACTIVE_LOGGER).
CLASS lcl_inactive_logger IMPLEMENTATION.
METHOD lif_salv_logger~log_task_begin.
ENDMETHOD.
METHOD lif_salv_logger~log_task_end.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_GUI_GRID_FACADE in ABAP 7.57 SP 0
CLASS lcl_salv_gui_grid_facade IMPLEMENTATION.
METHOD constructor.
me->o_grid = o_grid.
IF o_logger IS BOUND.
me->o_logger = o_logger.
ELSE.
me->o_logger = lcl_salv_logger=>create_logger( component = 'ALV_GUI'
class_shortened_name = 'GRID_FACADE' ).
ENDIF.
me->o_data_source = NEW lcl_grid_datasource( o_grid = o_grid
o_parent = me ).
ENDMETHOD.
METHOD lif_salv_gui_grid_lvc_data~get_model_modus.
*m_performance='X',m_memory='X' :
"-mt_data empty, Dataprovider gets only size of table mt_data
"-paging via ON_BEFORE_SEND
"1.Call: LVC_GET_INFO_DATA_TABLE : get table_lines of mt_data[]
"Paging: LVC_FILL_DATA_TABLE : firstline, lastline
*m_performance=space,m_memory=space or 'X' : Editable Mode, Excel
"-mt_data completely filled, no paging
"1.Call: LVC_TABLE_FOR_DISPLAY
"Paging: -
*m_performance='X',m_memory=space :
"-mt_data completely filled with empty values, paging via ON_BEFORE_SEND
"1.Call: LVC_TABLE_FOR_DISPLAY_PREPARE
"Paging: LVC_TABLE_FOR_DISPLAY_FILL
**...SOFT_REFRESH_TABLE_DISPLAY : (4) Get Display Information for Frontend
* IF me->o_grid->is_ready_for_input( ) EQ 1
* AND cl_alv_z_params=>get_parameter( cl_alv_z_params=>c_flag-edit_with_paging ) NE abap_true.
* me->o_grid->m_memory = space.
* me->o_grid->m_performance = space.
* ENDIF.
*...Determine Returning value, regarding rules above
IF me->o_grid->m_performance EQ abap_true AND me->o_grid->m_memory EQ abap_true.
* value = IF_ALV_RM_TABLE_MODEL~c_modus-optimized.
value = if_salv_grm_listview_service=>c_modus-performance_on_memory_on.
ELSEIF me->o_grid->m_performance EQ abap_false AND me->o_grid->m_memory EQ abap_true.
* value = IF_ALV_RM_TABLE_MODEL~c_modus-not_optimized.
value = if_salv_grm_listview_service=>c_modus-performance_off_memory_on.
ELSEIF me->o_grid->m_performance EQ abap_false AND me->o_grid->m_memory EQ abap_false.
* value = IF_ALV_RM_TABLE_MODEL~c_modus-not_optimized.
value = if_salv_grm_listview_service=>c_modus-performance_off_memory_off.
ELSEIF me->o_grid->m_performance EQ abap_true AND me->o_grid->m_memory EQ abap_false.
* value = IF_ALV_RM_TABLE_MODEL~c_modus-semi_optimized.
value = if_salv_grm_listview_service=>c_modus-performance_on_memory_off.
ENDIF.
ENDMETHOD.
METHOD do_paging_optimized.
o_logger->log_task_begin( task = 'DO_PAGING_OPTIMIZED'
text = |firstline={ firstline };lastline={ lastline }| ).
_macro_assign_outtab.
* type-pools: alvco.
* alvco_create_collect_tables <tab1>[].
_macro_assign_collect_tables.
* 7.57 INCOMPATIBLE WITH 7.40
* CALL FUNCTION 'LVC_CALLBACK_INTERNAL'
* EXPORTING
* io_event_handler = me. "if_salv_gui_grid_facade~events( ).
*
* CALL FUNCTION 'LVC_GLOBALS_FOR_OUTPUT' " YI3K572225
* EXPORTING
* io_datasource = lif_salv_gui_grid_facade~data_source( ).
CALL FUNCTION 'LVC_FILL_DATA_TABLE'
EXPORTING
i_view = view
i_gui_type = gui_type
is_layout = me->o_grid->m_cl_variant->ms_layout
i_start_index = firstline
i_end_index = lastline
is_layout_local = me->o_grid->ms_layout_local
is_total_options = me->o_grid->m_cl_variant->ms_total_options
it_except_qinfo = me->o_grid->mt_except_qinfo
it_fieldcat = me->o_grid->m_cl_variant->mt_fieldcatalog
it_fieldcat_local = me->o_grid->mt_fieldcat_local
it_roid = me->o_grid->mt_roid
it_poid = me->o_grid->mt_poid
it_fidx = me->o_grid->m_cl_variant->mt_filter_index
it_grouplevels = me->o_grid->m_cl_variant->mt_grouplevels_filter
i_delete_entries_not_in_range = delete_entries_not_in_range
TABLES
it_data = <tab1>[]
it_collect00 = <lt_collect00>
it_collect01 = <lt_collect01>
it_collect02 = <lt_collect02>
it_collect03 = <lt_collect03>
it_collect04 = <lt_collect04>
it_collect05 = <lt_collect05>
it_collect06 = <lt_collect06>
it_collect07 = <lt_collect07>
it_collect08 = <lt_collect08>
it_collect09 = <lt_collect09>
CHANGING
ct_start_index = me->o_grid->mt_start_index
ct_lvc_data = me->o_grid->mt_data[].
me->o_grid->add_bidi_flags( ).
t_start_index = me->o_grid->mt_start_index.
transfer_data_2_requester( CHANGING ct_lvc_data = me->o_grid->mt_data[] ).
GET REFERENCE OF me->o_grid->mt_data INTO rt_data.
o_logger->log_task_end( 'DO_PAGING_OPTIMIZED' ).
ENDMETHOD.
METHOD do_paging_semi_optimized.
o_logger->log_task_begin( task = 'DO_PAGING_SEMI_OPTIMIZED'
text = |firstline={ firstline };lastline={ lastline }| ).
_macro_assign_outtab.
_macro_assign_collect_tables.
CALL FUNCTION 'LVC_CALLBACK_INTERNAL'
EXPORTING
io_event_handler = me.
CALL FUNCTION 'LVC_GLOBALS_FOR_OUTPUT' " YI3K572225
EXPORTING
io_datasource = lif_salv_gui_grid_facade~data_source( ).
CALL FUNCTION 'LVC_TABLE_FOR_DISPLAY_FILL'
EXPORTING
i_view = view
i_gui_type = gui_type "#EC *
is_layout = me->o_grid->m_cl_variant->ms_layout
i_start_index = firstline
i_end_index = lastline
is_layout_local = me->o_grid->ms_layout_local
it_except_qinfo = me->o_grid->mt_except_qinfo
TABLES
it_data = <tab1>
CHANGING
ct_fieldcat_local = me->o_grid->mt_fieldcat_local
ct_lvc_data = me->o_grid->mt_data[]
ct_start_index = me->o_grid->mt_start_index.
me->o_grid->add_bidi_flags( ).
t_start_index = me->o_grid->mt_start_index.
transfer_data_2_requester( CHANGING ct_lvc_data = me->o_grid->mt_data[] ).
GET REFERENCE OF me->o_grid->mt_data INTO rt_data.
o_logger->log_task_end( 'DO_PAGING_SEMI_OPTIMIZED' ).
ENDMETHOD.
METHOD transfer_data_2_requester.
ENDMETHOD.
METHOD lif_salv_gui_grid_lvc_data~get_data_package.
*since the routine ON_BEFORE_SEND is called every roundtrip, we must avoid the
*processing when all data has been sent to the Frontend
DATA: l_modus TYPE string.
l_modus = lif_salv_gui_grid_lvc_data~get_model_modus( ).
CHECK l_modus EQ if_salv_grm_listview_service=>c_modus-performance_on_memory_on " type string value 'PERF_ON_MEMORY_ON'
OR l_modus EQ if_salv_grm_listview_service=>c_modus-performance_on_memory_off." type string value 'PERF_ON_MEMORY_OFF'
"semi-optimized
IF l_modus EQ if_salv_grm_listview_service=>c_modus-performance_on_memory_off
OR l_modus EQ if_salv_grm_listview_service=>c_modus-performance_off_memory_on.
me->do_paging_semi_optimized(
EXPORTING
view = view
firstline = firstline
lastline = lastline
gui_type = gui_type
IMPORTING
rt_data = rt_data
).
ELSE.
me->do_paging_optimized(
EXPORTING
view = view
firstline = firstline
lastline = lastline
gui_type = gui_type
IMPORTING
rt_data = rt_data
).
ENDIF.
adapt_lvc_data(
EXPORTING
t_sort = me->o_grid->m_cl_variant->mt_sort
t_fieldcatalog = me->o_grid->m_cl_variant->mt_fieldcatalog
t_filter_miss_index = me->o_grid->m_cl_variant->mt_filter_index
from_x_y_cell = firstline
to_x_y_cell = lastline
CHANGING
xt_data = rt_data->* ).
* if me->o_grid is INSTANCE OF _cl_gui_alv_grid_uim_test.
* data(lo_uim_hook) = _cl_alv_uim_wrapper=>get_uim( o_uim_access = cast _cl_gui_alv_grid_uim_test( me->o_grid ) ).
* data(lt_uim_ui_data_package) = lo_uim_hook->grid_ui_data_package( ).
* "ToDo Check Consistency
* me->o_grid->mt_data = lt_uim_ui_data_package.
* rt_data = ref #( me->o_grid->mt_data ).
* endif.
ENDMETHOD.
METHOD adapt_lvc_data.
CHECK lines( t_sort ) GT 1. "Stop cell merge required?
DATA(lrt_appl_data) = me->o_data_source->get_r_appl_data( ).
FIELD-SYMBOLS: <t_appl_data> TYPE STANDARD TABLE.
ASSIGN lrt_appl_data->* TO <t_appl_data>.
DATA: lt_column_order TYPE string_table.
SORT t_fieldcatalog BY col_pos.
APPEND lcl_salv_gui_table_writer_ida=>mc_row_indicator TO lt_column_order. "Add Row Indicator
LOOP AT t_fieldcatalog INTO DATA(ls_fieldcatalog) WHERE tech NE abap_true
AND no_out NE abap_true.
APPEND ls_fieldcatalog-fieldname TO lt_column_order.
ENDLOOP.
lcl_salv_gui_grid_line_xy_conv=>get_list_compact( EXPORTING it_column_order = lt_column_order
start_list_index = from_x_y_cell
end_list_index = to_x_y_cell
IMPORTING t_list_compact = DATA(lt_list_compact) ).
DATA lt_sort_fieldname_col_pos TYPE lcl_salv_gui_table_writer_ida=>yt_sort_field_name_info.
SORT t_sort BY spos.
LOOP AT t_sort INTO DATA(ls_sort) WHERE subtot NE abap_true.
DATA(lv_sort_rule_sequence_nr) = sy-tabix.
READ TABLE lt_list_compact INTO DATA(ls_compact_list) WITH KEY column_name = ls_sort-fieldname.
IF sy-subrc EQ 0. "Client field
APPEND INITIAL LINE TO lt_sort_fieldname_col_pos ASSIGNING FIELD-SYMBOL(<s_sort_fieldname_col_pos>).
MOVE-CORRESPONDING ls_compact_list TO <s_sort_fieldname_col_pos>.
SUBTRACT 1 FROM <s_sort_fieldname_col_pos>-column_order.
<s_sort_fieldname_col_pos>-sort_rule_sequence_nr = lv_sort_rule_sequence_nr.
ENDIF.
ENDLOOP.
CHECK lines( lt_sort_fieldname_col_pos ) > 0. "otherwise no work to do...
SORT xt_data BY col_pos row_pos.
DATA lv_line_type_excluding TYPE c LENGTH 2.
lv_line_type_excluding = |{ lcl_salv_gui_table_writer_ida=>mc_line_type-hidden_subtotal }{ lcl_salv_gui_table_writer_ida=>mc_line_type-subtotal }{ lcl_salv_gui_table_writer_ida=>mc_line_type-total }|.
"Create a ref the previous line, fill with data when sy-tabix <> 1
DATA(lo_sample_structdescr) = me->o_data_source->get_structure_descriptor( ).
DATA lrs_previous_line TYPE REF TO data.
CREATE DATA lrs_previous_line TYPE HANDLE lo_sample_structdescr.
ASSIGN lrs_previous_line->* TO FIELD-SYMBOL(<s_previous_line>).
SORT lt_sort_fieldname_col_pos BY column_order.
READ TABLE lt_sort_fieldname_col_pos INTO DATA(ls_sort_fieldname_info) INDEX 1.
ASSERT sy-subrc EQ 0.
READ TABLE <t_appl_data> INTO <s_previous_line> INDEX ls_sort_fieldname_info-s_row_pos_range-from - 1.
"determine appl_data_index_range
IF lines( t_filter_miss_index ) > 0.
"match: 1,2,6,7 miss: 3,4,5,8
lcl_salv_range_tools=>convert_indexes_to_ranges(
EXPORTING it_sorted_index = CONV #( t_filter_miss_index )
IMPORTING et_range = DATA(lt_filter_miss_range)
).
"miss range: [3-5],[8-8]
lcl_salv_stv_itab_srv_utils=>get_opposite_range(
EXPORTING
t_normalized_range = lt_filter_miss_range
range_size = lines( <t_appl_data> )
IMPORTING
t_opposite_range = DATA(lt_appl_data_index_range)
).
"match range: [1-2],[6-7]
ELSE.
* STANDARD BUG?
* lt_appl_data_index_range = VALUE #( ( ls_sort_fieldname_info-s_source_index_range ) ). " STANDARD
lt_appl_data_index_range = VALUE #( ( ls_sort_fieldname_info-s_row_pos_range ) ). " FIX
ENDIF.
lcl_salv_gui_table_writer_ida=>stop_merge_cells_by_sort_level(
EXPORTING
t_appl_data_index_range = lt_appl_data_index_range
t_appl_data = <t_appl_data>
line_type_excluding = lv_line_type_excluding
rs_previous_result_data = lrs_previous_line
o_logger = o_logger
CHANGING
xt_sort_fieldname_col_pos = lt_sort_fieldname_col_pos
xt_lvc_data = xt_data
).
SORT xt_data BY row_pos col_pos.
ENDMETHOD.
METHOD lif_salv_gui_grid_facade~data_source.
IF me->o_data_source IS NOT BOUND.
DATA(lo_grid_datasource) = NEW lcl_grid_datasource(
o_grid = me->o_grid
o_parent = me ).
me->o_data_source = lo_grid_datasource. "cast #( cl_salv_gui_core_data_source=>create_for_external_ds( lo_grid_datasource ) ).
ENDIF.
o_data_source = me->o_data_source.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_LOGGER in ABAP 7.57 SP 0
CLASS lcl_salv_logger IMPLEMENTATION.
METHOD create_logger.
o_logger = NEW lcl_salv_logger( ).
IF gv_is_initialized <> abap_true.
" Performance shortcut for inactive trace (usual case)
" As consequence, it is not possible to activate trace for all users
* if not cl_salv_csq_params_db=>has_any_user_specific_value(
* user = sy-uname
* param_area = cl_salv_csq_params=>c_area ).
go_inactive_logger = NEW lcl_inactive_logger( ).
* endif.
gv_is_initialized = abap_true.
ENDIF.
IF go_inactive_logger IS BOUND.
o_logger = go_inactive_logger.
* else.
* create object o_logger type cl_salv_tr_logger
* exporting
* component = component
* class_shortened_name = class_shortened_name.
ENDIF.
ENDMETHOD.
METHOD lif_salv_logger~log_task_begin.
ENDMETHOD.
METHOD lif_salv_logger~log_task_end.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_STV_ITAB_SRV_UTILS in ABAP 7.57 SP 0
CLASS lcl_salv_stv_itab_srv_utils IMPLEMENTATION.
METHOD get_opposite_range.
CLEAR t_opposite_range.
DATA ls_previous_normalized_range TYPE lif_salv_service_types=>ys_range.
LOOP AT t_normalized_range INTO DATA(ls_normalized_range).
APPEND VALUE #( from = ls_previous_normalized_range-to + 1
to = ls_normalized_range-from - 1 ) TO t_opposite_range.
ls_previous_normalized_range = ls_normalized_range.
ENDLOOP.
IF sy-subrc EQ 0.
IF ls_normalized_range-to NE range_size.
APPEND VALUE #( from = ls_normalized_range-to + 1
to = range_size ) TO t_opposite_range.
ENDIF.
ELSE.
t_opposite_range = VALUE #( ( from = 1 to = range_size ) ).
ENDIF.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of LCL_GRID_DATASOURCE in class CL_SALV_GUI_GRID_FACADE in ABAP 7.57 SP 0
CLASS lcl_grid_datasource IMPLEMENTATION.
METHOD constructor.
me->o_grid = o_grid.
me->o_parent = o_parent.
ENDMETHOD.
METHOD lif_salv_gui_grid_data_source~get_r_appl_data.
rt_appl_data = me->o_grid->mt_outtab.
ENDMETHOD.
METHOD lif_salv_gui_grid_data_source~get_structure_descriptor.
IF me->o_grid->mt_outtab IS BOUND.
DATA(lo_tabledescr) = CAST cl_abap_tabledescr( cl_abap_tabledescr=>describe_by_data_ref( me->o_grid->mt_outtab ) ).
o_structdescr = CAST cl_abap_structdescr( lo_tabledescr->get_table_line_type( ) ).
ELSE.
* o_logger->log_task_begin( task = 'GET_STRUCTURE_DESCRIPTOR'
* text = 'Warning: a RT_OUTTAB is not bound...' ).
* "message a534(0k). -> can not be used, as also not relevant OUTTABS are existing in the system at this point in time, only protocol...
* "Example TA DBACOCKPIT
* o_logger->log_task_end( task = 'GET_STRUCTURE_DESCRIPTOR' ).
ENDIF.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CX_SALV_API_DYNAMIC in ABAP 7.57 SP 0
CLASS lcx_salv_api_dynamic IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor
EXPORTING
previous = previous.
CLEAR me->textid.
IF textid IS INITIAL.
if_t100_message~t100key = if_t100_message=>default_textid.
ELSE.
if_t100_message~t100key = textid.
ENDIF.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CX_SALV_API_CONTRACT_VIOLATION in ABAP 7.57 SP 0
CLASS lcx_salv_api_contract_violatio IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor
EXPORTING
previous = previous.
CLEAR me->textid.
IF textid IS INITIAL.
if_t100_message~t100key = lcx_salv_api_contract_violatio .
ELSE.
if_t100_message~t100key = textid.
ENDIF.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CX_SALV_INDEX_TABLE_NOT_SORTED in ABAP 7.57 SP 0
CLASS lcx_salv_index_table_not_sorte IMPLEMENTATION.
METHOD constructor.
CALL METHOD super->constructor
EXPORTING
previous = previous.
me->table_name = table_name .
CLEAR me->textid.
IF textid IS INITIAL.
if_t100_message~t100key = lcx_salv_index_table_not_sorte .
ELSE.
if_t100_message~t100key = textid.
ENDIF.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_GUI_TABLE_WRITER_IDA in ABAP 7.57 SP 0
CLASS lcl_salv_gui_table_writer_ida IMPLEMENTATION.
METHOD find_row_boundaries_4_mapping.
LOOP AT xt_sort_fieldname_info ASSIGNING FIELD-SYMBOL(<s_sort_fieldname_info>).
READ TABLE t_lvc_data INTO DATA(ls_data) BINARY SEARCH
WITH KEY col_pos = <s_sort_fieldname_info>-column_order.
" assert sy-subrc eq 0.
<s_sort_fieldname_info>-s_lvc_data_range-from = sy-tabix.
"Try to add first line to mapping table
LOOP AT t_lvc_data TRANSPORTING NO FIELDS FROM sy-tabix + 1
WHERE col_pos NE <s_sort_fieldname_info>-column_order.
DATA(lv_to) = sy-tabix - 1.
EXIT.
ENDLOOP.
IF sy-subrc NE 0.
lv_to = lines( t_lvc_data ).
ENDIF.
READ TABLE t_lvc_data INTO ls_data INDEX lv_to.
ASSERT sy-subrc EQ 0.
<s_sort_fieldname_info>-s_lvc_data_range-to = lv_to.
ENDLOOP.
ENDMETHOD.
METHOD get_condition_4_sort_rule.
IF lines( t_sort_fieldname_col_pos ) > 1.
READ TABLE t_sort_fieldname_col_pos TRANSPORTING NO FIELDS WITH KEY column_name = fieldname.
IF sy-subrc EQ 0.
DATA(lv_sort_seq_nr) = sy-tabix - 1.
DATA(lv_first_time) = abap_true.
LOOP AT t_sort_fieldname_col_pos INTO DATA(ls_sort_fieldname) TO lv_sort_seq_nr. "w/o RowIndicator
ls_sort_fieldname-column_name = cl_abap_dyn_prg=>escape_quotes_str( ls_sort_fieldname-column_name ).
IF lv_first_time EQ abap_true.
merge_condition = |{ ls_sort_fieldname-column_name } <> <S_RESULT_DATA>-{ ls_sort_fieldname-column_name }|.
ELSE.
merge_condition = |{ merge_condition } or { ls_sort_fieldname-column_name } <> <S_RESULT_DATA>-{ ls_sort_fieldname-column_name }|.
ENDIF.
lv_first_time = abap_false.
ENDLOOP.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD get_switch_level_4_sort_rule.
CLEAR t_switch_level_4_sort_rule.
DATA(lv_merge_condition) = get_condition_4_sort_rule(
fieldname = fieldname
t_sort_fieldname_col_pos = t_sort_fieldname_col_pos ).
IF lv_merge_condition IS NOT INITIAL.
DATA(lv_from) = s_result_index_range-from.
ASSIGN xrs_previous_result_data->* TO FIELD-SYMBOL(<s_result_data>).
DATA(lv_switch_level_range_nr) = 0.
DO.
LOOP AT t_result_data ASSIGNING <s_result_data> FROM lv_from
TO s_result_index_range-to
WHERE (lv_merge_condition).
DATA(lv_to) = sy-tabix - 1.
IF lv_switch_level_range_nr GT 0. "No first Run
IF lv_to GE lv_from. "not 1st Item = Previous
APPEND VALUE #( from = lv_from to = lv_to ) TO t_switch_level_4_sort_rule.
ENDIF.
* else.
* append value #( from = lv_from to = lv_to ) to t_switch_level_4_sort_rule.
ENDIF.
lv_from = lv_to + 1.
EXIT.
ENDLOOP.
IF sy-subrc NE 0.
IF ( lv_switch_level_range_nr GT 0 AND lv_to NE s_result_index_range-to ). "Current range
APPEND VALUE #( from = lv_from to = s_result_index_range-to ) TO t_switch_level_4_sort_rule.
ENDIF.
EXIT.
ENDIF.
IF <s_result_data> IS ASSIGNED.
xrs_previous_result_data = REF #( <s_result_data> ).
ENDIF.
ADD 1 TO lv_switch_level_range_nr.
ENDDO.
ENDIF.
ENDMETHOD.
METHOD set_stop_merge_style.
INCLUDE <cl_alv_control>.
"save original previous_line
IF xrs_previous_result_data IS NOT BOUND.
READ TABLE t_appl_data ASSIGNING FIELD-SYMBOL(<s_previous_result_data>) INDEX 1.
CHECK sy-subrc EQ 0.
ELSE.
ASSIGN xrs_previous_result_data->* TO <s_previous_result_data>.
ENDIF.
DATA lrs_previous_result_data_org TYPE REF TO data.
CREATE DATA lrs_previous_result_data_org LIKE <s_previous_result_data>.
ASSIGN lrs_previous_result_data_org->* TO FIELD-SYMBOL(<s_previous_result_data_org>).
lrs_previous_result_data_org = REF #( <s_previous_result_data> ).
IF xrs_previous_result_data IS BOUND.
<s_previous_result_data_org> = <s_previous_result_data>.
ENDIF.
"calculate switch level e.g. for SR3 additive
"SR1 : [1-3],[4-10] + SR2 : [1-10]
"=>SwitchLevel SR3 [1-3],[1-10],[4-10]
DATA(lt_appl_switch_level_4_so_rule) = VALUE lif_salv_service_types=>yt_range( ).
LOOP AT t_sort_fieldname_info INTO DATA(ls_sort_fieldname_info) FROM 2. "without first criteria
xrs_previous_result_data = lrs_previous_result_data_org.
LOOP AT t_appl_data_range INTO DATA(ls_appl_data_range).
DATA(lt_switch_level_4_sort_rule) = get_switch_level_4_sort_rule(
EXPORTING
s_result_index_range = ls_appl_data_range
t_result_data = t_appl_data
fieldname = CONV #( ls_sort_fieldname_info-column_name )
t_sort_fieldname_col_pos = t_sort_fieldname_info
CHANGING
xrs_previous_result_data = xrs_previous_result_data
).
APPEND LINES OF lt_switch_level_4_sort_rule TO lt_appl_switch_level_4_so_rule.
ENDLOOP.
SORT lt_appl_switch_level_4_so_rule BY from to. "#EC CI_SORTLOOP
IF lines( lt_appl_switch_level_4_so_rule ) > 0.
LOOP AT xt_lvc_data ASSIGNING FIELD-SYMBOL(<s_lvc_data>)
FROM ls_sort_fieldname_info-s_lvc_data_range-from
TO ls_sort_fieldname_info-s_lvc_data_range-to.
* STANDARD BUG?
* IF <s_lvc_data>-row_pos BETWEEN ls_sort_fieldname_info-s_source_index_range-from " STANDARD
* AND ls_sort_fieldname_info-s_source_index_range-to. " STANDARD
IF <s_lvc_data>-row_pos BETWEEN ls_sort_fieldname_info-s_row_pos_range-from " FIXED
AND ls_sort_fieldname_info-s_row_pos_range-to. " FIXED
READ TABLE lt_appl_switch_level_4_so_rule TRANSPORTING NO FIELDS BINARY SEARCH
WITH KEY from = <s_lvc_data>-row_id.
IF sy-subrc EQ 0.
ADD alv_style4_stop_merge TO <s_lvc_data>-style4.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
* if o_logger->is_active( ).
* analyse_merge_style4(
* exporting
* t_result_data = t_appl_data
* t_sort_fieldname_col_pos = t_sort_fieldname_info
* rs_previous_result_data = xrs_previous_result_data
* t_lvc_data = xt_lvc_data
* o_logger = o_logger
* ).
* endif.
ENDMETHOD.
METHOD stop_merge_cells_by_sort_level.
CHECK lines( xt_sort_fieldname_col_pos ) GT 1. "Stop cell merge required?
SORT xt_sort_fieldname_col_pos BY sort_rule_sequence_nr.
find_row_boundaries_4_mapping(
EXPORTING
t_lvc_data = xt_lvc_data
CHANGING
xt_sort_fieldname_info = xt_sort_fieldname_col_pos
).
set_stop_merge_style(
EXPORTING
t_sort_fieldname_info = xt_sort_fieldname_col_pos
t_appl_data_range = t_appl_data_index_range
t_appl_data = t_appl_data
o_logger = o_logger
CHANGING
xrs_previous_result_data = rs_previous_result_data
xt_lvc_data = xt_lvc_data
).
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_GUI_GRID_LINE_XY_CONV in ABAP 7.57 SP 0
CLASS lcl_salv_gui_grid_line_xy_conv IMPLEMENTATION.
METHOD get_line_and_offset.
line_offset = list_index MOD lines( it_column_order ).
line_index = list_index DIV lines( it_column_order ).
IF line_offset > 0.
ADD 1 TO line_index.
ELSE.
line_offset = lines( it_column_order ).
ENDIF.
ENDMETHOD.
METHOD get_list.
DATA: l_start_line TYPE sytabix.
DATA: l_start_line_column_offset TYPE sytabix.
DATA: l_end_line TYPE sytabix.
DATA: l_end_line_column_offset TYPE sytabix.
CLEAR t_list.
get_line_and_offset(
EXPORTING list_index = start_list_index
it_column_order = it_column_order
IMPORTING line_index = l_start_line
line_offset = l_start_line_column_offset ).
get_line_and_offset(
EXPORTING list_index = end_list_index
it_column_order = it_column_order
IMPORTING line_index = l_end_line
line_offset = l_end_line_column_offset ).
get_list_for_area(
EXPORTING
table_size = table_size
it_column_order = it_column_order
start_line_index = l_start_line
start_line_column_offset = l_start_line_column_offset
end_line_index = l_end_line
end_line_column_offset = l_end_line_column_offset
IMPORTING
t_list = t_list
).
ENDMETHOD.
METHOD get_list_compact.
DATA: l_start_line TYPE sytabix.
DATA: l_start_line_column_offset TYPE sytabix.
DATA: l_end_line TYPE sytabix.
DATA: l_end_line_column_offset TYPE sytabix.
CLEAR t_list_compact.
get_line_and_offset(
EXPORTING list_index = start_list_index
it_column_order = it_column_order
IMPORTING line_index = l_start_line
line_offset = l_start_line_column_offset ).
get_line_and_offset(
EXPORTING list_index = end_list_index
it_column_order = it_column_order
IMPORTING line_index = l_end_line
line_offset = l_end_line_column_offset ).
get_list_compact_for_area(
EXPORTING
it_column_order = it_column_order
start_line_index = l_start_line
start_line_column_offset = l_start_line_column_offset
end_line_index = l_end_line
end_line_column_offset = l_end_line_column_offset
IMPORTING
t_list_compact = t_list_compact
).
ENDMETHOD.
METHOD get_list_compact_for_area.
* importing
* start_line_index type sytabix
* start_line_column_offset type sytabix
* end_line_index type sytabix
* end_line_column_offset type sytabix
* exporting
* t_list type yt_list.
DATA: l_column_counter TYPE sytabix VALUE 1.
DATA: ls_list_compact TYPE lif_salv_gui_types_int_ida=>ys_x_y_list_compact.
DATA: l_column_name TYPE string.
DATA(l_visible_col_size) = lines( it_column_order ).
IF ( end_line_index - start_line_index + 1 ) > 1. "more than one line to proceed
LOOP AT it_column_order INTO l_column_name. "all
"general
ls_list_compact-column_order = l_column_counter. "sy-tabix.
ls_list_compact-column_name = l_column_name.
"position dependant
IF l_column_counter < start_line_column_offset
AND start_line_column_offset > 0.
* if start_line_column_offset > 0.
"offset = 5, visibleColumsn = 12 => delete the first 4 items of table
ls_list_compact-s_row_pos_range-from = start_line_index + 1.
ls_list_compact-s_source_index_range-from = 2.
* endif.
ELSE.
ls_list_compact-s_row_pos_range-from = start_line_index.
ls_list_compact-s_source_index_range-from = 1.
ENDIF.
IF l_column_counter > end_line_column_offset
AND end_line_column_offset > 0.
* "offset = 5, visibleColumsn = 12 => delete the last 7 items of table
ls_list_compact-s_row_pos_range-to = end_line_index - 1.
ls_list_compact-s_source_index_range-to = end_line_index - start_line_index + 1 - 1.
ELSE.
ls_list_compact-s_row_pos_range-to = end_line_index.
ls_list_compact-s_source_index_range-to = end_line_index - start_line_index + 1.
ENDIF.
APPEND ls_list_compact TO t_list_compact.
ADD 1 TO l_column_counter.
ENDLOOP.
ELSE.
"only one data line processing
LOOP AT it_column_order INTO l_column_name
FROM start_line_column_offset TO end_line_column_offset.
"general
ls_list_compact-column_order = l_column_counter. "sy-tabix.
ls_list_compact-column_name = l_column_name.
ls_list_compact-s_row_pos_range-from = start_line_index.
ls_list_compact-s_source_index_range-from = 1.
ls_list_compact-s_row_pos_range-to = end_line_index.
ls_list_compact-s_source_index_range-to = 1.
APPEND ls_list_compact TO t_list_compact.
ADD 1 TO l_column_counter.
ENDLOOP.
ENDIF.
SORT t_list_compact BY column_order s_source_index_range-from.
ENDMETHOD.
METHOD get_list_for_area.
* importing
* start_line_index type sytabix
* start_line_column_offset type sytabix
* end_line_index type sytabix
* end_line_column_offset type sytabix
* exporting
* t_list type yt_list.
DATA: l_counter TYPE sytabix VALUE 1.
DATA: l_rows TYPE sytabix.
DATA: l_line TYPE sytabix.
DATA: ls_list TYPE lif_salv_gui_types_int_ida=>ys_x_y_list.
DATA: l_column_name TYPE string.
DATA: l_from TYPE sy-tabix.
DATA: l_to TYPE sy-tabix.
DATA: l_run TYPE sy-tabix.
IF ( end_line_index - start_line_index + 1 ) > 1. "more than one line to proceed
l_line = start_line_index.
DO end_line_index - start_line_index + 1 TIMES.
ADD 1 TO l_run.
"at first row processing
IF l_run = 1.
l_from = start_line_column_offset.
l_to = lines( it_column_order ).
ENDIF.
"at last row processing
IF l_run = ( end_line_index - start_line_index + 1 ).
l_from = 1.
l_to = end_line_column_offset.
ENDIF.
"processing
LOOP AT it_column_order INTO l_column_name FROM l_from TO l_to. "all
CLEAR ls_list.
ls_list-index = l_counter.
ls_list-row_index = l_line.
ls_list-column_name = l_column_name.
ls_list-column_pos = sy-tabix.
ADD 1 TO l_counter.
APPEND ls_list TO t_list.
ENDLOOP.
"after processing the sub fields first time l_from must start at the beginning
l_from = 1.
ADD 1 TO l_line.
ENDDO.
ELSE.
"only one data line processing
* read table mt_table_lines_order into l_line index start_line_index.
* if sy-subrc eq 0.
l_line = start_line_index.
" if l_line between 1 and table_size.
LOOP AT it_column_order INTO l_column_name
FROM start_line_column_offset TO end_line_column_offset.
CLEAR ls_list.
ls_list-index = l_counter.
ls_list-row_index = l_line.
ls_list-column_name = l_column_name.
ls_list-column_pos = sy-tabix.
ADD 1 TO l_counter.
APPEND ls_list TO t_list.
ENDLOOP.
" endif.
ENDIF.
ENDMETHOD.
METHOD get_start_and_end_line_indizes.
* importing
* start_list_index type sytabix
* end_list_index type sytabix
* exporting
* start_table_line_index type sytabix
* end_table_line_index type sytabix.
IF include_row_indicator EQ abap_true.
DATA(lt_column_order) = it_column_order.
INSERT lcl_salv_gui_table_writer_ida=>mc_row_indicator INTO lt_column_order INDEX 1.
ELSE.
lt_column_order = it_column_order.
ENDIF.
get_line_and_offset(
EXPORTING list_index = start_list_index
it_column_order = lt_column_order
IMPORTING line_index = start_table_line_index ).
get_line_and_offset(
EXPORTING list_index = end_list_index
it_column_order = lt_column_order
IMPORTING line_index = end_table_line_index ).
ENDMETHOD.
METHOD get_start_and_end_x_y_indizes.
IF include_row_indicator EQ abap_true.
DATA(lv_columns_calculated) = nr_of_columns + 1.
ELSE.
lv_columns_calculated = nr_of_columns.
ENDIF.
start_list_x_y_index = ( ( start_table_line_index - 1 ) * lv_columns_calculated ) + 1.
end_list_x_y_index = end_table_line_index * lv_columns_calculated.
ENDMETHOD.
ENDCLASS.
* Copyright SAP pieces of CL_SALV_RANGE_TOOLS in ABAP 7.57 SP 0
CLASS lcl_salv_range_tools IMPLEMENTATION.
METHOD convert_indexes_to_ranges.
* Converts a table of indexes (integer values) into a range table.
*
* PRECONDITIONS:
* - it_sorted_indexes must be sorted ascending, otherwise an exception will be raised
*
* TOLERATED CONDITIONS:
* - negative or zero index values are silently ignored.
* - duplicated (repeating) index values are tolerated and will be considered only once.
*
* PERFORMANCE HINT:
* - if the caller _knows_ that there will be repeating index values, he should remove
* them with DELETE ADJACENT DUPLICATES. This can slightly improve the performance
* of this method.
DATA: l_index TYPE y_index,
ls_range TYPE lif_salv_service_types=>ys_range,
l_first_nonzero_tabix TYPE sytabix.
CLEAR et_range.
"find first non-zero index:
l_first_nonzero_tabix = 1.
LOOP AT it_sorted_index INTO l_index WHERE table_line > 0.
l_first_nonzero_tabix = sy-tabix.
EXIT.
ENDLOOP.
IF sy-subrc IS INITIAL. "previous loop-body was executed
ls_range-from = ls_range-to = l_index.
LOOP AT it_sorted_index INTO l_index FROM l_first_nonzero_tabix + 1.
IF l_index = ls_range-to + 1.
ls_range-to = l_index.
ELSEIF l_index > ls_range-to + 1.
APPEND ls_range TO et_range.
ls_range-from = ls_range-to = l_index.
ELSEIF l_index < ls_range-to.
"it_sorted_indexes is not sorted
RAISE EXCEPTION TYPE lcx_salv_index_table_not_sorte
EXPORTING
table_name = 'IT_SORTED_INDEXES'
##no_text.
"elseif l_index = ls_range-to.
"duplicate index - ignore.
ENDIF.
ENDLOOP.
APPEND ls_range TO et_range.
ENDIF.
ENDMETHOD.
ENDCLASS.
*"* use this source file for any macro definitions you need
*"* in the implementation part of the class
define _macro_assign_collect_tables.
field-symbols: <lt_collect00> type standard table,
<lt_collect01> type standard table,
<lt_collect02> type standard table,
<lt_collect03> type standard table,
<lt_collect04> type standard table,
<lt_collect05> type standard table,
<lt_collect06> type standard table,
<lt_collect07> type standard table,
<lt_collect08> type standard table,
<lt_collect09> type standard table.
assign o_grid->mt_ct00->* to <lt_collect00>.
assign o_grid->mt_ct01->* to <lt_collect01>.
assign o_grid->mt_ct02->* to <lt_collect02>.
assign o_grid->mt_ct03->* to <lt_collect03>.
assign o_grid->mt_ct04->* to <lt_collect04>.
assign o_grid->mt_ct05->* to <lt_collect05>.
assign o_grid->mt_ct06->* to <lt_collect06>.
assign o_grid->mt_ct07->* to <lt_collect07>.
assign o_grid->mt_ct08->* to <lt_collect08>.
assign o_grid->mt_ct09->* to <lt_collect09>.
end-of-definition.
define _macro_assign_outtab.
field-symbols: <tab1> type standard table.
try.
assign o_grid->mt_outtab->* to <tab1>.
catch CX_SY_RMC_COMM_FAILURE.
endtry.
end-of-definition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment