Application Development and Automation 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: 
Read only

problem with delete statement

Former Member
0 Likes
739

Hi all,

here i have an internal table with 32 fileds almost.

i have to delete adjacent duplicates comparing 31 fields.

i have my internal table with some data as

PERNR BEGDA ENDDA SEQNR AWDTP AWAMT

001 01012006 01012006 0 9120 10.00

001 01012006 01012006 1 9120 10.00

001 01012006 01012006 2 9120 10.00

if have sorted the table before

if use delecte adjacent duplicate from itab comparing pernr begda endda awdtp

Here i should not use seqnr.

when i use above syntax the system has to delete 2nd 2 records

but here it is deleting only 2nd record

please can any one give me suggestion

with regards

anandp

7 REPLIES 7
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
706

Hi,

Use the same FILEDS In SORT BY and then in DELETE ADJACENT DUPLICATES COMPARING in the SAME ORDER.

Regards,

Sesh

Read only

Former Member
0 Likes
706

Hi,

Write TWICE this DELETE ADJACENT statment

Regards

Sudheer

Read only

0 Likes
706

HI if i write twice and i have n number of duplicates then i will not work again i ahve to face the same problem

with regards

anandp

Read only

0 Likes
706

Do it like this...

SORT ITAB descending BY pernr begda endda awdtp awamt.

delete adjacent duplicate from itab comparing pernr begda endda awdtp awamt.

It will solve your problem.

Regards,

Sairam

Read only

0 Likes
706

hi.... try this piece of code

It deletes duplicates.... even if they are not adjacent

FORM get_latest_deal CHANGING ch_t_deals TYPE t_typ_deals.

DATA : ls_deals TYPE zak_pbb_deals,

l_sytabix TYPE sytabix.

FIELD-SYMBOLS : <ls_deals> TYPE zak_pbb_deals.

  • sorting based on date and other key fields

SORT ch_t_deals BY aktnr matnr datum DESCENDING.

LOOP AT ch_t_deals ASSIGNING <ls_deals>.

l_sytabix = sy-tabix.

  • for the same the promotion-article

IF <ls_deals>-aktnr = ls_deals-aktnr AND

<ls_deals>-matnr = ls_deals-matnr.

DELETE ch_t_deals INDEX l_sytabix.

CONTINUE.

ENDIF.

  • storing the work area

ls_deals = <ls_deals>.

ENDLOOP.

ENDFORM. " get_latest_deal

<b>

please reward points</b>

regards

raksha

Read only

0 Likes
706

THE SYSTEM IS SAYING T_TYP_DEALS

zak_pbb_deals ARE UNKNOW

Read only

Former Member
0 Likes
706

make your internal table like this

now your logic will work

PERNR BEGDA ENDDA AWDTP AWAMT SEQNR

001 01012006 01012006 10.00 0 9120

001 01012006 01012006 10.00 1 9120

001 01012006 01012006 10.00 2 9120

delecte adjacent duplicate from itab comparing pernr begda endda awdtp awamt

Message was edited by:

vamsi reddy

Message was edited by:

vamsi reddy