‎2008 Mar 02 3:14 PM
Hi,
Can anyone give me a code example of deleteing a line form a dynamic internal table (not by index).
Thanks.
‎2008 Mar 02 5:10 PM
Hello
Let us assume that your dynamic itab contains a field VKORG (sales organisation) and you want to delete all entries where VKORG = '1100'.
FIELD-SYMBOLS:
<ls_record> TYPE any.
<ld_fld> TYPE any.
LOOP AT <lt_itab> ASSIGNING <ls_record>.
UNASSIGN <ld_fld>.
ASSIGN COMPONENT 'VKORG' OF STRUCTURE <ls_record> TO <ld_fld>.
IF ( <ld_fld> IS BOUND ).
IF ( <ld_fld> = '1100' ).
DELETE <lt_itab> INDEX syst-tabix.
ENDIF.
ENDIF.
ENDLOOP.
Regards
Uwe
‎2008 Mar 02 5:10 PM
Hello
Let us assume that your dynamic itab contains a field VKORG (sales organisation) and you want to delete all entries where VKORG = '1100'.
FIELD-SYMBOLS:
<ls_record> TYPE any.
<ld_fld> TYPE any.
LOOP AT <lt_itab> ASSIGNING <ls_record>.
UNASSIGN <ld_fld>.
ASSIGN COMPONENT 'VKORG' OF STRUCTURE <ls_record> TO <ld_fld>.
IF ( <ld_fld> IS BOUND ).
IF ( <ld_fld> = '1100' ).
DELETE <lt_itab> INDEX syst-tabix.
ENDIF.
ENDIF.
ENDLOOP.
Regards
Uwe
‎2008 Mar 02 7:48 PM
Is there another way to delete the record, without using the record index ?
‎2008 Mar 02 7:58 PM
Hello
You may try the following variant which - at the end of the day - uses the INDEX internally.
FIELD-SYMBOLS:
<ls_record> TYPE any.
<ld_fld> TYPE any.
LOOP AT <lt_itab> ASSIGNING <ls_record>.
UNASSIGN <ld_fld>.
ASSIGN COMPONENT 'VKORG' OF STRUCTURE <ls_record> TO <ld_fld>.
IF ( <ld_fld> IS BOUND ).
IF ( <ld_fld> = '1100' ).
DELETE <lt_itab> FROM <ld_record>. " not sure if this works
ENDIF.
ENDIF.
ENDLOOP.
Regards
Uwe
‎2008 Mar 03 6:55 AM
‎2012 Jul 19 8:41 PM
Thy following step.
1. Create a work area from dynamic table.
create data dyn_line like line of <fs_table>.
assign dyn_line->* to <fs_wa_tmp>.
2. Loop your internal table to work area and build one temp work area and then delete the record from your new work area.
LOOP at <fs_table> assigning <fs_wa>.
clear <fs_wa_tmp>.
Do.
Assign component sy-tabix of structure <fs_wa> to <fs_val>. <<<<<<<<<<<<< Assign value
if sy-subrc ne 0.
EXIT.
else.
Assign component sy-tabix of structure <fs_wa_tmp> to <fs_val1>. <<<<<<<<<<<<< Assign value
<fs_val1> = <fs_val>.
enddo.
delete <fs_table> from <fs_wa_tmp>.
ENDLOOP.
Try this logic according to your requirement.
Regards,
Dhirendra Pandit