Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

delete option in alv grid

Former Member
0 Kudos

Hi all

my requirement in this program is that when i select multiple checkboxes in the output and press delete butoon in the toolbar then it shuld delete the records from ouput as well as delete records from the database table.

so when i can run the ouput again then the deleted records shuld not come in the output again.

below i am giving my code, if anyone can help me in getting my problem solved.

<code>

&----


*& Report Z_50804_TRANS_SUBMIT

*&

&----


*&

*&

&----


REPORT Z_demo.

TABLES : ZDATA_12.

DATA :OK_CODE LIKE SY-UCOMM,

save_ok like sy-ucomm,

G_CONTAINER TYPE SCRFNAME VALUE 'GRID_CON',

IT_GRID1 TYPE REF TO CL_GUI_ALV_GRID,

IT_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

it_fieldcat type lvc_t_fcat,

wa_fieldcat like line of it_fieldcat,

gs_layout type lvc_s_layo.

  • delete_button type ref to cl_gui_toolbar.

types : begin of ty_EMPO ,

checkbox type c,

EMP type zdata_12-EMP,

SUBJECT type zdata_12-SUBJECT,

DATE1 type zdata_12-DATE1,

  • include structure zdata_12.

end of ty_empo.

data : it_empo type standard table of ty_empo,

wa_empo type ty_empo.

          • Handling delete button in the toolbar.

DATA: ds_disposal_toolbar TYPE stb_button,

dt_disposal_toolbar TYPE ttb_button.

select-options : s_emp for zdata_12-emp.

class vend_details definition.

public section.

methods : get_data,

handle_hotspot_click for event hotspot_click of cl_gui_alv_grid importing e_row_id,

display_data,

handle_toolbar for event toolbar of cl_gui_alv_grid importing e_object e_interactive,

handle_user_command for event user_command of cl_gui_alv_grid importing e_ucomm.

endclass.

  • IMPLEMENTATION OF THE CLASS vend_details

class vend_details implementation.

method get_data.

SELECT EMP

SUBJECT

DATE1

FROM zdata_12

INTO CORRESPONDING FIELDS OF TABLE IT_EMPO

where emp in s_emp.

endmethod.

method handle_hotspot_click.

if not e_row_id is initial.

read table it_empo into wa_empo index e_row_id-index.

if sy-subrc = 0.

set parameter id 'PER' field wa_empo.

call transaction 'Z_CHANGE_COMENT' and skip first screen.

endif.

endif.

endmethod.

method display_data.

if not IT_EMPO is initial.

perform build_fldcat.

call screen 300.

endif.

endmethod.

method handle_toolbar.

  • wa_button type stb_button.

*

  • IF NOT DT_TOOLBAR[] IS INITIAL.

  • MOVE DT_TOOLBAR TO E_OBJECT->MT_TOOLBAR.

  • ENDIF.

*

**-ADD SPACE BETWEEN BUTTONS

  • clear wa_button.

  • move '&&SEP00' to wa_button-function.

  • move 3 to wa_button-butn_type.

  • append wa_button to e_object->mt_toolbar.

  • CLEAR DT_TOOLBAR.

  • MOVE E_OBJECT->MT_TOOLBAR TO DT_TOOLBAR.

  • clear wa_button.

*

**-add Delete Button on the toolbar

  • move 'DELE' to wa_button-function.

  • move icon_delete to wa_button-icon.

  • move 3 to wa_button-butn_type.

  • move ' ' to wa_button-disabled.

  • move 'DELETE'(001) to WA_BUTTON-TEXT.

  • append wa_button to e_object->mt_toolbar.

  • MOVE E_OBJECT->MT_TOOLBAR TO DT_TOOLBAR.

DATA: ds_toolbar TYPE stb_button.

IF NOT dt_disposal_toolbar[] IS INITIAL.

CLEAR: e_object->mt_toolbar[].

MOVE dt_disposal_toolbar TO e_object->mt_toolbar.

ENDIF.

READ TABLE e_object->mt_toolbar INTO ds_toolbar

WITH KEY function = 'DELETE'.

IF sy-subrc <> 0.

  • Add separator

CLEAR ds_toolbar.

MOVE '&&SEP00' TO ds_toolbar-function.

move '3' to ds_toolbar-butn_type.

APPEND ds_toolbar TO e_object->mt_toolbar.

CLEAR: dt_disposal_toolbar[].

MOVE e_object->mt_toolbar TO dt_disposal_toolbar.

*Add DELETE button

CLEAR ds_toolbar.

MOVE 'DELETE' TO ds_toolbar-function.

MOVE 'Delete' TO ds_toolbar-text.

MOVE 'Delete' TO ds_toolbar-quickinfo.

MOVE ' ' TO ds_toolbar-disabled.

MOVE icon_delete TO ds_toolbar-icon.

APPEND ds_toolbar TO e_object->mt_toolbar.

ENDIF.

CLEAR: dt_disposal_toolbar[].

MOVE e_object->mt_toolbar TO dt_disposal_toolbar.

endmethod.

method handle_user_command.

case e_ucomm.

when 'DELETE'.

PERFORM DELETE_FROM_TABLE.

endcase.

endmethod.

endclass.

start-of-selection.

data : obj_empo type ref to vend_details.

create object obj_empo.

call method obj_empo->get_data.

call method obj_empo->display_data.

  • call screen 300.

&----


*& Module STATUS_0300 OUTPUT

&----


  • text

----


module STATUS_0300 output.

SET PF-STATUS 'EMP'.

  • SET TITLEBAR 'xxx'.

IF IT_CONTAINER IS INITIAL.

create object it_container

exporting

  • PARENT =

container_name = G_CONTAINER

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTL_SYSTEM_ERROR = 2

  • CREATE_ERROR = 3

  • LIFETIME_ERROR = 4

  • LIFETIME_DYNPRO_DYNPRO_LINK = 5

  • others = 6

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

create object it_grid1

exporting

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

i_parent = IT_CONTAINER

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • I_NAME =

  • I_FCAT_COMPLETE = SPACE

  • EXCEPTIONS

  • ERROR_CNTL_CREATE = 1

  • ERROR_CNTL_INIT = 2

  • ERROR_CNTL_LINK = 3

  • ERROR_DP_CREATE = 4

  • others = 5

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

set handler obj_empo->handle_hotspot_click for it_grid1.

set handler obj_empo->handle_toolbar for it_grid1.

call method it_grid1->set_table_for_first_display

  • EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME = 'ZDATA_12'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

changing

it_outtab = IT_EMPO

IT_FIELDCATALOG = it_fieldcat

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

others = 4

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

ENDIF.

*call method it_grid1->set_toolbar_interactive.

*

*call method cl_gui_control=>set_focus

  • exporting

  • control = it_grid1

    • EXCEPTIONS

    • CNTL_ERROR = 1

    • CNTL_SYSTEM_ERROR = 2

    • others = 3

  • .

*if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*endif.

endmodule. " STATUS_0300 OUTPUT

&----


*& Module USER_COMMAND_0300 INPUT

&----


  • text

----


module USER_COMMAND_0300 input.

save_ok = sy-ucomm.

case save_ok.

when 'EXIT'.

perform exit_program.

when 'BACK' or 'CANCEL'.

leave to screen 0.

endcase.

clear ok_code.

endmodule. " USER_COMMAND_0300 INPUT

&----


*& Form exit_program

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form exit_program .

leave program.

endform. " exit_program

&----


*& Form build_fldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fldcat .

clear wa_fieldcat.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'CHECKBOX'.

wa_fieldcat-checkbox = 'X'.

wa_fieldcat-EDIT = 'X'.

wa_fieldcat-tabNAME = 'IT_EMPO'.

append wa_fieldcat to It_fieldcat.

clear wa_fieldcat.

wa_fieldcat-col_pos = 2.

wa_fieldcat-fieldname = 'EMP'.

wa_fieldcat-tabNAME = 'IT_EMPO'.

wa_fieldcat-coltext = 'EMP'.

wa_fieldcat-seltext = 'EMP'.

wa_fieldcat-hotspot = 'X'.

wa_fieldcat-outputlen = 8.

append wa_fieldcat to It_fieldcat.

clear wa_fieldcat.

wa_fieldcat-col_pos = 3.

wa_fieldcat-fieldname = 'SUBJECT'.

wa_fieldcat-tabNAME = 'IT_EMPO'.

wa_fieldcat-coltext = 'SUBJECT'.

wa_fieldcat-seltext = 'SUBJECT'.

wa_fieldcat-hotspot = 'X'.

wa_fieldcat-outputlen = 20.

append wa_fieldcat to It_fieldcat.

clear wa_fieldcat.

wa_fieldcat-col_pos = 4.

wa_fieldcat-fieldname = 'DATE1'.

wa_fieldcat-tabNAME = 'IT_EMPO'.

wa_fieldcat-coltext = 'DATE'.

wa_fieldcat-seltext = 'DATE'.

wa_fieldcat-outputlen = 12.

append wa_fieldcat to It_fieldcat.

endform. " build_fldcat

&----


*& Form DELETE_FROM_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form DELETE_FROM_TABLE .

if wa_empo-checkbox is not initial.

delete zdata_12 from wa_empo .

endif.

endform. " DELETE_FROM_TABLE

</code>

Thanks,

satya

6 REPLIES 6

hymavathi_oruganti
Active Contributor
0 Kudos

check the folloaing code which is similar to ur requirement. hope it solves.

REPORT ZWWREV_DELETE_FILE_EXT_TRIG.

TABLES : zwwrev_fileloc,

zwwrev_filecbn,

zwwrev_rm_trig.

*data: DELETE.

CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.

selection-screen begin of block b1 with frame title text-001.

selection-screen begin of line.

selection-screen position 1.

PARAMETERS : P_FLOC radiobutton group RG2 user-command ucomm default

'X'

.

selection-screen comment 3(23) text-002.

selection-screen position 29.

PARAMETERS : P_Fcbn radiobutton group RG2.

selection-screen comment 31(23) text-003.

selection-screen position 56 .

PARAMETERS : P_RMTRIG radiobutton group RG2.

selection-screen comment 60(23) text-004.

selection-screen end of line .

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text-001.

SELECT-OPTIONS: S_CRSID FOR zwwrev_fileloc-crsid modif id m1,

s_CREdt1 for zwwrev_fileloc-CREATED_ON modif id m1,

s_CREti1 for zwwrev_fileloc-CREATED_AT modif id m1,

s_CHGdt1 for zwwrev_fileloc-CHANGED_ON modif id m1,

s_CHGti1 for zwwrev_fileloc-CHANGED_AT modif id m1,

*Begin of Mod-V002

p_actvt1 FOR zwwrev_fileloc-actvt modif id m1,

p_ent1 FOR zwwrev_fileloc-entity modif id m1,

*Begin of Mod-V003

p_F_STA1 for ZWWREV_FILEloc-FILE_STATUS modif id m1,

p_HPS_E1 for zwwrev_fileloc-HPS_EXT modif id m1.

*End of Mod-V003

*End of Mod-V002

*Begin of Mod-V001

*Begin of Insertion-Mod-V001

*Begin of Mod-V003

*PARAMETERS:

*End of Mod-V003

*Begin of Mod-V002

  • p_actvt1 FOR zwwrev_fileloc-actvt modif id m1,

  • p_ent1 FOR zwwrev_fileloc-entity modif id m1.

*End of Mod-V002

*Begin of Mod-V003

  • p_F_STA1(1) modif id m1,

  • p_HPS_E1 LIKE zwwrev_fileloc-HPS_EXT modif id m1.

*End of Mod-V003

*End of Insertion-Mod-V001

SELECT-OPTIONS: s_CBN_NO for ZWWREV_FILECBN-CBN_NO modif id m2,

s_CREdt2 for ZWWREV_FILECBN-CREATED_ON modif id m2,

s_CREti2 for ZWWREV_FILECBN-CREATED_AT modif id m2,

s_CHGdt2 for ZWWREV_FILECBN-CHANGED_ON modif id m2,

s_CHGti2 for ZWWREV_FILECBN-CHANGED_AT modif id m2,

*Begin of Mod-V002

p_ACTVT2 for ZWWREV_FILECBN-ACTVT modif id m2,

p_ent2 For ZWWREV_FILECBN-entity modif id m2,

*Begin of Mod-V003

p_CBNST for ZWWREV_FILECBN-CBN_STATUS modif id m2,

p_F_STA2 for ZWWREV_FILECBN-FILE_STATUS modif id m2,

p_HPS_E2 for ZWWREV_FILECBN-HPS_EXT modif id m2.

*End of Mod-V003

*End of Mod-V002

*PARAMETERS: p_CBNST like ZWWREV_FILECBN-CBN_STATUS modif id m2.

*Begin of Mod-V002

  • p_ent2 LIKE ZWWREV_FILECBN-entity modif id m2,

*End of Mod-V002

*Begin of Mod-V001

*Begin of Insertion-Mod-V001

*Begin of Mod-V002

  • p_ACTVT2 like ZWWREV_FILECBN-ACTVT modif id m2,

  • p_F_STA2 like ZWWREV_FILECBN-FILE_STATUS modif id m2,

  • p_F_STA2(1) modif id m2,

*End of Mod-V002

*Begin of Mod-V003

  • p_HPS_E2 like ZWWREV_FILECBN-HPS_EXT modif id m2.

*End of Mod-V003

*End of Insertion-Mod-V001

SELECT-OPTIONS: S_CRSID2 FOR ZWWREV_RM_TRIG-crsid modif id m3,

s_CREdt3 for ZWWREV_RM_TRIG-CREATED_ON modif id m3,

s_CREti3 for ZWWREV_RM_TRIG-CREATED_AT modif id m3,

s_CHGdt3 for ZWWREV_RM_TRIG-CHANGED_ON modif id m3,

s_CHGti3 for ZWWREV_RM_TRIG-CHANGED_AT modif id m3,

p_ACTVT3 for ZWWREV_FILECBN-ACTVT modif id m3,

*Begin of Mod-V003

p_ORUNIT for ZWWREV_RM_TRIG-ORGUNIT modif id m3,

p_LAND1 for ZWWREV_RM_TRIG-LAND1 modif id m3,

p_RM_SUC for ZWWREV_RM_TRIG-RM_SUCCESS modif id m3.

*PARAMETERS:

*End of Mod-V003

*Begin of Mod-V002

  • p_ACTVT3 like ZWWREV_RM_TRIG-ACTVT modif id m3,

*End of Mod-V002

  • p_ORUNIT like ZWWREV_RM_TRIG-ORGUNIT modif id m3,

  • p_LAND1 like ZWWREV_RM_TRIG-LAND1 modif id m3.

*Begin of Mod-V001

*Begin of Insertion-Mod-V001

*Begin of Mod-V002

  • p_RM_SUC like ZWWREV_RM_TRIG-RM_SUCCESS modif id m3,

*End of Mod-V002

*Begin of Mod-V003

  • p_RM_SUC(1) modif id m3.

  • p_REC_T like ZWWREV_RM_TRIG-RECORD_TYPE modif id m3.

*End of Mod-V003

*End of Insertion-Mod-V001

selection-screen end of block b2.

*****Class variables*********

DATA:EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.

DATA:

GO_GRID type ref to cl_gui_alv_grid,

go_custom_container type ref to cl_gui_custom_container.

*****LVC fieldcatalog declaration*************

DATA: lt_lvcfieldcat type lvc_t_fcat,

ls_lvcfieldcat type lvc_s_fcat,

LS_PRINT TYPE LVC_S_PRNT,

SEL_ROW TYPE LVC_S_ROID,

SEL_T_ROW TYPE LVC_T_ROID,

LS_LVCLAYOUT TYPE LVC_S_LAYO,

SEL_CELL TYPE LVC_S_CENO,

SEL_T_CELL TYPE LVC_T_CENO,

lvc_sort type lvc_s_sort,

lvc_tsort type lvc_t_sort,

it_exclude type ui_functions,

is_exclude type ui_func,

ls_toolbar TYPE stb_button.

*********internal table decharation

*DATA: t_FLOC1 LIKE zwwrev_fileloc." OCCURS 0 WITH HEADER LINE.

types: begin of typ_floc.

INCLUDE structure zwwrev_fileloc.

types: end of typ_floc.

data: t_floc type table of typ_floc,

t_floc1 type table of typ_floc,

w_floc like line of t_floc,

w_floc1 like line of t_floc.

types: begin of typ_fcbn.

INCLUDE structure ZWWREV_FILECBN.

types: end of typ_fcbn.

data: t_fcbn type table of typ_fcbn,

t_fcbn1 type table of typ_fcbn,

w_fcbn like line of t_fcbn,

w_fcbn1 like line of t_fcbn1.

types: begin of typ_ftrig.

INCLUDE structure zwwrev_rm_trig.

types: end of typ_ftrig.

data: t_ftrig type table of typ_ftrig,

t_ftrig1 type table of typ_ftrig,

w_ftrig like line of t_ftrig,

w_ftrig1 like line of t_ftrig.

data: g_exit(1) TYPE c.

----


  • 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,

handle_user_command

for event USER_COMMAND of cl_gui_alv_grid importing e_ucomm.

ENDCLASS. "cl_event_receiver DEFINITION

----


  • CLASS LCL_EVENT_RECEIVER IMPLEMENTATION

----


*

----


CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.

METHOD HANDLE_TOOLBAR.

PERFORM HANDLE_TOOL_BAR USING E_OBJECT.

ENDMETHOD. "HANDLE_TOOLBAR

METHOD handle_user_command .

PERFORM HANDLE_USER_COMMAND USING E_UCOMM.

ENDMETHOD. "handle_user_command

ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION

at selection-screen output.

loop at screen.

if screen-group1 = 'M1'.

if P_FLOC = 'X'.

screen-active = 1.

else.

screen-active = 0.

endif.

endif.

if screen-group1 = 'M2'.

if P_Fcbn = 'X'.

screen-active = 1.

else.

screen-active = 0.

endif.

endif.

if screen-group1 = 'M3'.

if P_RMTRIG = 'X'.

screen-active = 1.

else.

screen-active = 0.

endif.

endif.

modify screen.

endloop.

at selection-screen .

*****************************************************************

*Begin of Mod-V001

*Begin of Insertion-Mod-V001

*Begin of Mod-V003

if sy-ucomm eq 'ONLI' and P_FLOC eq 'X'.

IF S_CRSID IS INITIAL and s_CREdt1 IS INITIAL AND s_Chgdt1 IS

INITIAL.

MESSAGE 'Enter CRS# or Cr.Date or CH.Date' type 'I'.

stop.

else.

*End of Mod-V003

  • if S_CRSID is initial.

  • message 'Please, enter value(s) for CRSID' type 'E'.

  • leave to screen 0.

  • else.

if s_CREdt1 is initial and s_CREti1 is not initial.

message 'Please, enter Creation Time along with Creation Date' type 'E'.

leave to screen 0.

endif.

if s_Chgdt1 is initial and s_Chgti1 is not initial.

message 'Please, enter Changed Time along with Changed Date' type 'E'.

leave to screen 0.

endif.

endif.

endif.

if sy-ucomm eq 'ONLI' and P_Fcbn eq 'X'.

*Begin of Mod-V003

IF S_cbn_no IS INITIAL and s_CREdt2 IS INITIAL AND s_Chgdt2 IS

INITIAL.

MESSAGE 'Enter CBN# or Cr.Date or CH.Date' type 'I'.

stop.

else.

*End of Mod-V003

  • message 'Please, enter value(s) for CBN_NO' type 'E'.

  • leave to screen 0.

  • else.

if s_CREdt2 is initial and s_CREti2 is not initial.

message 'Please, enter Creation Time along with Creation Date' type 'E'.

leave to screen 0.

endif.

if s_Chgdt2 is initial and s_Chgti2 is not initial.

message 'Please, enter Changed Time along with Changed Date' type 'E'.

leave to screen 0.

endif.

endif.

endif.

if sy-ucomm eq 'ONLI' and P_RMTRIG eq 'X'.

*Begin of Mod-V003

IF S_CRSID2 IS INITIAL and s_CREdt3 IS INITIAL AND s_Chgdt3 IS

INITIAL.

MESSAGE 'Enter CRS# or Cr.Date or CH.Date' type 'I'.

stop.

else.

*End of Mod-V003

  • if S_CRSID2 is initial.

  • message 'Please, enter value(s) for CRSID' type 'E'.

  • leave to screen 0.

  • else.

if s_CREdt3 is initial and s_CREti3 is not initial.

message 'Please, enter Creation Time along with Creation Date' type 'E'.

leave to screen 0.

endif.

if s_Chgdt3 is initial and s_Chgti3 is not initial.

message 'Please, enter Changed Time along with Changed Date' type 'E'.

leave to screen 0.

endif.

endif.

endif.

*End of Insertion-Mod-V001

START-OF-SELECTION.

PERFORM SELECT_DATA.

if P_FLOC = 'X'.

perform filed_cat using : 'CRSID' 'CRSID',

'ACTVT' 'ACTVT',

'ENTITY' 'ENTITY',

'CREATED_ON' 'CREATED_ON',

'CREATED_AT' 'CREATED_AT',

'CHANGED_ON' 'CHANGED_ON',

'CHANGED_AT' 'CHANGED_AT',

'FILE_STATUS' 'FILE_STATUS',

'HPS_EXT' 'HPS_EXT'.

else.

if P_Fcbn = 'X'.

perform filed_cat using : 'CBN_NO' 'CBN_NO',

'ACTVT' 'ACTVT',

'CBN_STATUS' 'CBN_STATUS',

'ENTITY' 'ENTITY',

'CREATED_ON' 'CREATED_ON',

'CREATED_AT' 'CREATED_AT',

'CHANGED_ON' 'CHANGED_ON',

'CHANGED_AT' 'CHANGED_AT',

'FILE_STATUS' 'FILE_STATUS',

'HPS_EXT' 'HPS_EXT'.

else.

if P_RMTRIG = 'X'.

perform filed_cat using : 'CRSID' 'CRSID',

'ACTVT' 'ACTVT',

'ENTITY' 'ENTITY',

'ORGUNIT' 'ORGUNIT',

'LAND1' 'LAND1',

'CREATED_ON' 'CREATED_ON',

'CREATED_AT' 'CREATED_AT',

'CHANGED_ON' 'CHANGED_ON',

'CHANGED_AT' 'CHANGED_AT',

'RM_SUCCESS' 'RM_SUCCESS',

'RECORD_TYPE' 'RECORD_TYPE'.

endif.

endif.

endif.

perform build_layout.

perform exclude.

CALL SCREEN 100.

&----


*& Form alv_disp

&----


  • text

----


  • -->P_T_FLOC text

----


FORM alv_disp.

if P_FLOC = 'X'.

CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = LS_LVCLAYOUT

IT_TOOLBAR_EXCLUDING = IT_EXCLUDE

CHANGING

IT_OUTTAB = t_floc[]

IT_FIELDCATALOG = lt_lvcfieldcat.

else.

if P_Fcbn = 'X'.

CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = LS_LVCLAYOUT

IT_TOOLBAR_EXCLUDING = IT_EXCLUDE

CHANGING

IT_OUTTAB = t_fcbn[]

IT_FIELDCATALOG = lt_lvcfieldcat.

else.

if P_rmtrig = 'X'.

CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = LS_LVCLAYOUT

IT_TOOLBAR_EXCLUDING = IT_EXCLUDE

CHANGING

IT_OUTTAB = T_Ftrig[]

IT_FIELDCATALOG = lt_lvcfieldcat.

endif.

endif.

endif.

ENDFORM. " alv_disp

&----


*& Form filed_cat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM filed_cat using p_field p_seltext.

LS_LVCFIELDCAT-FIELDNAME = P_FIELD.

LS_LVCFIELDCAT-SELTEXT = P_SELTEXT.

LS_LVCFIELDCAT-COLTEXT = P_SELTEXT.

LS_LVCFIELDCAT-outputlen = 10.

APPEND LS_LVCFIELDCAT TO LT_LVCFIELDCAT.

CLEAR ls_lvcfieldcat.

ENDFORM. " filed_cat

&----


*& Form build_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_layout .

LS_LVCLAYOUT-SEL_MODE = 'D'.

ENDFORM. " build_layout

&----


*& Form SELECT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM SELECT_DATA .

if P_FLOC = 'X'.

SELECT * FROM zwwrev_fileloc

INTO corresponding fields of TABLE t_floc

WHERE CRSID IN S_CRSID and

ACTVT IN p_ACTVT1 and

ENTITY IN P_ENT1 and

*Begin of Insertion-Mod-V001

CREATED_ON in s_CREdt1 and

CREATED_AT in s_CREti1 and

CHANGED_ON in s_Chgdt1 and

CHANGED_AT in s_Chgti1 and

*Begin of Mod-V003

FILE_STATUS in p_F_STA1 and

HPS_EXT in p_HPS_E1.

  • FILE_STATUS eq p_F_STA1 and

  • HPS_EXT eq p_HPS_E1.

*End of Mod-V003

*End of Insertion-Mod-V001

else.

if P_Fcbn = 'X'.

SELECT * FROM zwwrev_filecbn

INTO corresponding fields of TABLE t_fcbn

WHERE CBN_NO IN s_CBN_NO and

*Begin of Mod-V003

CBN_STATUS in p_CBNST AND

*

  • CBN_STATUS eq p_CBNST AND

*End of Mod-V003

  • ACTVT in p_ACTVT2 AND

*Begin of Insertion-Mod-V001

ENTITY in P_ENT2 and

CREATED_ON in s_CREdt2 and

CREATED_AT in s_CREti2 and

CHANGED_ON in s_Chgdt2 and

CHANGED_AT in s_Chgti2 and

*Begin of Mod-V003

FILE_STATUS in p_F_STA2 and

HPS_EXT in p_HPS_E2.

  • FILE_STATUS eq p_F_STA2 and

  • HPS_EXT eq p_HPS_E2.

*End of Mod-V003

*End of Insertion-Mod-V001

else.

if P_RMTRIG = 'X'.

SELECT * FROM ZWWREV_RM_TRIG

INTO corresponding fields of TABLE t_ftrig

WHERE CRSID IN S_CRSID2 AND

ACTVT in p_ACTVT3 and

*Begin of Mod-V003

  • ORGUNIT = p_ORUNIT AND

  • LAND1 = p_LAND1 and

ORGUNIT in p_ORUNIT AND

LAND1 in p_LAND1 and

*Begin of Mod-V003

*Begin of Insertion-Mod-V001

CREATED_ON in s_CREdt3 and

CREATED_AT in s_CREti3 and

CHANGED_ON in s_Chgdt3 and

CHANGED_AT in s_Chgti3 and

*Begin of Mod-V003

  • RM_SUCCESS eq p_RM_SUC and

RM_SUCCESS in p_RM_SUC .

  • RECORD_TYPE eq p_rec_t.

*End of Mod-V003

*End of Insertion-Mod-V001

endif.

endif.

endif.

ENDFORM. " SELECT_DATA

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'ZMENU'..

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module CREATE_OBJECTS OUTPUT

&----


  • text

----


MODULE CREATE_OBJECTS OUTPUT.

FREE: GO_GRID, GO_CUSTOM_CONTAINER.

CREATE OBJECT GO_CUSTOM_CONTAINER

EXPORTING

CONTAINER_NAME = 'CUST_CONTROL'.

CREATE OBJECT GO_GRID

EXPORTING

I_PARENT = GO_CUSTOM_CONTAINER.

CREATE OBJECT EVENT_RECEIVER .

SET HANDLER EVENT_RECEIVER->HANDLE_TOOLBAR FOR GO_GRID.

SET HANDLER EVENT_RECEIVER->HANDLE_USER_COMMAND FOR GO_GRID.

ENDMODULE. " CREATE_OBJECTS OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'BACK'.

*Begin of Mod-V002

  • LEAVE PROGRAM.

leave to screen 0.

*End of Mod-V002

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module DISP_DATA OUTPUT

&----


  • text

----


MODULE DISP_DATA OUTPUT.

PERFORM ALV_DISP.

ENDMODULE. " DISP_DATA OUTPUT

&----


*& Form handle_user_command

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM handle_user_command using ucomm TYPE SY-UCOMM.

CALL METHOD GO_GRID->GET_SELECTED_ROWS

IMPORTING

ET_ROW_NO = SEL_T_ROW.

CASE UCOMM.

WHEN 'DELE'.

IF P_FLOC = 'X' .

LOOP AT SEL_T_ROW INTO SEL_ROW.

read table t_floc into w_floc index SEL_ROW-ROW_ID.

check sy-subrc = 0.

append w_floc to t_floc1.

clear: sel_row, w_floc.

ENDLOOP.

*Begin of Insertion-Mod-V001

loop at t_floc1 into w_floc1.

read table t_floc into w_floc with key CRSID = w_floc1-CRSID.

if sy-subrc eq 0.

delete t_fLOC where CRSID = w_fLOC-cRSID.

if sy-subrc eq 0.

delete from zwwrev_fileloc where CRSID = w_floc-crsid.

endif.

endif.

clear : w_fLOC, w_fLOC1.

endloop.

*End of Insertion-Mod-V001

else.

IF P_FCBN = 'X' .

LOOP AT SEL_T_ROW INTO SEL_ROW.

read table t_fcbn into w_fcbn index SEL_ROW-ROW_ID.

check sy-subrc eq 0.

APPEND W_fcbn to t_fcbn1.

clear:sel_row,w_fcbn.

ENDLOOP.

*Begin of Insertion-Mod-V001

loop at t_fcbn1 into w_fcbn1.

read table t_fcbn into w_fcbn with key cbn_no = w_fcbn1-cbn_no.

if sy-subrc eq 0.

delete t_fcbn where cbn_no = w_fcbn-cbn_no.

delete from zwwrev_filecbn where cbn_no = w_fcbn-cbn_no.

endif.

clear : w_fcbn, w_fcbn1.

endloop.

*End of Insertion-Mod-V001

else.

IF P_RMTRIG = 'X' .

LOOP AT SEL_T_ROW INTO SEL_ROW.

read table t_ftrig into w_ftrig index SEL_ROW-ROW_ID.

check sy-subrc = 0.

APPEND W_FTRIG TO T_FTRIG1.

CLEAR: sel_row,w_ftrig.

ENDLOOP.

*Begin of Insertion-Mod-V001

loop at t_ftrig1 into w_ftrig1.

read table t_ftrig into w_ftrig with key crsid = w_ftrig1-crsid.

if sy-subrc eq 0.

delete t_ftrig where crsid = w_ftrig-crsid.

if sy-subrc eq 0.

delete from zwwrev_rm_trig where CRSID = w_ftrig-crsid.

endif.

endif.

clear : w_ftrig1, w_ftrig.

endloop.

*End of Insertion-Mod-V001

endif.

endif.

endif.

CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY.

ENDCASE.

ENDFORM. " handle_user_command

&----


*& Form HANDLE_TOOL_BAR

&----


  • text

----


  • -->P_E_OBJECT text

----


FORM HANDLE_TOOL_BAR USING I_OBJECT

TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET.

LS_TOOLBAR-FUNCTION = 'DELE'.

LS_TOOLBAR-ICON = ICON_DELETE.

LS_TOOLBAR-TEXT = 'DELETE'.

LS_TOOLBAR-BUTN_TYPE = 0.

APPEND ls_toolbar TO I_object->mt_toolbar.

ENDFORM. " HANDLE_TOOL_BAR

&----


*& Form EXCLUDE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM EXCLUDE .

IS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_EXCL_ALL.

APPEND IS_EXCLUDE TO IT_EXCLUDE.

ENDFORM. " EXCLUDE

Former Member
0 Kudos

write user command

I_CALLBACK_USERCOMMAND = 'USERCOMMAND'.

FORM USERCOMMAND.

when 'DELETE'.

Loop at itab where chk = 'X'.

delete itab index sy-tabix.

Endloop.

ENDFORM>

Former Member
0 Kudos

frnds,

I am not getting the solution. i need it in oops alv.

thanks,

satya

0 Kudos

<b>Check this code.</b>

FORM USERCOMMAND.

if sy-ucomm eq 'DELETE'.

Loop at itab where chk = 'X'.

delete itab index sy-tabix.

Endloop.

endif.

ENDFORM>

*then call below method to refresh table

CALL METHOD go_grid->refresh_table_display.

0 Kudos

&----


*& Form HANDLE_TOOL_BAR

&----


  • text

----


  • -->P_E_OBJECT text

----


FORM HANDLE_TOOL_BAR USING I_OBJECT

TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET.

LS_TOOLBAR-FUNCTION = 'DELE'.

LS_TOOLBAR-ICON = ICON_DELETE.

LS_TOOLBAR-TEXT = 'DELETE'.

LS_TOOLBAR-BUTN_TYPE = 0.

APPEND ls_toolbar TO I_object->mt_toolbar.

ENDFORM. " HANDLE_TOOL_BAR

&----


*& Form handle_user_command

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM handle_user_command using ucomm TYPE SY-UCOMM.

CALL METHOD GO_GRID->GET_SELECTED_ROWS

IMPORTING

ET_ROW_NO = SEL_T_ROW.

CASE UCOMM.

WHEN 'DELE'.

IF P_FLOC = 'X' .

LOOP AT SEL_T_ROW INTO SEL_ROW.

WRITE UR LOGIC HERE

ENDLOOP.

This is the only solution.

Former Member
0 Kudos

Frnds,

i want to write the delete logic but not getting how to write for multiple checkbox selections.

frnds please help me.

Thanks,

satya