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: 

How to delete rows from the internal table intab?

Former Member
0 Kudos

I'm trying to delete rows from an internal table, but though the program gets activated the rows don't get deleted from the table! The rows that should not be deleted are the ones whose locno value is contained in select option p_sup, all others should be deleted.

SELECT-OPTIONS: p_sup FOR p_prdsel,

DELETE intab

WHERE locno NOT IN p_sup AND

COMMIT WORK.

When this didn't work I then also tryed to import the rows - with the values of locno that should be kept in intab - in an internal table intab1. The rows that should be deleted are the ones whose locno value is in intab1~locno.

DELETE intab

WHERE locno NOT IN intab1-locno.

This failed with the error: "intab1 is a table without a header line and therefore has no component called "LOCNO"".

Does anybody have an idea about why the above mentioned delete codes failed or how I should go about to delete rows from an internal table when select option or another internal table (intab1) contain rows that should not be deleted (NOT IN) from intab?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data: intab1 like intab occurs 0 with header line.

For this data definition I get the error: "When using "WITH HEADER LINE" the line type cannot be a table".

10 REPLIES 10

Former Member
0 Kudos

By the way the first code example is:

DELETE intab

WHERE locno NOT IN p_sup.

There is no:

... AND

COMMIT WORK...

0 Kudos

Try this ..

DELETE intab

WHERE NOT locno = intab1-locno.

Regards,

Ravi

0 Kudos

DELETE intab

WHERE locno NOT IN p_sup.

I THINK THIS IS NOT VALID COMMAND..

USE

DELETE intab

WHERE NOT locno = intab1-locno.

0 Kudos

Hi,

<b>

DELETE intab

WHERE locno NE intab1-locno.

</b>

Rgds,

Jothi.

Mark useful answers.

0 Kudos

<i>DELETE intab

WHERE locno NOT IN p_sup AND

COMMIT WORK</i>

loop at p_sub.

read table intab with key locno eq p_sub-locno.

if sy-subrc eq 0.

else.

delete intab.

endloop.

reward points if it helps

Regards

Gunjan

Former Member
0 Kudos

Hi ,

DELETE intab
WHERE locno NOT IN p_sup AND
COMMIT WORK.

i never used Commit Work ? how did u know abt Commit work along with <b>DELETE</b>first remove the commit work then check.

DELETE intab
WHERE locno NOT IN intab1-locno.
data defination should  be like this.
data: intab1 like intab occurs 0 with header line.
so 

regards

Prabhu

Former Member
0 Kudos

When I try suggested codes:

DELETE intab

WHERE NOT locno = intab1-locno.

or:

DELETE intab

WHERE locno NE intab1-locno.

I get the error "intab1 is a table without a header line and therefore has no component called "LOCNO"". The table intab1 is declared the same way as the table intab. Why do I get this error?

Former Member
0 Kudos

data: intab1 like intab occurs 0 with header line.

For this data definition I get the error: "When using "WITH HEADER LINE" the line type cannot be a table".

0 Kudos

hi

create a work area and loop at the internal table and move the contents to wrokarea ...and do operations...

Former Member
0 Kudos

Thanx a lot for all the helpful suggestions, but Mr. Gunjan Kumar was the one who cracked the problem this time. Thank you Gunjan!

/ armin