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: 

Marking deletion flag using SM30

saradas
Explorer
0 Kudos

we have a custom table and it has a field, flag for deletion.

Now In SM30, if user tries to delete the records, the flag need to be set but the records must not be deleted.

I tried using the event '03' (before deleting the data) but couldn't achieve the functionality.

P.S:As i haven't found the correct answer, i'm re-posting this question.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sarada,

When you trigger 03 event, it will delete the record, but at the beginning of this event store that selected record into memory id or parameter id and append it to the table again in event "After deleting the data".

In event 'before deleting the data', set your deletion flag.

Regards,

Mahidhar.

5 REPLIES 5

Former Member
0 Kudos

Hi Sarada,

When you trigger 03 event, it will delete the record, but at the beginning of this event store that selected record into memory id or parameter id and append it to the table again in event "After deleting the data".

In event 'before deleting the data', set your deletion flag.

Regards,

Mahidhar.

0 Kudos

hey i was able to store the record with memory id and able to create it again in "after saving" event.

But instead of deleting and re-creating the record, can i just abort deletion and modify the record?

0 Kudos

Hi Sarada,

Yes you can mark the deletion flag and abort the deletion. There is just a bit of diversion in the process.

Try using the below method

1. You have the following code for table maintenance generator

   MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
MODULE LISTE_BEFORE_LOOP.
LOOP AT EXTRACT.
   MODULE LISTE_INIT_WORKAREA.
   CHAIN.
    FIELD ZTABLE-field1 .               " This would be the key

    FIELD ZTABLE-field2 .               " This would be the key

    FIELD ZTABLE-field3 .
    MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
   ENDCHAIN.
   FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
   CHAIN.
   
FIELD ZTABLE-field1 .               " This would be the key

    FIELD ZTABLE-field2 .               " This would be the key

    MODULE LISTE_UPDATE_LISTE.
   ENDCHAIN.
ENDLOOP.

MODULE deletion_flag.     " create a new module here


MODULE LISTE_AFTER_LOOP.

 

You have to change the behaviour of the standard TMG before module liste_after_loop(here the record is actually deleted). The records to be deleted have a value M appended/inserted at the end of

that record.

You can also see the extra space the system takes before M.

2. Write the below code as below in the module created.

Note 1: You have to change the required fields using offset only as the internal table has only one column called LINE. see the screenshot.

     LOOP AT extract.

          CHECK extract+length(1) EQ 'M'.         " See note 2 below for length

          ....set the deletion flag as you require(set the value of the variable/table field to X here)

              extract+length(1) = space.

               MODIFY extract.

ENDLOOP.

Note 2 :  Here the length would be sum of table field lengths + mandt length + 1

Eg: assuming you have 3 fields having lengths 10 each

     sum of field lengths = 30

     mandt field length   = 3

     space taken by the system

Therefore length = 30 + 3 + 1 = 34

Hope this helps

I have tried using this and it works

0 Kudos

Thanks Guy's this is really helpful and too much easy.

Former Member
0 Kudos

Hi Sarada,

Solution provided by Aniket is promising. If you are having more records then its better to follow Aniket's or if the table is a master table and contains few records then you can go for any of the methods.

Regards,

Mahidhar.