‎2007 Jul 27 1:47 PM
i m having a dynamic internal table.
i want to delete a record where product = 'car'.
there are 10 records with value car.
how to delete as a whole.
in static table i will specify it[].
How to do tht in dynamic table.
Thanks in advance.
‎2007 Jul 27 1:51 PM
hi.
Try this.
Loop at internal_table where product = 'car'.
delete internal_table.
endloop.
Warren
‎2007 Jul 27 1:55 PM
I don't think you can do this in one line with a dynamic internal table. But you can do it like this.
loop at <dyn_table> into <dyn_wa>.
assign component 'PRODUCT' of structure <dyn_wa> to <dyn_field>.
if <dyn_field> = 'car'.
delete table <dyn_table> from <dyn_wa>.
endif.
endloop.
Regards,
Rich Heilman
‎2007 Jul 27 1:56 PM
Hi Maya,
Use,
Delete itab where product eq car.
Reward points if useful.
‎2007 Jul 27 1:56 PM
suposse <FS_1> is you internal table...
step 1 create work area as line of you internal table
DATA: NEW_LINE type ref to data.
create data NEW_LINE like line of <FS_1>.
assign NEW_LINE->* to <FS_2>.
then loop on your internal table
loop at <FS_1> assigning <FS_2>.
* Get the component in which value is stored..
assign component 1 of structure <FS_2> to <FS_3>.
IF <FS_3> = 'CAR' .
DELETE <FS_1> INDEX sy-tabix
ENDIF.
endloop.
Message was edited by:
Pawan Kesari
‎2007 Jul 27 1:58 PM
Please see the code below :
It may help u..
DATA: BEGIN OF itab OCCURS 0,
fld1(10) TYPE c,
fld2(10) TYPE c,
fld3(10) TYPE c,
END OF itab.
DATA: l_index LIKE sy-tabix.
FIELD-SYMBOLS: <fs> TYPE ANY,
<fs_tab> TYPE table,
<l_fs> TYPE ANY.
itab-fld1 = '1'.
itab-fld2 = '2'.
itab-fld3 = '3'.
APPEND itab.
itab-fld1 = '11'.
itab-fld2 = '22'.
itab-fld3 = '33'.
APPEND itab.
itab-fld1 = '111'.
itab-fld2 = '222'.
itab-fld3 = '333'.
APPEND itab.
LOOP AT itab.
WRITE:/ itab-fld1, itab-fld2, itab-fld3.
ENDLOOP.
assign itab[] to <fs_tab>.
LOOP AT <fs_tab> ASSIGNING <fs>.
l_index = sy-tabix.
ASSIGN COMPONENT 1 OF STRUCTURE <fs> TO <l_fs>. " Component 1 = FLD1
*** OR use ASSIGN COMPONENT 'FLD1' OF STRUCTURE <fs> TO <l_fs>.
IF <l_fs> EQ '1'.
DELETE <fs_tab> INDEX l_index.
ENDIF.
ENDLOOP.
LOOP AT itab.
WRITE:/ itab-fld1, itab-fld2, itab-fld3.
ENDLOOP.
Reward if useful..
Regards
Prax