Editable alv with checkbox
*&---------------------------------------------------------------------*
*& Include ZMAN_EDITABLE_ALV_DD
*&---------------------------------------------------------------------*
TYPE-POOLS : slis.
TABLES : zman_emp_table.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat LIKE LINE OF it_fieldcat.
DATA: t_list_top_of_page TYPE slis_t_listheader.
DATA: it_events TYPE slis_t_event WITH HEADER LINE.
DATA: g_save TYPE c VALUE 'A'.
DATA: gt_sort TYPE slis_t_sortinfo_alv.
DATA: gx_save TYPE c VALUE 'A'.
DATA: gx_variant TYPE disvariant.
DATA: g_variant TYPE disvariant.
DATA: gs_layout TYPE slis_layout_alv.
DATA: t_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
DATA: t_i_event TYPE slis_alv_event.
TYPES : BEGIN OF ty_zman_emp_table,
zman_emp_no TYPE zman_emp_no,
zman_emp_name TYPE zman_emp_name,
zman_emp_address TYPE zman_emp_address,
zman_emp_blood_grp TYPE zman_emp_blood_grp,
zman_emp_gender TYPE zman_emp_gender,
zman_emp_email TYPE zman_emp_email,
zman_emp_marital_status TYPE zman_emp_marital_status,
zman_emp_expirence TYPE zman_emp_expirence,
flag TYPE flag,
END OF ty_zman_emp_table.
DATA : it_ZMAN_EMP_TABLE TYPE STANDARD TABLE OF TY_zman_emp_table WITH HEADER LINE,
wa_zman_emp_table TYPE ty_zman_emp_table.
DATA: it_update TYPE TABLE OF ty_zman_emp_table,
it_change TYPE TABLE OF ty_zman_emp_table.
DATA: it_delete TYPE TABLE OF ty_zman_emp_table,
it_change1 TYPE TABLE OF ty_zman_emp_table.
DATA: defaultoption TYPE string, "header declaration
title TYPE string, "header title
textline TYPE string, "text line
lv_popup_ans TYPE string, "pop up
cancel_display TYPE string. "pop up
DATA: it_listheader TYPE slis_t_listheader.
*& Include ZMAN_EDITABLE_ALV_DD
*&---------------------------------------------------------------------*
TYPE-POOLS : slis.
TABLES : zman_emp_table.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat LIKE LINE OF it_fieldcat.
DATA: t_list_top_of_page TYPE slis_t_listheader.
DATA: it_events TYPE slis_t_event WITH HEADER LINE.
DATA: g_save TYPE c VALUE 'A'.
DATA: gt_sort TYPE slis_t_sortinfo_alv.
DATA: gx_save TYPE c VALUE 'A'.
DATA: gx_variant TYPE disvariant.
DATA: g_variant TYPE disvariant.
DATA: gs_layout TYPE slis_layout_alv.
DATA: t_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
DATA: t_i_event TYPE slis_alv_event.
TYPES : BEGIN OF ty_zman_emp_table,
zman_emp_no TYPE zman_emp_no,
zman_emp_name TYPE zman_emp_name,
zman_emp_address TYPE zman_emp_address,
zman_emp_blood_grp TYPE zman_emp_blood_grp,
zman_emp_gender TYPE zman_emp_gender,
zman_emp_email TYPE zman_emp_email,
zman_emp_marital_status TYPE zman_emp_marital_status,
zman_emp_expirence TYPE zman_emp_expirence,
flag TYPE flag,
END OF ty_zman_emp_table.
DATA : it_ZMAN_EMP_TABLE TYPE STANDARD TABLE OF TY_zman_emp_table WITH HEADER LINE,
wa_zman_emp_table TYPE ty_zman_emp_table.
DATA: it_update TYPE TABLE OF ty_zman_emp_table,
it_change TYPE TABLE OF ty_zman_emp_table.
DATA: it_delete TYPE TABLE OF ty_zman_emp_table,
it_change1 TYPE TABLE OF ty_zman_emp_table.
DATA: defaultoption TYPE string, "header declaration
title TYPE string, "header title
textline TYPE string, "text line
lv_popup_ans TYPE string, "pop up
cancel_display TYPE string. "pop up
DATA: it_listheader TYPE slis_t_listheader.
========================================================================
* Selection Screen
========================================================================
*&---------------------------------------------------------------------*
*& Include ZMAN_EDITABLE_ALV_SS
*&---------------------------------------------------------------------*
SELECT-OPTIONS: S_EMPID FOR IT_ZMAN_EMP_TABLE-ZMAN_EMP_NO.
*& Include ZMAN_EDITABLE_ALV_SS
*&---------------------------------------------------------------------*
SELECT-OPTIONS: S_EMPID FOR IT_ZMAN_EMP_TABLE-ZMAN_EMP_NO.
========================================================================
* LOGIC
========================================================================
*&---------------------------------------------------------------------*
*& Include ZMAN_EDITABLE_ALV_LOGIC
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form GET_DATA .
SELECT
ZMAN_EMP_NO
ZMAN_EMP_NAME
ZMAN_EMP_ADDRESS
ZMAN_EMP_BLOOD_GRP
ZMAN_EMP_GENDER
ZMAN_EMP_EMAIL
ZMAN_EMP_MARITAL_STATUS
ZMAN_EMP_EXPIRENCE
FROM zman_emp_table INTO CORRESPONDING FIELDS OF TABLE it_zman_emp_table
WHERE ZMAN_EMP_NO IN s_empid.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form ALV_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ALV_FIELDCAT .
DATA: counter TYPE i.
counter = counter + 1.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-fieldname ='FLAG'.
wa_fieldcat-seltext_m ='CHECKBOX'.
wa_fieldcat-edit ='X'.
wa_fieldcat-checkbox = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_NO '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Employee ID.'.
wa_fieldcat-col_pos = 0.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_NAME '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Employee NAME.'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_ADDRESS'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Address'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_BLOOD_GRP '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Blood Group'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_GENDER '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Gender'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_EMAIL'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Email'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_MARITAL_STATUS'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Marital Status'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_EXPIRENCE'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Expirence'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
endform. " ALV_FIELDCAT
*&---------------------------------------------------------------------*
*& Form GET_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form GET_EVENT .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS[]
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_events WITH KEY name = slis_ev_top_of_page
INTO it_events.
IF sy-subrc = 0.
MOVE t_formname_top_of_page TO it_events-form.
APPEND it_events.
ENDIF.
endform. " GET_EVENT
*&---------------------------------------------------------------------*
*& Form SUB_COMMENT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LIST_TOP_OF_PAGE text
*----------------------------------------------------------------------*
form SUB_COMMENT_BUILD using p_t_list_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
DATA: wrk_name TYPE string.
wrk_name = 'Squirrel Softech Pvt. Ltd.'.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = wrk_name.
APPEND ls_line TO t_list_top_of_page.
ls_line-typ = 'H'.
ls_line-info = 'Employee Detail'.
APPEND ls_line TO p_t_list_top_of_page.
endform. " SUB_COMMENT_BUILD
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form TOP_OF_PAGE .
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'SAPLOGO'
it_list_commentary = t_list_top_of_page.
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
endform. " TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ALV_DISPLAY .
gs_layout-zebra = 'X'.
gs_layout-detail_popup = 'X'.
gs_layout-detail_initial_lines = 'X'.
gs_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
it_events = it_events[]
i_callback_program = sy-repid
is_layout = gs_layout
it_sort = gt_sort[]
i_save = g_save
is_variant = gx_variant
i_callback_pf_status_set = 'ZSTANDARD1'
i_callback_user_command = 'USER_COMMAND' " Interactive command
TABLES
t_outtab = IT_zman_emp_table[].
ENDFORM. " ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM zstandard1 USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD1'.
ENDFORM. "text
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_comm TYPE sy-ucomm
selfield TYPE slis_selfield.
DATA: gd_repid LIKE sy-repid,
ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
DATA : flag TYPE i VALUE 0.
CASE r_comm.
WHEN 'SELECT_ALL'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table.
IF wa_zman_emp_table-flag IS INITIAL.
wa_zman_emp_table-flag = 'X'.
MODIFY it_zman_emp_table FROM wa_zman_emp_table.
CLEAR wa_zman_emp_table.
ENDIF.
ENDLOOP.
selfield-refresh = 'X'.
WHEN 'DSELECT_AL'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table.
IF wa_zman_emp_table-flag IS NOT INITIAL.
wa_zman_emp_table-flag = ''.
MODIFY it_zman_emp_table FROM wa_zman_emp_table.
CLEAR wa_zman_emp_table.
ENDIF.
ENDLOOP.
selfield-refresh = 'X'.
WHEN 'UPDATE'.
READ TABLE it_zman_emp_table into wa_zman_emp_table with key FLAG = 'X'.
if sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar ='MESSAGE'
text_question ='ARE YOU SURE YOU WANT TO UPDATE THIS DATA'
text_button_1 ='YES'
text_button_2 ='NO'
default_button = '1'
display_cancel_button = 'X'
popup_type = 'ICON MESSAGE INFORMATION'
IMPORTING
answer = lv_popup_ans.
IF sy-subrc <> 0.
ENDIF.
IF lv_popup_ans = '1'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table WHERE flag = 'X'.
PERFORM zman_emp_table_updatedata. " update data
IF sy-subrc EQ 0.
message 'DATA UPDATED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDLOOP.
ELSE.
LEAVE SCREEN.
ENDIF.
else.
MESSAGE 'please select atleast one line item' type 'E'.
endif.
WHEN 'DELETE'.
READ TABLE it_zman_emp_table into wa_zman_emp_table with key flag = 'X'.
if sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar ='MESSAGE'
text_question ='ARE YOU SURE YOU WANT TO DELETE DATA'
text_button_1 ='YES'
text_button_2 ='NO'
default_button = '1'
display_cancel_button = 'X'
popup_type = 'ICON MESSAGE INFORMATION'
IMPORTING
answer = lv_popup_ans.
IF sy-subrc <> 0.
ENDIF.
IF lv_popup_ans = '1'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table WHERE flag = 'X'.
PERFORM zman_emp_table_DATADELETE. " DATA DELETE
select ZMAN_EMP_NO
ZMAN_EMP_NAME
ZMAN_EMP_ADDRESS
ZMAN_EMP_BLOOD_GRP
ZMAN_EMP_GENDER
ZMAN_EMP_EMAIL
ZMAN_EMP_MARITAL_STATUS
ZMAN_EMP_EXPIRENCE
from zman_emp_table
INTO CORRESPONDING FIELDS OF TABLE it_zman_emp_table.
modify it_zman_emp_table FROM wa_zman_emp_table.
selfield-refresh = 'X'.
IF sy-subrc EQ 0.
message 'DATA DELETED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDLOOP.
ELSE.
LEAVE SCREEN.
ENDIF.
else.
MESSAGE 'please select atleast one line item' type 'E'.
endif.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form ZMAN_EMP_TABLE_UPDATEDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ZMAN_EMP_TABLE_UPDATEDATA .
data: wa_tzman_emp_table type zman_emp_table.
REFRESH it_change.
IF it_zman_emp_table[] IS NOT INITIAL.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table WHERE flag = 'X'.
MOVE-CORRESPONDING wa_zman_emp_table TO wa_tzman_emp_table.
MODIFY zman_emp_table FROM wa_tzman_emp_table.
ENDLOOP.
ENDIF.
endform.
*&---------------------------------------------------------------------*
*& Form ZMAN_EMP_TABLE_DATADELETE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ZMAN_EMP_TABLE_DATADELETE .
data: wa_delete type ty_zman_emp_table,
wa_tzman_emp_table type zman_emp_table.
refresh it_change1.
if it_zman_emp_table[] is not INITIAL.
loop at it_zman_emp_table into wa_zman_emp_table where flag = 'X'.
MOVE-CORRESPONDING wa_zman_emp_table TO wa_tzman_emp_table.
delete from zman_emp_table where ZMAN_EMP_NO = wa_zman_emp_table-ZMAN_EMP_NO.
endloop.
clear wa_delete.
endif.
endform. " ZMAN_EMP_TABLE_DATADELETE " ZMAN_EMP_TABLE_UPDATEDATA
*& Include ZMAN_EDITABLE_ALV_LOGIC
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form GET_DATA .
SELECT
ZMAN_EMP_NO
ZMAN_EMP_NAME
ZMAN_EMP_ADDRESS
ZMAN_EMP_BLOOD_GRP
ZMAN_EMP_GENDER
ZMAN_EMP_EMAIL
ZMAN_EMP_MARITAL_STATUS
ZMAN_EMP_EXPIRENCE
FROM zman_emp_table INTO CORRESPONDING FIELDS OF TABLE it_zman_emp_table
WHERE ZMAN_EMP_NO IN s_empid.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form ALV_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ALV_FIELDCAT .
DATA: counter TYPE i.
counter = counter + 1.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-fieldname ='FLAG'.
wa_fieldcat-seltext_m ='CHECKBOX'.
wa_fieldcat-edit ='X'.
wa_fieldcat-checkbox = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_NO '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Employee ID.'.
wa_fieldcat-col_pos = 0.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_NAME '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Employee NAME.'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_ADDRESS'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Address'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_BLOOD_GRP '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Blood Group'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_GENDER '.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Gender'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_EMAIL'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Email'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_MARITAL_STATUS'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Marital Status'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZMAN_EMP_EXPIRENCE'.
wa_fieldcat-tabname = 'IT_zman_emp_table'.
wa_fieldcat-seltext_l = 'Expirence'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-edit = 'X'. "its for edditing field.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
endform. " ALV_FIELDCAT
*&---------------------------------------------------------------------*
*& Form GET_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form GET_EVENT .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS[]
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_events WITH KEY name = slis_ev_top_of_page
INTO it_events.
IF sy-subrc = 0.
MOVE t_formname_top_of_page TO it_events-form.
APPEND it_events.
ENDIF.
endform. " GET_EVENT
*&---------------------------------------------------------------------*
*& Form SUB_COMMENT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LIST_TOP_OF_PAGE text
*----------------------------------------------------------------------*
form SUB_COMMENT_BUILD using p_t_list_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
DATA: wrk_name TYPE string.
wrk_name = 'Squirrel Softech Pvt. Ltd.'.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = wrk_name.
APPEND ls_line TO t_list_top_of_page.
ls_line-typ = 'H'.
ls_line-info = 'Employee Detail'.
APPEND ls_line TO p_t_list_top_of_page.
endform. " SUB_COMMENT_BUILD
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form TOP_OF_PAGE .
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'SAPLOGO'
it_list_commentary = t_list_top_of_page.
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
endform. " TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ALV_DISPLAY .
gs_layout-zebra = 'X'.
gs_layout-detail_popup = 'X'.
gs_layout-detail_initial_lines = 'X'.
gs_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
it_events = it_events[]
i_callback_program = sy-repid
is_layout = gs_layout
it_sort = gt_sort[]
i_save = g_save
is_variant = gx_variant
i_callback_pf_status_set = 'ZSTANDARD1'
i_callback_user_command = 'USER_COMMAND' " Interactive command
TABLES
t_outtab = IT_zman_emp_table[].
ENDFORM. " ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM zstandard1 USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD1'.
ENDFORM. "text
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_comm TYPE sy-ucomm
selfield TYPE slis_selfield.
DATA: gd_repid LIKE sy-repid,
ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
DATA : flag TYPE i VALUE 0.
CASE r_comm.
WHEN 'SELECT_ALL'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table.
IF wa_zman_emp_table-flag IS INITIAL.
wa_zman_emp_table-flag = 'X'.
MODIFY it_zman_emp_table FROM wa_zman_emp_table.
CLEAR wa_zman_emp_table.
ENDIF.
ENDLOOP.
selfield-refresh = 'X'.
WHEN 'DSELECT_AL'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table.
IF wa_zman_emp_table-flag IS NOT INITIAL.
wa_zman_emp_table-flag = ''.
MODIFY it_zman_emp_table FROM wa_zman_emp_table.
CLEAR wa_zman_emp_table.
ENDIF.
ENDLOOP.
selfield-refresh = 'X'.
WHEN 'UPDATE'.
READ TABLE it_zman_emp_table into wa_zman_emp_table with key FLAG = 'X'.
if sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar ='MESSAGE'
text_question ='ARE YOU SURE YOU WANT TO UPDATE THIS DATA'
text_button_1 ='YES'
text_button_2 ='NO'
default_button = '1'
display_cancel_button = 'X'
popup_type = 'ICON MESSAGE INFORMATION'
IMPORTING
answer = lv_popup_ans.
IF sy-subrc <> 0.
ENDIF.
IF lv_popup_ans = '1'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table WHERE flag = 'X'.
PERFORM zman_emp_table_updatedata. " update data
IF sy-subrc EQ 0.
message 'DATA UPDATED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDLOOP.
ELSE.
LEAVE SCREEN.
ENDIF.
else.
MESSAGE 'please select atleast one line item' type 'E'.
endif.
WHEN 'DELETE'.
READ TABLE it_zman_emp_table into wa_zman_emp_table with key flag = 'X'.
if sy-subrc = 0.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar ='MESSAGE'
text_question ='ARE YOU SURE YOU WANT TO DELETE DATA'
text_button_1 ='YES'
text_button_2 ='NO'
default_button = '1'
display_cancel_button = 'X'
popup_type = 'ICON MESSAGE INFORMATION'
IMPORTING
answer = lv_popup_ans.
IF sy-subrc <> 0.
ENDIF.
IF lv_popup_ans = '1'.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table WHERE flag = 'X'.
PERFORM zman_emp_table_DATADELETE. " DATA DELETE
select ZMAN_EMP_NO
ZMAN_EMP_NAME
ZMAN_EMP_ADDRESS
ZMAN_EMP_BLOOD_GRP
ZMAN_EMP_GENDER
ZMAN_EMP_EMAIL
ZMAN_EMP_MARITAL_STATUS
ZMAN_EMP_EXPIRENCE
from zman_emp_table
INTO CORRESPONDING FIELDS OF TABLE it_zman_emp_table.
modify it_zman_emp_table FROM wa_zman_emp_table.
selfield-refresh = 'X'.
IF sy-subrc EQ 0.
message 'DATA DELETED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDLOOP.
ELSE.
LEAVE SCREEN.
ENDIF.
else.
MESSAGE 'please select atleast one line item' type 'E'.
endif.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form ZMAN_EMP_TABLE_UPDATEDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ZMAN_EMP_TABLE_UPDATEDATA .
data: wa_tzman_emp_table type zman_emp_table.
REFRESH it_change.
IF it_zman_emp_table[] IS NOT INITIAL.
LOOP AT it_zman_emp_table INTO wa_zman_emp_table WHERE flag = 'X'.
MOVE-CORRESPONDING wa_zman_emp_table TO wa_tzman_emp_table.
MODIFY zman_emp_table FROM wa_tzman_emp_table.
ENDLOOP.
ENDIF.
endform.
*&---------------------------------------------------------------------*
*& Form ZMAN_EMP_TABLE_DATADELETE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ZMAN_EMP_TABLE_DATADELETE .
data: wa_delete type ty_zman_emp_table,
wa_tzman_emp_table type zman_emp_table.
refresh it_change1.
if it_zman_emp_table[] is not INITIAL.
loop at it_zman_emp_table into wa_zman_emp_table where flag = 'X'.
MOVE-CORRESPONDING wa_zman_emp_table TO wa_tzman_emp_table.
delete from zman_emp_table where ZMAN_EMP_NO = wa_zman_emp_table-ZMAN_EMP_NO.
endloop.
clear wa_delete.
endif.
endform. " ZMAN_EMP_TABLE_DATADELETE " ZMAN_EMP_TABLE_UPDATEDATA