Code: Alles auswählen.
if <ALV_OUT>-TIM_BEG lt <ALV_OUT>-TRT_END or <ALV_OUT>-TIM_END lt <ALV_OUT>-TRT_BEG.
perform WARNUNG_ZEILE using 'C' 'Reise- oder Arbeitszeiten überschneiden sich'
changing <ALV_OUT> .
<ALV_OUT>-CHECKBOX = 'X'.
endif.
Code: Alles auswählen.
data: LS_FCAT type LVC_S_FCAT.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
I_STRUCTURE_NAME = 'struktur'
changing
CT_FIELDCAT = PT_FIELDCAT[]
exceptions
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
others = 3.
clear LS_FCAT.
LS_FCAT-FIELDNAME = 'CHECKBOX'.
LS_FCAT-CHECKBOX = 'X'.
LS_FCAT-EDIT = 'X'.
* LS_FCAT-HOTSPOT = 'X'.
LS_FCAT-EMPHASIZE = 'X'.
LS_FCAT-COLTEXT = TEXT-F01.
LS_FCAT-OUTPUTLEN = 10.
append LS_FCAT to PT_FIELDCAT[].
Code: Alles auswählen.
if <ALV_OUT>-TIM_BEG lt <ALV_OUT>-TRT_END or <ALV_OUT>-TIM_END lt <ALV_OUT>-TRT_BEG.
--> SET HANDLERNadine_2706 hat geschrieben:Aber wie ich das mache, dass erst bei checkbox-deaktivierung fie Fehlermeldung gelöscht wird?
Es gibt noch einen anderen Thread, der dieses Problem bereits geklärt hattekm216 hat geschrieben:Ohne jetzt den Hintergrund zu kennen würde ich tippen, dass statt dem zweiten lt ein gt hin muss...
Code: Alles auswählen.
form GET_FIELDCAT changing PT_FIELDCAT type LVC_T_FCAT.
data: LV_KEY type CHAR4,
LS_FCAT type LVC_S_FCAT.
field-symbols:
<FIELDCAT> type line of LVC_T_FCAT.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
I_STRUCTURE_NAME = 'ZHCM_AZB_MONTAGE_ALV'
changing
CT_FIELDCAT = PT_FIELDCAT[]
exceptions
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
others = 3.
clear LS_FCAT.
LS_FCAT-FIELDNAME = 'CHECKBOX'.
LS_FCAT-CHECKBOX = 'X'.
LS_FCAT-EDIT = 'X'.
LS_FCAT-HOTSPOT = 'X'.
LS_FCAT-EMPHASIZE = 'X'.
LS_FCAT-COLTEXT = TEXT-F01.
LS_FCAT-OUTPUTLEN = 10.
append LS_FCAT to PT_FIELDCAT[].
endform.
Code: Alles auswählen.
class LCL_EVENT_RECEIVER definition.
public section.
methods:
* Hotspot clicking
HOTSPOT_CLICK
for event HOTSPOT_CLICK of CL_GUI_ALV_GRID
importing E_ROW_ID
E_COLUMN_ID
ES_ROW_NO,
* Data changed (such as checkbox clicking)
HANDLE_DATA_CHANGED
for event DATA_CHANGED of CL_GUI_ALV_GRID
importing ER_DATA_CHANGED.
endclass.
class LCL_EVENT_RECEIVER implementation.
method HOTSPOT_CLICK.
perform EVENT_HOTSPOT_CLICK
using E_ROW_ID
E_COLUMN_ID.
endmethod. "hotspot_click
method HANDLE_DATA_CHANGED.
data: LV_CHANGED type LVC_S_MODI.
loop at ER_DATA_CHANGED->MT_GOOD_CELLS into LV_CHANGED
where FIELDNAME = 'CHECKBOX'.
read table i_alv_data into v_alv_data index LV_CHANGED-ROW_ID.
if SY-SUBRC = 0.
move LV_CHANGED-VALUE to V_ALV_DATA-CHECKBOX.
modify I_ALV_DATA from V_ALV_DATA index LV_CHANGED-ROW_ID.
endif.
endloop.
endmethod. "handle_data_changed
endclass.
Code: Alles auswählen.
FORM EVENT_HOTSPOT_CLICK
USING p_row TYPE lvc_s_row
p_column TYPE lvc_s_col.
READ TABLE i_alv_data INTO v_alv_data INDEX p_row-index.
IF p_column = 'CHECKBOX'.
* call a transaction when the cust_id is clicked
MESSAGE i012.
ENDIF.
ENDFORM. " EVENT_HOTSPOT_CLICK
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
Nadine_2706
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ALV WITH CHECKBOX *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT yalv_mit_checkbox2.
INCLUDE <icon>.
DATA: BEGIN OF it_data OCCURS 0,
cb(1).
INCLUDE STRUCTURE sflight.
DATA END OF it_data.
* Grid Parameter
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_CONTAINER',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
*--- Field catalog table
DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
*--- Layout structure
DATA gs_layout TYPE lvc_s_layo .
* LT_EXCLUDE => Tabelle zum Ausschliessen von Funktionen innerhalb
* der Toolbar des ALV-Grid
DATA: lt_exclude TYPE ui_functions,
ls_exclude TYPE ui_func.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
INITIALIZATION.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--hotspot-click control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Double Click
METHOD handle_hotspot_click .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS. "lcl_event_handler IMPLEMENTATION
DATA gr_event_handler TYPE REF TO lcl_event_handler .
* Eingabe und Auswertung ---------------------------------------------*
START-OF-SELECTION.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_data.
CALL SCREEN 100.
EXIT.
*&---------------------------------------------------------------------*
*& Module PBO OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*----Preparing field catalog.
PERFORM prepare_field_catalog TABLES gt_fieldcat[] .
*----Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout .
*----Preparing Disable Toolbar Buttons
PERFORM change_buttons .
CALL METHOD grid1->set_table_for_first_display
EXPORTING
* i_save = ' '
is_layout = gs_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = it_data[]
it_fieldcatalog = gt_fieldcat[].
*--Registering handler methods to handle ALV Grid events JG
SET HANDLER gr_event_handler->handle_hotspot_click FOR grid1.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'AUSW' WITH text-001.
ENDMODULE. " PBO OUTPUT
*&---------------------------------------------------------------------*
*& Module PAI INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI INPUT
*&--------------------------------------------------------------------*
*& Form prepare_field_catalog
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->PT_FIELDCATtext
*---------------------------------------------------------------------*
FORM prepare_field_catalog TABLES pt_fieldcat TYPE lvc_t_fcat .
DATA ls_fcat TYPE lvc_s_fcat .
* DATA lv_depth TYPE i.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = pt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
CLEAR ls_fcat.
READ TABLE pt_fieldcat INTO ls_fcat WITH KEY fieldname = 'CARRID'.
ls_fcat-fieldname = 'CB'.
ls_fcat-hotspot = 'X'.
ls_fcat-domname = 'FLAG'.
ls_fcat-dd_outlen = '1'.
ls_fcat-intlen = '1'.
ls_fcat-coltext = 'Select'.
ls_fcat-reptext = 'Select'.
ls_fcat-checkbox = 'X'.
ls_fcat-scrtext_l = 'Auswahl'.
ls_fcat-scrtext_m = 'Auswahl'.
ls_fcat-scrtext_s = 'Auswahl'.
ls_fcat-ref_table = 'KAEP_COAC'.
ls_fcat-tabname = '1'.
INSERT ls_fcat INTO pt_fieldcat INDEX 1.
LOOP AT pt_fieldcat INTO ls_fcat .
ls_fcat-col_pos = sy-tabix.
ls_fcat-key = space.
ls_fcat-emphasize = space.
MODIFY pt_fieldcat FROM ls_fcat .
ENDLOOP.
ENDFORM . "prepare_field_catalog
*&--------------------------------------------------------------------*
*& Form prepare_layout
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->PS_LAYOUT text
*---------------------------------------------------------------------*
FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
ps_layout-zebra = 'X' .
ps_layout-cwidth_opt ='X'.
ps_layout-numc_total = ' '.
ps_layout-no_merging = 'X'.
ps_layout-no_rowmark = 'X'.
ps_layout-sel_mode = 'A'.
ps_layout-no_toolbar = ' '.
ENDFORM. "prepare_layout
*&--------------------------------------------------------------------*
*& Form Change_buttons
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM change_buttons .
* Kein Symbol für Drucken / Graphik / Info
ls_exclude = cl_gui_alv_grid=>mc_fc_print_back.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_info.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_sum.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_view.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_detail.
APPEND ls_exclude TO lt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_find.
APPEND ls_exclude TO lt_exclude.
ENDFORM. "Change_buttons
*&---------------------------------------------------------------------*
*& Form handle_hotspot_click
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E_ROW_ID text
* -->E_COLUMN_ID text
* -->ES_ROW_NO text
*----------------------------------------------------------------------*
FORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
*E_ROW_ID Type LVC_S_ROW
*E_COLUMN_ID Type LVC_S_COL
*ES_ROW_NO Type LVC_S_ROID
DATA stable TYPE lvc_s_stbl .
CHECK e_column_id = 'CB'.
READ TABLE it_data INDEX e_row_id.
IF NOT it_data-cb IS INITIAL.
CLEAR it_data-cb.
ELSE.
it_data-cb = 'X'.
ENDIF.
MODIFY it_data INDEX e_row_id.
IF sy-subrc = 0.
stable-row = 'X'.
CALL METHOD grid1->refresh_table_display
EXPORTING
is_stable = stable
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDFORM. "handle_hotspot_click
Folgende Benutzer bedankten sich beim Autor Tron für den Beitrag:
Nadine_2706