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: 

Regarding Delete duplicates adjacent in internal table

Former Member
0 Kudos

hey

In my report i tried to delete the adjacent datas as

below from table itab_rbusa.but it is not deleting. why

-


code------

append lines of itab_glt0[] to itab_rbusa.

delete adjacent duplicates from itab_rbusa comparing all fields.

-


endof code----


if internal table has below values

011F

316A

789B

789B

131B

132B

302B

i get the same values as output after using the delete statement why?(789B-Business Area is not deleting)

could you please guide me.

ambichan.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Does the table contain other columns as well? See if the addition <b>comparing all fields</b> is causing the problem.

Regards

9 REPLIES 9

Former Member
0 Kudos

Hi,

Does the table contain other columns as well? See if the addition <b>comparing all fields</b> is causing the problem.

Regards

0 Kudos

hey i have only one field in this table itab_rbusa.

ie. rbusa is the only field i have in it.

let me give the outline for my code.

loop at itab_t001.

select rbusa

from glt0

into table itab_glt0

append lines of itab_glt0[] to itab_rbusa.

delete adjacent duplicates from itab_rbusa comparing all fields.

...where i did loop itab_rbusa.and printed values ..still i get duplicates.

endloop.

ambichan.

0 Kudos

Hi,

Firstly, issuing a SELECT statement in a LOOP is not advisable. If this is the complete code and you have not missed any lines, it seems that the table itab_t001 hasn't got much to do with selection. Please try to place SELECT outside the loop and then issue a DELETE ADJACENT statement. Secondly, have you tried the addition <b>SELECT DISTINCT rbusa</b>.

Regards

0 Kudos

Hi Ambi Chan,

Before deleting , SORT internal table and then try.

Thanks

Lakshman

0 Kudos

hey

i dont think DISTINCT option will be much useful in this case. because my operation is like this.

1.Created loop with company code,itab_t001.

2-select rbusa from glt0 into table itab_glt0

where bukrs = itab_t001 and other fields.

3- append lines of itab_glt0[] to itab_rbusa.

4-delete if any duplicates in table(delete adjacent command).

5-endloop.

6-finally i take table itab_rbusa and with respect to

rbusa field i am displaying summary report respect to rbusa field(biz area).

could you pls tell me how can i modify here..

if any idea.

ambichan

0 Kudos

Hi ambi,

So , if the command "delete adjacent.." does'nt work ,

what ist's very strange:

Instead of:

append lines ...

delete adjacent ...

-> try this:

  LOOP AT itab_glt0 INTO wa_rbusa.
    COLLECT wa_rbusa INTO itab_rbusa.
   ENDLOOP.

Regards Andreas

0 Kudos

Hi,

You can use the addition FOR ALL ENTRIES rather than issuing SELECT in a loop. Try something like:


SELECT [DISTINCT] rbusa
  FROM glt0
  INTO TABLE itab_glt0
   FOR ALL ENTRIES IN TABLE itab_t001
 WHERE bukrs EQ itab_t001-bukrs
   AND <other fields>...

APPEND LINES OF itab_t001[] TO itab_rbusa....

If DISTINCT does not serve the purpose, then you will need:

SORT itab_rbusa.
DELETE ADJACENT DUPLICATES FROM...

Regards

Message was edited by: Shehryar Khan

0 Kudos

hey guys

thanks for your help.

using sort itab_rbusa. before delete statement

gets works for me.

thanks a lot.

ambichan.

0 Kudos

Hi,

Good to know that your problem has been solved. Although it is your choice to award points and thank the contributors the SDN way, I just wanted to highlight that Lakhsman was the first one to propose use of SORT before issuing DELETE ADJACENT... So please consider that when awarding maximum points.

Regards