03-22-2006 9:51 AM
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.
03-22-2006 9:56 AM
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.
03-22-2006 9:58 AM
Hi,
Use CONTINUE after DELETE ITAB.
Ex.
Loop at itab.
if cond.
do something.
else.
delete itab.
continue.
endloop.
Hope it helps.
regards,
Shashank
03-22-2006 10:00 AM
hi,
try this sample code.
loop at itab into wa.
if <condition>.
do something.
else.
delete itab from wa.
endif.
regards,
Kinshuk
03-22-2006 10:01 AM
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
03-22-2006 10:55 AM
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.
03-22-2006 11:06 AM
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
03-22-2006 10:01 AM
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
03-22-2006 10:50 AM
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.