0

How can I check the repetitive value in the "Form #" column?

enter image description here

I want to highlight it later as duplicate record.

  LOOP AT ZVBELNEXTTAB WHERE werks IN werks.

ZVBELNEXTTAB_COPY-WERKS        = ZVBELNEXTTAB-WERKS.
ZVBELNEXTTAB_COPY-MANDT        = ZVBELNEXTTAB-MANDT.
ZVBELNEXTTAB_COPY-BUKRS        = ZVBELNEXTTAB-BUKRS.
ZVBELNEXTTAB_COPY-VBELN        = ZVBELNEXTTAB-VBELN.
ZVBELNEXTTAB_COPY-EVBELN       = ZVBELNEXTTAB-EVBELN.
ZVBELNEXTTAB_COPY-FKDAT        = ZVBELNEXTTAB-FKDAT.
ZVBELNEXTTAB_COPY-VBLSTAT      = ZVBELNEXTTAB-VBLSTAT.
ZVBELNEXTTAB_COPY-ZPRN         = ZVBELNEXTTAB-ZPRN.
ZVBELNEXTTAB_COPY-UNAME        = ZVBELNEXTTAB-UNAME.
ZVBELNEXTTAB_COPY-TYPE         = ZVBELNEXTTAB-TYPE.



curr = ZVBELNEXTTAB-EVBELN.
lv_tab = SY-TABIX + 1.
READ TABLE ZVBELNEXTTAB INDEX lv_tab.
next = ZVBELNEXTTAB-EVBELN.

IF curr GT next.
  a = curr - next.
ELSE.
  a = next - curr.
ENDIF.

IF a GT 1.
  curr = curr + 1.
  next = next - 1.

  ZVBELNEXTTAB_COPY-MISSINGFROM   = curr.
  ZVBELNEXTTAB_COPY-MISSINGTO     = next.
ELSE.
  ZVBELNEXTTAB_COPY-MISSINGFROM   = ''.
  ZVBELNEXTTAB_COPY-MISSINGTO     = ''.
ENDIF.



APPEND ZVBELNEXTTAB_COPY.
SORT ZVBELNEXTTAB_COPY BY EVBELN.


ENDLOOP.

ENDFORM.

I still trying to check the duplicate "Form #" column by using 1 dimensional array by looping them.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Ryan Lopez
  • 29
  • 1
  • 8

1 Answers1

1

Use GROUP BY functionality during looping. You wanna extract duplicates based on comparison fields Company code, Plant, Form #, Sales Doc, Billing date, Username.

So you should write something like this:

TYPES tt_vbeln TYPE STANDARD TABLE OF vbeln WITH DEFAULT KEY. 

DATA duplicates TYPE tt_vbeln. 
LOOP AT ZVBELNEXTTAB INTO DATA(zvbeln) 
GROUP BY ( BUKRS = zvbeln-BUKRS
           WERKS = zvbeln-WERKS
           VBELN = zvbeln-VBELN
           EVBELN = zvbeln-EVBELN
           FKDAT = zvbeln-FKDAT
           UNAME = zvbeln-UNAME
           size = GROUP SIZE ) 
ASCENDING REFERENCE INTO DATA(group_ref). 

CHECK group_ref->*-size > 1. "extracting dups
duplicates = VALUE tt_vbeln( BASE duplicates FOR <form_num> IN GROUP group_ref ( <form_num> ) ). 
* setting color 
MODIFY duplicates FROM VALUE tt_vbeln( line_color = 'C410' ) TRANSPORTING line_color WHERE line_color IS INITIAL. 
ENDLOOP.

That allows you to extract sets of duplicated values like this

enter image description here

By the way, in the above sample rows of blue dataset differ in fields Form # and Username, so my GROUP snippet won't actually work on them. You should adjust grouping fields accordingly, for example leave only VBELN field as grouping field.

Beforehand you should add field line_color to your structure where you will put color codes for duplicates datasets.

Good sample of conditional coloring an ALV resides here.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90