method CREATE_PRINT_ALV DATA lr_salv_wd_table_usa ge TYPE REF TO if_wd

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
method CREATE_PRINT_ALV .
DATA:
lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
DATA:
lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
lr_salv_wd_table_usage->create_component( ).
ENDIF.
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
DATA:
lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lv_table_config TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
lv_column_settings TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS,
lt_columns TYPE SALV_WD_T_COLUMN_REF,
lr_column type ref to cl_salv_wd_column,
lr_input type ref to cl_salv_wd_uie_input_field,
lr_img TYPE REF TO CL_SALV_WD_UIE_IMAGE,
lr_header type ref to CL_SALV_WD_HEADER,
lr_col_header type ref to CL_SALV_WD_column_HEADER,
lr_buttonui type REF TO CL_SALV_WD_FE_BUTTON,
lv_input_name TYPE string.
DATA:
lr_field_settings TYPE REF TO IF_SALV_WD_FIELD_SETTINGS,
lr_field_curr TYPE REF TO CL_SALV_WD_FIELD,
lr_field_amnt TYPE REF TO CL_SALV_WD_FIELD.
DATA: lv_aggr_rule TYPE REF TO CL_SALV_WD_AGGR_RULE.
DATA: lr_sort_rule TYPE REF TO CL_SALV_WD_SORT_RULE.
data:
lt_node_info type WDR_CONTEXT_ATTR_INFO_MAP,
ls_node_info type WDR_CONTEXT_ATTRIBUTE_INFO,
lr_info type ref to IF_WD_CONTEXT_NODE_INFO,
lt_attr TYPE TABLE OF string.
FIELD-SYMBOLS: <fs_column> TYPE SALV_WD_S_COLUMN_REF.
types: BEGIN OF visible_column,
name TYPE string,
END OF visible_column.
data: lt_visible_cols TYPE TABLE OF VISIBLE_COLUMN,
ls_visible_col TYPE VISIBLE_COLUMN.
* LR_INFO = WD_CONTEXT->GET_CHILD_NODE( NAME = wd_this->WDCTX_FILTER )->GET_NODE_INFO( ).
* LT_ATTR = LR_INFO->GET_ATTRIBUTE_NAMES( ).
* LT_NODE_INFO = LR_INFO->GET_ATTRIBUTEs( ).
*
* LOOP AT LT_NODE_INFO INTO LS_NODE_INFO.
* LS_VISIBLE_COL-NAME = LS_NODE_INFO-NAME.
*
* APPEND LS_VISIBLE_COL to LT_VISIBLE_COLS.
* ENDLOOP.
* setup visible columns
ls_visible_col-NAME = 'NUM'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'MATNR'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'SIZES'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'HEIGHT'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'SEASON'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
* ls_visible_col-NAME = 'EBELN'.
* APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'NUM_TO_PRINT'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'PRINTED_TAGS_NUM'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
ls_visible_col-NAME = 'IMG'.
APPEND ls_visible_col to LT_VISIBLE_COLS.
* ls_visible_col-NAME = 'STATUS'.
* APPEND ls_visible_col to LT_VISIBLE_COLS.
LR_SALV_WD_TABLE->SET_DATA( EXPORTING R_NODE_DATA = WD_CONTEXT->GET_CHILD_NODE( NAME = wd_this->WDCTX_FILTER ) ).
LV_TABLE_CONFIG = LR_SALV_WD_TABLE->GET_MODEL( ).
LV_COLUMN_SETTINGS ?= LV_TABLE_CONFIG.
LT_COLUMNS = LV_COLUMN_SETTINGS->GET_COLUMNS( ).
* aggregation rules
LR_FIELD_SETTINGS ?= LV_TABLE_CONFIG.
LOOP AT LT_COLUMNS ASSIGNING <FS_COLUMN>.
CASE <FS_COLUMN>-ID.
WHEN 'NUM_TO_PRINT'.
LR_FIELD_AMNT = LV_TABLE_CONFIG->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD( <FS_COLUMN>-id ).
LV_AGGR_RULE = LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE( AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL ).
WHEN 'MATNR1'.
LR_FIELD_CURR = LV_TABLE_CONFIG->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD( <FS_COLUMN>-id ).
LR_SORT_RULE = LR_FIELD_CURR->IF_SALV_WD_SORT~CREATE_SORT_RULE( SORT_ORDER = IF_SALV_WD_C_SORT=>SORT_ORDER_ASCENDING GROUP_AGGREGATION = ABAP_TRUE ).
WHEN OTHERS.
ENDCASE.
ENDLOOP.
* setting visible columns
LOOP AT LT_COLUMNS ASSIGNING <FS_COLUMN>.
READ TABLE LT_VISIBLE_COLS WITH TABLE KEY name = <FS_COLUMN>-ID TRANSPORTING NO FIELDS.
if sy-subrc ne 0.
LV_COLUMN_SETTINGS->DELETE_COLUMN( EXPORTING ID = <FS_COLUMN>-ID ).
ELSE.
LR_COLUMN = <FS_COLUMN>-R_COLUMN.
if <FS_COLUMN>-ID ne 'IMG' and <FS_COLUMN>-id ne 'NUM' and <FS_COLUMN>-id ne 'PRINTED_TAGS_NUM' and <FS_COLUMN>-id ne 'SEASON' and <FS_COLUMN>-id ne 'SIZES' and <FS_COLUMN>-id ne 'HEIGHT'.
CREATE OBJECT LR_INPUT
EXPORTING
VALUE_FIELDNAME = <FS_COLUMN>-ID.
LR_INPUT->SET_READ_ONLY_FIELDNAME( 'INDICATOR' ).
LR_COLUMN->SET_CELL_EDITOR( LR_INPUT ).
ELSEIF <FS_COLUMN>-id eq 'IMG'.
CREATE OBJECT lr_img.
lr_img->SET_SOURCE_FIELDNAME( 'IMG' ).
lr_column->set_cell_editor( lr_img ).
ELSEif <FS_COLUMN>-id eq 'SEASON' or <FS_COLUMN>-id eq 'SIZES' or <FS_COLUMN>-id eq 'HEIGHT'.
data lr_ddbk type ref to CL_SALV_WD_UIE_DROPDOWN_BY_KEY.
CREATE OBJECT LR_DDBK
EXPORTING
* VALUE_FIELDNAME = 'SEASON'
SELECTED_KEY_FIELDNAME = <FS_COLUMN>-ID
.
* LR_DDBK->SET_VALUE_FIELDNAME( 'SEASON' ).
LR_COLUMN->SET_CELL_EDITOR( LR_DDBK ).
LR_DDBK->SET_READ_ONLY_FIELDNAME( 'INDICATOR' ).
ENDIF.
ENDIF.
ENDLOOP.
* column names
wd_this->CHANGE_COL_NAME( EXPORTING IR_COL_SETTINGS = LV_COLUMN_SETTINGS IV_COL_NAME = 'NUM' IV_NEW_COL_NAME = '№' ).
wd_this->CHANGE_COL_NAME( EXPORTING IR_COL_SETTINGS = LV_COLUMN_SETTINGS IV_COL_NAME = 'PRINTED_TAGS_NUM' IV_NEW_COL_NAME = 'Кол. напеч. меток.' ).
wd_this->CHANGE_COL_NAME( EXPORTING IR_COL_SETTINGS = LV_COLUMN_SETTINGS IV_COL_NAME = 'NUM_TO_PRINT' IV_NEW_COL_NAME = 'Кол-во' ).
wd_this->CHANGE_COL_NAME( EXPORTING IR_COL_SETTINGS = LV_COLUMN_SETTINGS IV_COL_NAME = 'IMG' IV_NEW_COL_NAME = 'Статус проверки' ).
* LV_TABLE_CONFIG->if_salv_wd_table_settings~set_row_selectable_fieldname( 'SELECTABLE' ).
LR_HEADER = LV_TABLE_CONFIG->IF_SALV_WD_TABLE_SETTINGS~GET_HEADER( ).
* LR_HEADER->SET_TEXT('ALV title').
data lt_func TYPE REF TO salv_wd_t_function_ref.
data lr_func TYPE REF TO CL_SALV_WD_FUNCTION_STD.
CREATE OBJECT lr_buttonui.
lr_buttonui->SET_TEXT( 'Копировать' ).
DATA button1 TYPE REF TO CL_SALV_WD_FUNCTION.
button1 = LV_TABLE_CONFIG->IF_SALV_WD_FUNCTION_SETTINGS~create_function( id = 'L_BUTTON_COPY' ).
button1->SET_EDITOR( lr_buttonui ).
LR_FUNC = LV_TABLE_CONFIG->IF_SALV_WD_FUNCTION_SETTINGS~GET_FUNCTION_STD( ID = 'SALV_WD_INPUT_APPEND_ROW' ).
* LV_TABLE_CONFIG->IF_SALV_WD_FUNCTION_SETTINGS~CREATE_FUNCTION( ID = 'SALV_WD_INPUT_APPEND_ROW' ).
LV_TABLE_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_CHECK_AVAILABLE( abap_false ).
LV_TABLE_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_INSERT_ROW_ALLOWED( abap_false ).
LV_TABLE_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_EDIT_INSERT_ROWS_ALLOWED( abap_false ).
LV_TABLE_CONFIG->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( abap_false ).
* LV_TABLE_CONFIG->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_HEADERCLICK_ALLOWED( abap_true ).
LV_TABLE_CONFIG->if_salv_wd_std_functions~set_edit_insert_row_allowed( ).
LV_TABLE_CONFIG->if_salv_wd_table_settings~set_data_check( if_salv_wd_c_table_settings=>data_check_on_cell_event ).
LV_TABLE_CONFIG->IF_SALV_WD_TABLE_SETTINGS~SET_WIDTH( VALUE = '100%' ).
endmethod.