REPORT z15_25.
DATA : gt_sflight LIKE sflight OCCURS 0 WITH HEADER LINE.
DATA : con1_ref TYPE REF TO cl_gui_custom_container.
DATA : g_grid TYPE REF TO cl_gui_alv_grid.
DATA : gs_variant TYPE disvariant.
DATA : gs_layout TYPE lvc_s_layo.
DATA : gt_toolbar TYPE ui_functions.
DATA : gt_sort TYPE lvc_t_sort.
DATA : gt_fieldcat TYPE lvc_t_fcat.
DATA : gt_modified_rows TYPE STANDARD TABLE OF sflight.
DATA : ok_code TYPE sy-ucomm.
TYPE-POOLS: icon.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS : handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive.
METHODS : handle_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
ls_toolbar-butn_type = 3.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
ls_toolbar-function = 'RESH'.
ls_toolbar-icon = icon_refresh.
ls_toolbar-quickinfo = 'Refresh'.
ls_toolbar-text = ' '.
ls_toolbar-disabled = ' '.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_command.
DATA : l_scroll TYPE lvc_s_stbl.
CASE e_ucomm.
WHEN 'RESH'.
SELECT * FROM sflight INTO TABLE gt_sflight.
l_scroll-row = 'X'.
l_scroll-col = 'X'.
CALL METHOD g_grid->refresh_table_display
EXPORTING
i_soft_refresh = ''
is_stable = l_scroll.
ENDCASE.
ENDMETHOD. "handle_command
METHOD handle_data_changed.
DATA:
ls_sflight TYPE sflight,
ls_outtab LIKE LINE OF gt_sflight.
FIELD-SYMBOLS: <fs> TYPE table.
ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
LOOP AT <fs> INTO ls_outtab.
MOVE-CORRESPONDING ls_outtab TO ls_sflight.
APPEND ls_sflight TO gt_modified_rows.
ENDLOOP.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
PARAMETERS: p_vari LIKE disvariant-variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
gs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = gs_variant
i_save = 'A'
IMPORTING
es_variant = gs_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
p_vari = gs_variant-variant.
ENDIF.
START-OF-SELECTION.
SELECT * FROM sflight
INTO TABLE gt_sflight UP TO 100 ROWS.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module INIT_CON OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE init_con OUTPUT.
IF con1_ref IS INITIAL.
CREATE OBJECT con1_ref
EXPORTING
container_name = 'CON1'.
CREATE OBJECT g_grid
EXPORTING
i_parent = con1_ref.
ENDIF.
gs_variant-report = sy-repid.
gs_variant-username = sy-uname.
PERFORM setting_layout CHANGING gs_layout.
PERFORM setting_toolbar.
PERFORM setting_sort.
* PERFORM getting_catalog.
PERFORM setting_catalog.
PERFORM setting_dropdown.
DATA : event_receiver TYPE REF TO lcl_event_receiver.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_data_changed FOR g_grid.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
*
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
* i_structure_name = 'SFLIGHT'
is_variant = gs_variant
i_save = 'A'
i_default = ''
is_layout = gs_layout
it_toolbar_excluding = gt_toolbar
CHANGING
it_outtab = gt_sflight[]
it_fieldcatalog = gt_fieldcat
it_sort = gt_sort.
ENDMODULE. " INIT_CON OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE TO SCREEN 0.
WHEN 'SAVE'.
DATA: l_valid TYPE c.
CALL METHOD g_grid->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid IS NOT INITIAL.
PERFORM update_database.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '100_STATUS'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form SETTING_LAYOUT
*&---------------------------------------------------------------------*
FORM setting_layout CHANGING p_layout TYPE lvc_s_layo.
p_layout-cwidth_opt = ''. "칼럼 길이 자동조절
p_layout-grid_title = 'Drop Down List Test'.
"타이틀 바
p_layout-sel_mode = 'B'. "선택모드 : 멀티 선택 가능
p_layout-zebra = ''. "Sripe 속성 지정
* p_layout-edit = 'X'.
ENDFORM. " setting_layout
*&---------------------------------------------------------------------*
*& Form SETTING_TOOLBAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM setting_toolbar .
DATA: l_exclude TYPE ui_func.
l_exclude = cl_gui_alv_grid=>mc_fc_save_variant.
APPEND l_exclude TO gt_toolbar.
l_exclude = cl_gui_alv_grid=>mc_fc_maintain_variant.
APPEND l_exclude TO gt_toolbar.
ENDFORM. " SETTING_TOOLBAR
*&---------------------------------------------------------------------*
*& Form SETTING_SORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM setting_sort .
DATA : ls_sort TYPE lvc_s_sort.
ls_sort-spos = '1'.
ls_sort-fieldname = 'CARRID'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO gt_sort.
ENDFORM. " SETTING_SORT
*&---------------------------------------------------------------------*
*& Form SETTING_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM setting_catalog .
DATA : ls_fieldcat TYPE lvc_s_fcat.
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-coltext = 'Airline Code'.
ls_fieldcat-edit = 'X'.
ls_fieldcat-COL_POS = '1'.
ls_fieldcat-drdn_hndl = '1'.
ls_fieldcat-drdn_alias = 'X'.
ls_fieldcat-checktable = '!'. "do not check foreign keys
ls_fieldcat-outputlen = '5'.
APPEND ls_fieldcat TO gt_fieldcat.
clear : ls_fieldcat.
ls_fieldcat-fieldname = 'CONNID'.
ls_fieldcat-coltext = 'Flight Number'.
ls_fieldcat-COL_POS = '2'.
ls_fieldcat-just = 'C'.
ls_fieldcat-key = 'X'.
ls_fieldcat-outputlen = '4'.
APPEND ls_fieldcat TO gt_fieldcat.
clear : ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-coltext = 'Airfare'.
ls_fieldcat-COL_POS = '3'.
ls_fieldcat-just = 'R'.
ls_fieldcat-key = ' '.
ls_fieldcat-outputlen = '15'.
APPEND ls_fieldcat TO gt_fieldcat.
ENDFORM. " SETTING_CATALOG
*&---------------------------------------------------------------------*
*& Form GETTING_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM getting_catalog .
DATA : lt_fieldcat TYPE kkblo_t_fieldcat.
CALL FUNCTION 'K_KKB_FIELDCAT_MERGE'
EXPORTING
i_callback_program = sy-repid
i_tabname = 'GT_SFLIGHT'
i_inclname = sy-repid
CHANGING
ct_fieldcat = lt_fieldcat[].
IF sy-subrc EQ 0.
CALL FUNCTION 'LVC_TRANSFER_FROM_KKBLO'
EXPORTING
it_fieldcat_kkblo = lt_fieldcat[]
IMPORTING
et_fieldcat_lvc = gt_fieldcat[].
ENDIF.
ENDFORM. " GETTING_CATALO
*&---------------------------------------------------------------------*
*& Form UPDATE_DATABASE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM update_database .
MODIFY sflight FROM TABLE gt_modified_rows.
IF sy-subrc EQ 0.
MESSAGE 'SAVE OK' TYPE 'I'.
ENDIF.
ENDFORM. " UPDATE_DATABASE
*&---------------------------------------------------------------------*
*& Form SETTING_DROPDOWN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form SETTING_DROPDOWN .
DATA: lt_dropdown TYPE lvc_t_dral,
ls_dropdown TYPE lvc_s_dral.
ls_dropdown-handle = '1'.
ls_dropdown-int_value = 'AA'.
ls_dropdown-value = 'AA : American Airlines'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-int_value = 'AZ'.
ls_dropdown-value = 'AZ : Alitalia'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-int_value = 'UA'.
ls_dropdown-value = 'UA : United Airlines'.
APPEND ls_dropdown TO lt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down_alias = lt_dropdown.
endform. " SETTING_DROPDOWN
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
631 | REPORT z17_01 . | sapjoy | 2012.08.02 | 1084 |
630 | REPORT z16_11. | sapjoy | 2012.08.02 | 1408 |
629 | REPORT z16_10. | sapjoy | 2012.08.02 | 1190 |
628 | REPORT z16_08. | sapjoy | 2012.08.02 | 1095 |
627 | REPORT z16_07. | sapjoy | 2012.08.02 | 1079 |
626 | REPORT z16_06. | sapjoy | 2012.08.02 | 1015 |
625 | REPORT z16_05. | sapjoy | 2012.08.02 | 1193 |
624 | REPORT z16_04. | sapjoy | 2012.08.02 | 1247 |
623 | REPORT z16_03. | sapjoy | 2012.08.02 | 1148 |
622 | REPORT Z16_02. | sapjoy | 2012.08.02 | 944 |
621 | REPORT z16_01. | sapjoy | 2012.08.02 | 1078 |
620 | REPORT z15_28. | sapjoy | 2012.08.02 | 1030 |
619 | REPORT z15_27. | sapjoy | 2012.08.02 | 949 |
618 | REPORT z15_26. | sapjoy | 2012.08.02 | 976 |
» | REPORT z15_25. [1] | sapjoy | 2012.08.02 | 1202 |
616 | REPORT z15_24. | sapjoy | 2012.08.02 | 1410 |
615 | REPORT z15_23. [1] | sapjoy | 2012.08.02 | 1220 |
614 | REPORT z15_22. | sapjoy | 2012.08.02 | 1112 |
613 | REPORT z15_21. | sapjoy | 2012.08.02 | 1163 |
612 | REPORT z15_20. | sapjoy | 2012.08.02 | 1212 |
z15-26과 z15-25의 소스가 바뀐 것 같습니다.