‎2007 Jan 29 7:32 AM
Hi all,
there is an internal table A with date as one one of the field.
i looped this table as loop at A.
Now the requirement is i want to delete the row from this internal table if date is zero.How to do this.
‎2007 Jan 29 7:37 AM
hi
chk if the date field is initial (Date with Zero) in your loop. and if yes then say " Delete Itab."
Deleting the line in Itab can be done using either Index or the Key.
-
Santosh
‎2007 Jan 29 7:36 AM
if ur date field is referring to sy-datum then it has to be like this .
loop at itab.
if itab-date eq '00000000'
delete itab index sy-tabix.
endif.
endloop.regards,
vijay
‎2007 Jan 29 7:37 AM
hi
chk if the date field is initial (Date with Zero) in your loop. and if yes then say " Delete Itab."
Deleting the line in Itab can be done using either Index or the Key.
-
Santosh
‎2007 Jan 29 7:39 AM
Hi,
You can use this line of code tahts enough
DELETE itab WHERE date = '00000000'.There is no need for a loop, this improves performance.
Hope thsi solves ur problem, reward points and clos eteh thraed if ur problem got solved.
‎2007 Jan 29 7:39 AM
hi,
chk this.
<u>pls dont use sy-tabiz directlt inside the loop.</u>
chk this.
data : f_tabix like sy-tabix.
loop at itab.
f_tabix = sy-tabix.
if itab-date eq '00000000'
delete itab index f_tabix .
endif.
endloop.rgds
Anver
‎2007 Jan 29 7:41 AM
Hi,
FIELD-SYMBOLS: <i_table> TYPE tabletype.
-
****
LOOP AT A ASSIGNING <i_table>.
IF <i_table>-field IS INITIAL.
DELETE A from <i_table>.
ENDIF.
ENDLOOP.
Regards,
Sunil
‎2007 Jan 29 7:41 AM
To improve performance do not loop and delete within the loop. Just use the DELETE statement outside the loop using a WHERE clause for the date field.
IF deleting within a loop is necessary, ensure you save the SY-TABIX within a temporary variable immediately after the loop statement and use this index for deletion, cos SY-TABIX is susceptible to change by other statements within the loop prior to deletion also.
Regards,
Aditya
‎2007 Jan 29 7:44 AM
execute the code.
data : begin of itab occurs 0,
f1(2) type c,
f2 like sy-datum,
end of itab.
DATA : CNTR LIKE SY-TABIX.
ITAB-f1 = 'A'.
ITAB-F2 = '20072801'.
APPEND ITAB.
CLEAR ITAB.
ITAB-f1 = 'B'.
ITAB-F2 = '00000000'.
APPEND ITAB.
CLEAR ITAB.
LOOP AT ITAB.
CNTR = SY-TABIX.
IF ITAB-F2 = '00000000'.
DELETE ITAB INDEX CNTR.
ENDIF.
ENDLOOP.
LOOP AT ITAB.
WRITE:/ ITAB-F1,
ITAB-F2.
ENDLOOP.regards,
vijay
‎2007 Jan 29 8:12 AM
Hi shwetha,
check this code,
REPORT zex33.
data : begin of itab occurs 0,
f type i,
f2 type sy-datum,
f3(10),
end of itab.
itab-f = 20 .
itab-f2 = '10052006'.
itab-f3 = '10/05/2006'.
APPEND ITAB.
CLEAR ITAB.
itab-f = 20 .
itab-f2 = '11052006'.
itab-f3 = '11/05/2006'.
APPEND ITAB.
CLEAR ITAB.
itab-f = 25 .
APPEND ITAB.
CLEAR ITAB.
itab-f = 25 .
APPEND ITAB.
CLEAR ITAB.
itab-f = 30 .
itab-f2 = '12052006'.
itab-f3 = '12/05/2006'.
APPEND ITAB.
CLEAR ITAB.
itab-f = 30 .
itab-f2 = '10082006'.
itab-f3 = '10/08/2006'.
APPEND ITAB.
CLEAR ITAB.
itab-f = 30 .
itab-f2 = '10082006'.
APPEND ITAB.
CLEAR ITAB.
write : / 'Internal table before'.
loop at itab.
write : / itab-f , itab-f2 , itab-f3.
endloop.
loop at itab.
if itab-f2 eq '00000000' or itab-f3 eq space.
delete itab index sy-tabix.
endif.
endloop.
write : / 'Internal table after deletion'.
loop at itab.
write : / itab-f , itab-f2 , itab-f3.
endloop.
‎2007 Jan 29 8:42 AM
‎2007 Jan 29 8:45 AM
data : f_tabix like sy-tabix.
loop at itab.
f_tabix = sy-tabix.
if itab-date eq '00000000'
delete itab index f_tabix .
endif.
endloop.
This should solve the problem.
‎2007 Jan 29 8:47 AM
Hi Shweta ,
If you just want to delete the entries which do not have a value in the date feild then you do not need to loop on the intermal table to do it.
Just write
DELETE A WHERE DATE IS INITIAL.
Regards
Arun