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: 

Msg for delete multiple record

0 Kudos

If I delete multiple record s from a table how to add message for deleting multiple record.

Eg if I delete material no 1580, 1581,1582

It will show a status message that 'material no 1580,1581,1582 successfully deleted.How can I write kindly suggest. Thanks in advance

1 ACCEPTED SOLUTION

touzik_itc
Active Participant

If you mean an internal table:

TYPES tt_mara TYPE TABLE OF mara WITH EMPTY KEY.
DATA(lt_mara) = VALUE tt_mara( ( matnr = '1580') ( matnr = '1581') ( matnr = '1582') ).

TYPES tt_matnr TYPE TABLE OF matnr WITH EMPTY KEY.
DATA(lt_matnr) = VALUE tt_matnr( ( '1580') ( '1581') ( '1582') ).

TYPES tt_matnr_range TYPE RANGE OF matnr.
DATA(lt_matnr_range) = VALUE tt_matnr_range( FOR <matnr> IN lt_matnr
  ( sign = 'I' option = 'EQ' low = <matnr> ) ).

DELETE lt_mara WHERE matnr IN lt_matnr_range.
IF sy-subrc = 0.
  MESSAGE |Materials { concat_lines_of( table = lt_matnr sep = ',' ) } have been deleted.| TYPE 'S'.
ENDIF.
6 REPLIES 6

former_member184158
Active Contributor
0 Kudos

Hi,

You can use the MESSAGE statement in ABAP to display a message after deleting multiple records from a table.

MESSAGE 'Materials 1580, 1581, and 1582 have been deleted.' TYPE 'S'.

OR try to use BAPIRET2 and call the method cl_rmsl_message=>display( lt_bapiret2 ).

DATA: lt_bapiret2 TYPE STANDARD TABLE OF bapiret2,
      ls_bapiret2 TYPE bapiret2.

* Check if some condition is met
IF some_condition.
  ls_bapiret2-type = 'S'.
  ls_bapiret2-id = 'MY_APP'.
  ls_bapiret2-number = '001'.
  ls_bapiret2-message = 'Materials has been deleted.'.
  ls_bapiret2-MESSAGE_V1 = Mat1. 

Append ls_bapiret2 to lt_bapiret2. 
ls_bapiret2-MESSAGE_V1 = Mat2. 
Append ls_bapiret2 to lt_bapiret2. 
cl_rmsl_message=>display( lt_bapiret2 ).

0 Kudos

If the user will delete more record

touzik_itc
Active Participant

If you mean an internal table:

TYPES tt_mara TYPE TABLE OF mara WITH EMPTY KEY.
DATA(lt_mara) = VALUE tt_mara( ( matnr = '1580') ( matnr = '1581') ( matnr = '1582') ).

TYPES tt_matnr TYPE TABLE OF matnr WITH EMPTY KEY.
DATA(lt_matnr) = VALUE tt_matnr( ( '1580') ( '1581') ( '1582') ).

TYPES tt_matnr_range TYPE RANGE OF matnr.
DATA(lt_matnr_range) = VALUE tt_matnr_range( FOR <matnr> IN lt_matnr
  ( sign = 'I' option = 'EQ' low = <matnr> ) ).

DELETE lt_mara WHERE matnr IN lt_matnr_range.
IF sy-subrc = 0.
  MESSAGE |Materials { concat_lines_of( table = lt_matnr sep = ',' ) } have been deleted.| TYPE 'S'.
ENDIF.

0 Kudos

If the user will delete more record how is it possible

0 Kudos

To delete more records add corresponding keys to the table lt_matnr.

Sandra_Rossi
Active Contributor

Where do you want to show this message? Are you sure you can display an unlimited message in case there are many materials deleted?