Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
endclass.
class lcl_handler implementation.
METHOD on_added_function.
data: lt_rows type salv_t_row,
l_row
type i,
l_row_string type char128,
l_row_info type char128.
*** Customized Function to re-order columns
IF e_salv_function EQ 'RESEND'.
*** get alv property column
it_temp[] = i_final[].
delete it_temp where checkbox = ' '.
stofile = '/gt/dump/inbound/2012.sto'.
try.
OPEN DATASET stofile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .
IF sy-subrc ne 0.
write 'error'.
else.
loop at it_temp into wa_sflight.
mandt_z = wa_sflight-mandt.
fldate_z = wa_sflight-fldate.
price_z = wa_sflight-price.
currency_z = wa_sflight-currency.
CONCATENATE MANDT_Z
wa_sflight-carrid
wa_sflight-connid
currency_z
price_z
fldate_z into z_string separated by '|'.
TRANSFER z_string TO stofile.
endloop.
ENDIF.
catch cx_root.
endtry.
CLOSE DATASET stofile.
obj_alv->refresh( ).
ELSEIF e_salv_function EQ 'SELECT'.
wa_sflight-checkbox = 'X'.
modify i_final from wa_sflight transporting checkbox where checkbox NE '
X'.
obj_alv->refresh( ).
ELSEIF e_salv_function EQ 'DESELECT'.
wa_sflight-checkbox = ' '.
modify i_final from wa_sflight transporting checkbox where checkbox NE
' '.
obj_alv->refresh( ).
ENDIF.
ENDMETHOD.
METHOD on_link_click.
if COLUMN = 'CHECKBOX'.
PERFORM f_change_flag USING row.
ENDIF.
ENDMETHOD.
endclass.
START-OF-SELECTION.
"CREATE OBJECT r_handler.
select * from sflight into wa_sflight.
* SELECT * FROM spfli INTO wa_final.
APPEND wa_sflight TO i_final.
ENDSELECT.
call screen 0100.
"*&---------------------------------------------------------------------*
*&
Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
module STATUS_0100 output.
SET PF-STATUS '100'.
* SET TITLEBAR 'xxx'.
endmodule.
" STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
module USER_COMMAND_0100 input.
IF ok_code EQ 'BACK'
OR ok_code EQ 'CANCEL'
OR ok_code EQ 'EXIT'.
LEAVE TO SCREEN 0.
ENDIF.
clear ok_code.
endmodule.
" USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*&
Module INITIALIZE_CONTAINER OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
module INITIALIZE_CONTAINER output.
IF gr_container IS INITIAL.
create object gr_container
exporting
container_name = 'CC_ALV'
exceptions
others = 1.
perform display_alv.
ENDIF.
endmodule.
" INITIALIZE_CONTAINER OUTPUT
*&---------------------------------------------------------------------*
*&
Form DISPLAY_ALV
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form DISPLAY_ALV .
data: l_icon type string,
l_text type string,
l_tooltip type string.
CALL METHOD cl_salv_table=>factory
exporting
r_container = gr_container
IMPORTING
r_salv_table = obj_alv
CHANGING
t_table
= i_final.
obj_display = obj_alv->get_display_settings( ).
"** SET ALL ALV Generic Buttons (Functions)
obj_functions = obj_alv->get_functions( ).
"obj_functions->set_all( ).
"** Set SELECTION MODE, CELL = Multiple select of
"** Column, rows, cell
obj_selections = obj_alv->get_selections( ).
obj_selections->set_selection_mode(
value = if_salv_c_selection_mode=>cell ).
obj_layout = obj_alv->get_layout( ).
*** Restrict None = User can save his own layout
obj_layout->set_save_restriction(
value = if_salv_c_layout=>restrict_none ).
lr_event = obj_alv->get_event( ).
l_icon = ICON_ORDER.
l_text = 'Resend'.
l_tooltip = 'Resend Line Items'.
obj_functions->add_function(
name = 'RESEND'
icon = l_icon
text = l_text
tooltip = l_tooltip
position = if_salv_c_function_position=>right_of_salv_functions
).
l_icon = ICON_SELECT_ALL.
lr_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
lr_column->set_output_length( 8 ).
" display length
lr_column->set_long_text( 'CHECKBOX' ).
" Display name in ALV o
utput
lr_columns->set_column_position( columnname = 'CHECKBOX' position = 1 ).
*
lr_sorts->add_sort(
*
columnname = 'CHECKBOX'
*
position = 1 ).
*** Set AUART as invisible
obj_alv->display( ).
endform.
" DISPLAY_ALV
*&---------------------------------------------------------------------*
*&
Form F_CHANGE_FLAG
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_ROW text
*----------------------------------------------------------------------*
form F_CHANGE_FLAG using
p_row.