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: 

delete current record

Former Member
0 Kudos

Hi Experts,

loop at itab.

if <condition>.

do something.

else.

(Here i dont want the current record in output).

endif.

endloop.

1.I have tried "delete itab index sy-tabix".

but the record is not deleted when if condition fails.

2. And also i tried "delete itab" but it leads short tump.

3. clear itab. its deleting the current record.but it inserts one empty record additionally.

help me what statement is suitable after else statement.

8 REPLIES 8

Former Member
0 Kudos
data : l_tabix like sy-tabix.

loop at itab.
<b>l_tabix = sy-tabix.</b>
if <condition>.
do something.

else.

(Here i dont want the current record in output).
<b>delete itab index l_tabix.</b>
endif.

endloop.

Former Member
0 Kudos

Hi,

Use CONTINUE after DELETE ITAB.

Ex.

Loop at itab.

if cond.

do something.

else.

delete itab.

continue.

endloop.

Hope it helps.

regards,

Shashank

Former Member
0 Kudos

hi,

try this sample code.


loop at itab into wa.

if <condition>.
do something.

else.

delete itab from wa.
endif.

regards,

Kinshuk

former_member188685
Active Contributor
0 Kudos

Hi,

do this way..

Loop at itab.

if <condition>.
do something...
else.
delete itab index sy-tabix. 
endif.
endloop.

may be you missed out index option thats the reason it is giving short dump.

now it will work..

Regards

Vjay

0 Kudos

In this code when the bolded if condition fails i want to delete that record. I tried "delete struct1 index sy-tabix" but that record is not deleted.

I tried "clear struct1 ". its deletes the current record.

but in some field its getting zero value & it is appending as a additional record.

Please help me.

loop at cdhdr.

if ( it1-tcode = 'FSS0' or it1-tcode = 'FS00' ).

w1_saknr = it1-objectid+4(10).

w_orgid = it1-objectid+14(4).

loop at it_cdpos where changenr eq it1-changenr

and objectid eq it1-objectid

and objectclas eq it1-objectclas.

<b>If w_orgid in r_orgid.</b>

IF ( it_CDPOS-FNAME = 'XLOEV' AND it_cdpos-value_new eq 'X' ).

replace struct1-change_ind with 'D' into struct1-change_ind.

struct1-bukrs = w_orgid.

struct1-cost = space.

struct1-plant = space.

append struct1.

else.

struct1-bukrs = w_orgid.

struct1-change_ind = w_chngid.

struct1-cost = space.

struct1-plant = space.

append struct1.

endif.

<b> else</b>.

<b>delete struct1 index sy-tabix</b>.

endif.

append struct1.

endloop.

endif.

endloop.

0 Kudos

Hi Siliviya,

why are you appending ...

delete struct1 index sy-tabix.
endif.
<b>append struct1.</b>
endloop.
endif.
endloop.

that is the problem ,it is appending blank record,

can you explain what you are trying ...

Regards

Vjay

Former Member
0 Kudos

hi,

in the Else part.

first Read the table i.e READ TABLE ITAB WITH KEY...

DELETE ITAB INDEX SY-TABIX.

hope this helps,

thanks,

priya

Message was edited by: Priya

Former Member
0 Kudos

try this -

loop at itab.

if <condition>.

do something.

else.

(Here i dont want the current record in output).

<b>continue.</b>

( as you don't want to display that record, you can skip that by using continue without deleting that record)

endif.

endloop.