Skip to Content
author's profile photo Former Member
Former Member

syntax of redundant data.

data :Begin of I_data

data1,

data2,

data3,

end of i_data

I have a internal table I_dat filled with

data1 data2 data3

1) x y z

2) x y z

3) x y i

4) c n o

5) c n o

6) n p l

7) j k o

8) b l n

9) b l n

10) j k y

I would like to have only lines which are repeating I would like to have lines 1,2,4,5,8,9.

Any idea how could I do.

Best Regards,

Mark

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Aug 01, 2006 at 05:07 PM

    Hi,

    Check this code :

    
         i_data1[] = i_data[].
    
    loop at i_data1.
        count = 0.
       loop at i_data.
       read table i_data with key    data1 = i_data1-data1
                                     data2 = i_data1-data2
                                     data3 = i_data1-data3.
       if sy-subrc eq 0.
    
         count = count + 1.
    
       endif.
    
    endloop.
       if count LE 1.
         delete i_data1.
       endif.
    endloop.
    

    now i_data1 will contain repeated value entries.

    Regards

    Appana

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 01, 2006 at 05:09 PM

    Try this:

    DATA: aux_itab LIKE i_dat OCCURS 0 WITH HEADER LINE,
          aux_cont TYPE i.
    
    
    SORT i_dat BY data1 data2 data3.
    aux_itab[] = i_dat[].
    
    LOOP AT i_dat.
      CLEAR aux_cont.
      LOOP aux_itab WHERE data1 = i_dat-data1
                      AND data2 = i_dat-data2
                      AND data3 = i_dat-data3.
        ADD 1 TO aux_cont.
      ENDLOOP.
      IF aux_cont EQ 1.
        DELETE i_dat.
      ENDIF.
    ENDLOOP.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 01, 2006 at 05:17 PM

    Here is one way to keep the duplicates.

    
    report zrich_0001.
    
    
    data :begin of i_data occurs 0,
          data1,
          data2,
          data3,
          end of i_data.
    
    data :begin of i_data2 occurs 0,
          data1,
          data2,
          data3,
          end of i_data2.
    
    data: counter type i.
    
    i_data = 'xyz'.  append i_data.
    i_data = 'xyz'.  append i_data.
    i_data = 'xyi'.  append i_data.
    i_data = 'cno'.  append i_data.
    i_data = 'cno'.  append i_data.
    i_data = 'npl'.  append i_data.
    i_data = 'jko'.  append i_data.
    i_data = 'bln'.  append i_data.
    i_data = 'bln'.  append i_data.
    i_data = 'jky'.  append i_data.
    
    i_data2[] = i_data[].
    
    sort i_data2 ascending by data1 data2 data3.
    delete adjacent duplicates from i_data2 comparing data1 data2 data3.
    
    
    loop at i_data2.
    
      clear counter.
      loop at i_data where data1 = i_data2-data1
                       and data2 = i_data2-data2
                       and data3 = i_data2-data3.
        counter = counter + 1.
      endloop.
    
      if counter = 1.
        delete i_data2.
      endif.
    
    endloop.
    
    
    loop at i_data2.
      write:/ i_data2-data1, i_data2-data2, i_data2-data3.
    endloop.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 05:18 PM

    Try this code

    data cntr type i.

    sort i_data.

    loop at i_data.

    cntr = cntr + 1.

    at end of data3.

    if cntr le 1.

    delete i_data.

    endif.

    clear cntr.

    endat.

    endloop.

    Regards

    Sridhar

    Message was edited by: Sridhar K

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.