01-22-2013 7:32 PM
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.
01-22-2013 7:58 PM
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.
01-22-2013 7:58 PM
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.
01-23-2013 8:35 PM
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?
01-24-2013 5:10 AM
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
03-11-2023 7:39 PM
01-24-2013 5:26 AM
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.