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

delete line from itab

Former Member
0 Likes
1,155

hi friends,

i want to delete a line from itab when sy-surc <> 0.can any one give me complete code.

regards

veera

hi friends,

i want to delete a line from itab when sy-surc <> 0.can any one give me complete code.

regards

veera

8 REPLIES 8
Read only

Former Member
0 Likes
1,125

data : aa like sflight occurs 1 with header line.

select * into table aa from sflight.

delete aa index 1.

Read only

0 Likes
1,125

hi'

i want to delete when my condtion sy-subrc <>0

Read only

0 Likes
1,125

Can you please specify the complete request as sy-subrc <> 0 does not make sense...

Sy-Subrc is a system parameter which is gets a value depending on the performed operation. So you just can't that using it as a where condition.

Are you trying to do something like the below ...

loop at itab1.

read table itab2 with key f1 = itab1-f1.

if sy-subrc <> 0.

delete itab1.

endif.

endloop.

Read only

0 Likes
1,125

Instead if you know the line numbers of row you want to delete then directly write as :

DELETE <ITAB> [FROM <Line N1>] [TO <Line N2>] [WHERE <condition>]. //Deletes multiple line in internal table

DELETE ITAB Index<N1> //N1 is line/row number

Read only

0 Likes
1,125

Hi Veera

Use as per the syntax provided in my earlier post when SY-SUBRC ne 0 orelse provide your code for a better solution.

Kind Regards

Eswar

Read only

Former Member
0 Likes
1,125

Most commonly used:

DELETE itab [FROM wa] [INDEX idx] [WHERE <cond>].

Kind Regards

Eswar

Read only

Former Member
0 Likes
1,125

LOOP AT ITAB .

......

........// some processing

.......

IF SY_SUBRC NE 0.

DELETE <ITAB> index sy-tabix.

// this statement deletes the particular row from internal table

ENDLOOP.

Read only

Former Member
0 Likes
1,125

Hi,

U may delete data from internal table with following syntex:

DELETE itab where condition.

Cheers.