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

Dynamic record deletion from database table

surya_gupta3
Explorer
0 Likes
2,219

Hi,

I need to delete selected records from database table(dynamic names). Table names are being passed from main program with some of their field names. The record to be deleted from the database table is being decided based on the fields passed for the table and their contains passed from the main program.

It is not possible to write dynamic where clause for DELETE statement directly.

So, I created a dynamic internal table and selected the records to be deleted in that internal table.

Now I want to use the syntax :

DELETE (dbtabname) FROM TABLE itab.

But for "(dbtabname)", the system is recognising it as internal table.

When i use "DELETE FROM (table_name), it recognises "table_name" as database table.

As i know

To specify the database table dynamically, we have to enter the following for <target>:

DELETE [FROM] (<name>) [CLIENT SPECIFIED] <lines>.

Please help How should I delete entries from database table when i have the records to be deleted in an internal table.

Thanks & Regards,

Surya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,658

DELETE (dbtabname) FROM TABLE itab.

will work. What error is it giving?

Regards,

Ravi

9 REPLIES 9
Read only

Former Member
0 Likes
1,659

DELETE (dbtabname) FROM TABLE itab.

will work. What error is it giving?

Regards,

Ravi

Read only

0 Likes
1,658

According to my program logic, Insteed of "table_name" I am useing T_FLDS_AGTAB-TABNAME where T_FLDS_AGTAB containing table names and their field names (table passed from the main program).

Error message:

"T_FLDS_AGTAB" is a table without a header line and therefor no component called "TABNAME"

Read only

0 Likes
1,658

DELETE (dbtabname) FROM TABLE itab.

Define (dbtabname) LIKE DD02L-tabname.

Ex:

DATA: dbtabname LIKE dd02l-tabname.

Read only

0 Likes
1,658

Hi,

Did u check if T_FLDS_AGTAB has some data in it. May be you need to declare an internal table of type T_FLDS_AGTAB and populate it with required values and later use that delete statement. Because "DELETE dbtab FROM TABLE itab" is statement used to delete database tables only.

Regards

Saikiran

Read only

0 Likes
1,658

Thanks buddy, now the code is working.

There was a mistake.

I was using t_flds_agtab, insteed of s_flds_agtab.

Thanks,

Still i need to test the code for its successful deletion from database table.

I will be back with issues soon.

Thanks again,

Surya

Read only

0 Likes
1,658

Please award some points if it works...

Read only

0 Likes
1,658

Please let me know some more things.

I am using a subroutine to create a dynamic inter table and the reference variable is being passed to the calling program.

the calling program will get an address(as a CHANGING parameter passed while calling)

I want to know - after it comes out of the subroutine, will the address be meaningful. The memory area in which the dynamic internal table was created will we flushed after returning from the sub-routine ??

"Remember the GEETA's Quote - Do your DUTY !! without thinking of the RESULTS or PRIZES ...

Please dont mind buddy....just kidding...I will soon reward you with points.

Enjoy ABAP !!!

Read only

0 Likes
1,658

That shuldn't happen ideally ( Think the value should remain intact even after coming out of the subroutine ) ..anyways if u post the exact code it will be much easier to sort out

Read only

andreas_mann3
Active Contributor
0 Likes
1,658

.