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: 

Help on Delete Internal table records

Former Member
0 Kudos

Hi,

I have a internal table with some records in it.

I need to delete the contents of this based on the condition as below.

if product_search-Resp_product_company is not initial.

SORT i_equi BY zzrefeng.

DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.

endif.

when i execute this all the records are getting deleted irrespective of the condition mentioned.

Can anyone help me on this.

Regards,

Ram

10 REPLIES 10

Former Member
0 Kudos

hi

try by giving the sort before the <b>if</b> condition

SORT i_equi BY zzrefeng.

if product_search-Resp_product_company is not initial.

DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.

endif.

Cheers

Alfred

Former Member
0 Kudos

Shouldn't it be

if <u><i><b>NOT</b></i></u> product_search-Resp_product_company is initial.

SORT i_equi BY zzrefeng.

DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.

endif.

Regards,

Ravi

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If <b>not product_search-Resp_product_company is initial.</b>

sort i_equi by zzrefeng.

delete i_equi where zzrefeng ne product_search-Resp_product_company.

endif.

If again all records are deleted,just check whether your table contains same values for the field zzrefeng.

0 Kudos

Hi,

If not product_search-Resp_product_company is initial.

sort i_equi by zzrefeng.

delete i_equi where <b>not</b> zzrefeng = product_search-Resp_product_company.

endif.

Kindly reward points by clicking the star on the left of reply if the reply is useful.

Message was edited by: Jayanthi Jayaraman

gopi_narendra
Active Contributor
0 Kudos

if <b>not</b> product_search-Resp_product_company is initial.

SORT i_equi BY zzrefeng.

DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.

endif.

Regards

- Gopi

Former Member
0 Kudos

I think you need to check the data in the two fields zzrefeng, product_search-Resp_product_company.

The condition (zzrefeng <> product_search-Resp_product_company)that you have specified is true and thats why the data is deleted.

Best Regards,

Vibha

*Please mark all the helpful answers

Former Member
0 Kudos

Hi,

kindly try this code:

IF NOT product_search-resp_product_company IS INITIAL.

  SORT i_equi BY zzrefeng.
  LOOP AT i_equi.
    IF i_equi-zzrefeng NE product_search-resp_product_company.
      DELETE i_equi.
    ENDIF.
  ENDLOOP.
  
ENDIF.

hope this helps!

best regards,

Thangesh

Former Member
0 Kudos

Hi Ram,

1. You are right this will DELETE all records where product_search-Resp_product_company contains some value.

2. please let me know in which case you want to delete record from internal table.

Thanks.

0 Kudos

Hi,

Need to delete the records if <b>ZZREFENG</b> does not have the value of <b>product_search-Resp_product_company</b> .

Here I have product_search-Resp_product_company value as FI14. And also the internal table contains some records with ZZREFENG = FI14.

I need to delete the internal table records if ZZREFENG <> FI14. But when i execute the statement it is deletng all the records even ZZREFENG = FI14 records also.

Regards,

Ram

Former Member
0 Kudos

I think then you need to check the way in which you have defined the two fields. Plz check their data types.

Best Regards,

Vibha

*Please mark all the helpful answers