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

Performane issue

krishna_moorthy11
Discoverer
0 Likes
657

Hi,

I have an internal table with these records.

How to delete records that are not the same?

10RR10 | 60 | 20

10RR10 | 60 | 21

10RR10 | 59 | 13

10RR10 | 59 | 13

10RR10 | 57 | 20

10RR10 | 57 | 21

Result should be this:

10RR10 | 59 | 13

10RR10 | 59 | 13

I have run one fiscal year data when run backgroud job but my output is come after 10 hour's. Can u give fast display .

5 REPLIES 5
Read only

Former Member
0 Likes
638

try like this

loop at itab into wa.

v_idx = sy-tabix.

if v_idx > 1.

v_idx = v_idx - 1.

read table itab into wa1 index v_idx.

if wa = wa1

append wa1 itab1.

endif

endif.

endloop.

itab 1 will have ur records

this is a rough idea if u understood it then modify it to work perfectly.

кu03B1ятu03B9к

Read only

Former Member
0 Likes
638

Hi

sort itab1 by f1 f2 f3.

pass the itab values into temp itab2.

itab2 [] = itab1 [] .

loop at itab1.

v_index = sy-tabix.

read table itab2 index v_index+1.

if itab1-f1 <> itab2-f1 or itab1-f2 <> itab2-f2 or itab1-f3 <> itab2-f3.

delete itab1.

endif.

clear v_index.

endloop.

reg

Ramya

Edited by: Ramya S on Dec 31, 2008 10:59 AM

Read only

Former Member
0 Likes
638

LOOP AT ITAB.

LOOP AT ITAB INTO WA
WHERE  A = ITAB-A
              B = ITAB-B
              C = ITAB-C.
  CHECK SY-TABIX GE 2.
  APPEND WA INTO ITAB1.
  CLEAR WA.
ENDIF.     

ENDLOOP.
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
638

Hello Krishna,

Plz try the code below:


TYPES :
BEGIN OF ty_rec,
f1 TYPE char6,
f2 TYPE numc2,
f3 TYPE numc2,
END OF ty_rec.

DATA:
it  TYPE STANDARD TABLE OF ty_rec,
it1 TYPE STANDARD TABLE OF ty_rec,
it_final TYPE STANDARD TABLE OF ty_rec,
wa  TYPE ty_rec,
v_cnt TYPE i.

SORT it BY f1 f2 f3.

it1 = it.

DELETE ADJACENT DUPLICATES FROM it1 COMPARING f1 f2 f3.

LOOP AT it INTO wa.
  READ TABLE it1 WITH KEY
  f1 =  wa-f1
  f2 =  wa-f2
  f3 =  wa-f3 BINARY SEARCH
  TRANSPORTING NO FIELDS.
  IF sy-subrc = 0.
    v_cnt = v_cnt + 1.
    IF v_cnt > 1.
      APPEND wa TO it_final.
      CLEAR: wa, v_cnt.
    ENDIF.
  ENDIF.
ENDLOOP.

IT_FINAL will have the duplicate values.

BR,

Suhas

Read only

Former Member
0 Likes
638

Hi,

this will resolve your problem.

10RR10 | 60 | 20

10RR10 | 60 | 21

10RR10 | 59 | 13

10RR10 | 59 | 13

10RR10 | 57 | 20

10RR10 | 57 | 21

records in i_itab1.

sort i_itab1 by col1 col2 col3.

i_itab2 = i_itab1.

itab1 itab2

-


-


10RR10 | 60 | 20 10RR10 | 60 | 20

10RR10 | 60 | 21 10RR10 | 60 | 21

10RR10 | 59 | 13 10RR10 | 59 | 13

10RR10 | 59 | 13 10RR10 | 59 | 13

10RR10 | 57 | 20 10RR10 | 57 | 20

10RR10 | 57 | 21 10RR10 | 57 | 21

delete ADJACENT DUPLICATES FROM i_itab2 COMPARING col1 col2 col3.

itab2

-


10RR10 | 60 | 20

10RR10 | 60 | 21

10RR10 | 57 | 20

10RR10 | 57 | 21

loop at i_itab2 into i_itab2_line.

delete TABLE i_itab1 FROM i_itab2_line.

endloop.

10RR10 | 59 | 13

10RR10 | 59 | 13

this will resolve your problem