Application Development and Automation 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: 
Read only

Not Able to delete data from internal table to Data Base Table in table control

Former Member
0 Kudos
393

Dear All,

I am working on table control, i am looking to delete the data of z-table if that data is being deleted from table control. I have created a table control, in that data is coming form three tables. 2 of them are z-table and one is standard table. now what i want is, if we select a row fro table control and press delete, in that case it will delete the data from all the 3 tables. but in my case its only deleting the data from the final internal table in which i have saved the data from three database tables. So kindly suggest.

Thanks and regards

Jai

6 REPLIES 6
Read only

Former Member
0 Kudos
352

hi jaiprakash,

can you share the source of the delete so that it can be checked before giving any advise.

Read only

0 Kudos
352

Dear Abdul,

refer the below code, as i have created 3 work area, moved the records of respective table to that work area, and then tried to delete from the database table, that is not working.

WHEN 'DELE'.

       MESSAGE 'This will delete entire row,still you want to continue' TYPE 'W'.

       READ TABLE it_main2 INTO wa_main2 WITH KEY mark = 'X'.

       READ TABLE it_zexp_advice1 INTO wa_zexp_advice1 WITH KEY eorder = wa_main2-eorder

                                                                         mark = 'X'.

       DELETE it_main2 WHERE mark = 'X'.

       DESCRIBE TABLE it_main2 LINES tc_it_main2-lines.

         MOVE-CORRESPONDING wa_main2 TO  wa_vbap1.

         MOVE-CORRESPONDING wa_main2 TO wa_zexp_advice2.

         MOVE-CORRESPONDING wa_main2 TO wa_zea_packaging2.

   BREAK ABAP_BFL.

         DELETE vbap FROM wa_vbap1.

         DELETE zexp_advice FROM wa_zexp_advice2.

         DELETE zea_packaging FROM wa_zea_packaging2.


Thanks and Regards

Jai

Read only

0 Kudos
352

hi jaiprakash,

are you sure that there are values in the work area wa_vbap1?

Read only

0 Kudos
352

Hi Jaiprakadsh,

my suggestion is add sy-subrc after read statement because whenever we use read statement then we have to check whether the data is moved to work area or not.

Tahnks,

Sree

Read only

Former Member
0 Kudos
352

Are you performing a COMMIT?

Also it does not sound correct to delete data from a standard SAP table. You should be very cautious in doing this.

Read only

Former Member
0 Kudos
352

HI ,

If you want to delete a particular record then use where condition for delete

DELETE { {FROM target [WHERE sql_cond]}

       | {target FROM source} }.

thanks

Vijay