Skip to Content
0
Aug 13, 2020 at 03:12 PM

remove duplicate values in columns in alv output.

337 Views

hi all, i am getting duplicate in alv output .!! plz help me out remove duplicate is not working in my came.. this report takes role name as input give role name tcodes in role and user in role..!

*&---------------------------------------------------------------------*
*& Report ZMANOJ22
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmanoj22.


TYPE-POOLS : slis.


TYPES: BEGIN OF ty_tab,
         agr_name   TYPE  agr_name,
         object     TYPE  agobject,
         field      TYPE  agrfield,
         low        TYPE  agval,
         uname      TYPE  xubname,
         bname      TYPE  bname,
         name_first TYPE  name_first,
         name_last  TYPE  name_last,
       END  OF ty_tab.




DATA: gt_final  TYPE TABLE OF ty_tab.
DATA: gt_fcat    TYPE slis_t_fieldcat_alv,
      wa_fcat    TYPE slis_fieldcat_alv,
      gs_layout  TYPE slis_layout_alv,
      gs_varient TYPE disvariant,
      v_prog     TYPE sy-repid.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_role TYPE agr_name OBLIGATORY.

SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK b1.




START-OF-SELECTION.


  SELECT  agr_1251~agr_name,
          agr_1251~object,
          agr_1251~field,
          agr_1251~low,
          agr_users~uname,
          agr_users~to_dat,
          user_addr~bname,
          user_addr~name_first,
          user_addr~name_last,
          tstct~tcode,
          tstct~ttext,
          tstct~sprsl,
          agr_texts~text
          INTO TABLE @DATA(gt_final2)
          FROM agr_1251 INNER JOIN agr_users ON ( agr_1251~agr_name = agr_users~agr_name )
                        INNER JOIN user_addr ON ( agr_users~uname = user_addr~bname )
                        INNER JOIN tstct     ON ( tstct~tcode = agr_1251~low )
                        INNER JOIN agr_texts ON ( agr_texts~agr_name =  agr_1251~agr_name )
                        WHERE agr_1251~agr_name = @p_role
                        AND object EQ 'S_TCODE'
                        AND field  EQ 'TCD'
                        AND sprsl  EQ 'E'
                        AND line   = ' '.

gt_final[] = gt_final2.
DELETE ADJACENT DUPLICATES FROM  gt_final comparing field object field low uname bname name_first name_last.

  DATA: text(12) TYPE c.
  text = TEXT-002.
  DATA: text1(12) TYPE c.
  text1 = TEXT-003.
  DATA: text2(12) TYPE c.
  text2 = TEXT-004.
  DATA: text3(12) TYPE c.
  text3 = TEXT-005.
  DATA: text4(12) TYPE c.
  text4 = TEXT-006.
  DATA: text5(12) TYPE c.
  text5 = TEXT-007.
  DATA: text6(12) TYPE c.
  text6 = TEXT-008.


  wa_fcat-fieldname = 'AGR_NAME'.
  wa_fcat-ref_tabname = 'AGR_1251'.
  wa_fcat-seltext_m = text.
  wa_fcat-outputlen = '19'.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.


  wa_fcat-fieldname = 'TEXT'.
  wa_fcat-ref_tabname = 'AGR_TEXTS'.
  wa_fcat-seltext_m = text1.
  wa_fcat-outputlen = '22'.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.


  wa_fcat-fieldname = 'LOW'.
  wa_fcat-ref_tabname = 'AGR_1251'.
  wa_fcat-seltext_m = text2.
  wa_fcat-outputlen = '10'.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.


  wa_fcat-fieldname = 'TTEXT'.
  wa_fcat-ref_tabname = 'TSTCT'.
  wa_fcat-seltext_m = text3.
  wa_fcat-outputlen = '25'.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.




  wa_fcat-fieldname = 'UNAME'.
  wa_fcat-ref_tabname = 'AGR_USERS'.
  wa_fcat-seltext_m = text4.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.


  wa_fcat-fieldname = 'NAME_FIRST'.
  wa_fcat-ref_tabname = 'USER_ADDR'.
  wa_fcat-outputlen = '9'.
  wa_fcat-seltext_m = text5.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.


  wa_fcat-fieldname = 'NAME_LAST'.
  wa_fcat-ref_tabname = 'USER_ADDR'.
  wa_fcat-outputlen = '9'.
  wa_fcat-seltext_m = text6.
  APPEND wa_fcat TO gt_fcat.
  CLEAR wa_fcat.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = v_prog
      is_layout          = gs_layout
      it_fieldcat        = gt_fcat
      is_variant         = gs_varient
    TABLES
      t_outtab           = gt_final.

Attachments

rolessss.png (50.2 kB)