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: 

Deleting rows from an internal table

Former Member
0 Kudos

Hi All,

we are populating internal table T_FINAL from tables VBAP and VBRP,We want to remove certain rows

of data from T_FINAL based on some Order types in VBAK table.

15 REPLIES 15

Former Member
0 Kudos

Hi,

you can use READ and DELETE statement for this.

syntax

T_FINAL based on some Order types in VBAK table

loop at T_FINAL.

if (set the condition).

DELETE itab INDEX sy-tabix.

end loop.

ref:

for READ STATEMANT

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm

for DELETE STATEMENT

http://help.sap.com/saphelp_nw70/helpdata/en/06/aafd54fc4011d195280000e8353423/content.htm

regards,

anirban

david_carballido
Active Participant
0 Kudos

You can use DELETE itab WHERE (condition) if itab has a header work

Former Member
0 Kudos

HI,

U CAN USE DELETE STATEMENT BY CHECKING THE ORDER TYPES FROM INTERNAL TABLE.

Former Member
0 Kudos

Karthik

Do following:

Delete T_Final where ( AUART = 'XYZ' ).

Thanks

Amol Lohade

0 Kudos

we did try this option within a loop but amount of data we are dealing here is huge and loop is taking lotof time so any other suggestion will be helpful

0 Kudos

I try using DELETE itab WHERE field = value., this stament is more performance.

Sry for my bad english

Former Member
0 Kudos

Hi,

Use the Code below for deleting the particular line asper your requirement.

LOOP AT itab.

*Deleting the field which is selected.

DELETE itab WHERE (condition).

ENDLOOP.

0 Kudos

Hello boss plz do check ur code ... U R DELETING WITHIN LOOP THATS ALSO WITH CONDITION...

remove the loop.... single loop within loop is enough

Former Member
0 Kudos

hi

AUART is the fiiels of document type let ur internal table have this fiels as order_type

do like this

LOOP AT T_FINAL  INTO wa_final.

    IF wa_final-order_type = ' order type '.

   DELETE T_FINAL  INDEX sy-tabix.

  ENDIF.

ENDLOOP.

Cheers

Snehi

Former Member
0 Kudos

Hi ,

U can use

Delete i_tab where order_type = something ...

am i right or u r expecting something else ....

Former Member
0 Kudos

Hi,

plz try this way to delete a particular line from internal table :


LOOP AT T_FINAL WHERE AUART = 'some value'.

DELETE T_FINAL 

ENDLOOP.

.

thanx.

Edited by: Dhanashri Pawar on Sep 5, 2008 7:48 AM

Former Member
0 Kudos

This is the code we had written for the condition

LOOP AT FPT_VBRP INTO WA_VBRP.

L_TABIX = SY-TABIX.

READ TABLE FPT_VBAP INTO WA_VBAP WITH KEY VBELN = WA_VBRP-AUBEL

POSNR = WA_VBRP-AUPOS.

IF SY-SUBRC <> 0.

DELETE FPT_VBRP INDEX L_TABIX.

ENDIF.

CLEAR L_TABIX.

ENDLOOP.

This processing inside the LOOP .......ENDLOOP takes lot of time.Because it is dealing with 4 lakhs data in FPT_VBRP and almost the same in FPT_VBAP.

Ideally it should not take more than 10 minutes, but in this case it is working as infinite loop.

please look into this

Former Member
0 Kudos

Hi,

You can solve this issue in two ways.

1)By usiing the condition in the select statement where condition.

2)create a new table which of same type of your final internal table and follow this process.

field-symbols: <fs_t_new> type wa_new.

unassign <fs_t_new>.

loop at t_final assigning wa_final.

check <fs_t_new> is assigned.

check <fs_t_new>-ordertype ne 'condition'.

append <fs_t_new> to t_new.

endloop.

Please careful while using field symbols. If you are not familiar with that, you can use workarea like this.

loop at t_final into wa_final.

if wa_final-ordertype ne 'condition'.

append wa_final to t_new(new table of same type t_final).

clear wa_final.

endif.

endloop.

use this t_new table for remaining purpose which consists of the data satisfying your condition

Former Member
0 Kudos

Hi Karthik,

You are populating T_FINAL from VBAK & VBRK so T_FINAL would be having data of VBAK.you can delete

directly using following statement:

Delete t_final where order type = <order type>

Regards,

Hemant

Former Member
0 Kudos

Hi Karthik,

Firstly create an internal table with the data from VABK, say t_vbak.

Check this Sample, which might give you an idea:

Loop at t_final.

w_index = sy-tabix.

 READ TABLE t_vbak with key <condition>.
                                              
 if sy-subrc eq 0.
    delete t_final index w_index.
endif.

Endloop.

Regards,

Chandra Sekhar