-3

I need to count the number of duplicate rows in an internal table base on one field.

I have tried to create a work area and counting the duplicate data but the problem is it counts all duplicate data. My purpose is to count duplicate data by the same date.

DATA: gv_line TYPE i.

gv_line = 0.
LOOP AT i_sect_proe.
  IF wa_sect_proe IS INITIAL.
     wa_sect_proe = i_sect_proe.
     CONTINUE.
  ENDIF.

  IF wa_sect_proe-/smr/wondat EQ i_final_f-/smr/wondat.
     gv_line = gv_line + 1.
  ENDIF.

  i_sect_proe-/smr/line = gv_line.
ENDLOOP.

The code I've tried displays the number off all duplicate data.

Jagger
  • 10,350
  • 9
  • 51
  • 93
tikarahm
  • 5
  • 1
  • 4
  • 1
    Post a full working example, please. – Jagger Jul 11 '19 at 08:22
  • The full version of my working was too long, i cant post here because its load the characters can be display. – tikarahm Jul 11 '19 at 08:36
  • Possible duplicate of [Show duplicates in internal table](https://stackoverflow.com/questions/26165679/show-duplicates-in-internal-table) – Sandra Rossi Jul 11 '19 at 14:37
  • Please provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) - You have to spend a little time to write it so that the question is made clear. Your example code needs to include only two columns, an internal table initialized with three lines, then show the current result, what you expect, what you tried... – Sandra Rossi Jul 11 '19 at 14:42

1 Answers1

-2

DATA: BEGIN OF lt_result OCCURS 0,
               date TYPE datum,
               count TYPE i,
           END OF lt_result.

SORT yourTable BY dateField.

LOOP AT yourTable.
    lt_result-date   = yourTable-dateField.
    lt_result-count = 1.
    COLLECT lt_result INTO lt_result.
ENDLOOP.

Result in lt_result[].

OltanTerzi
  • 11
  • 2