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

duplicate records

Former Member
0 Likes
707

hi all,

i had an requirement to develop an alv report and in the output it contains g/l account field it displays the same content 10 times repeatedly and the requirement is at first i had to display only one time and the remaining 9 times it has to display empty.

regards,

karthik

1 ACCEPTED SOLUTION
Read only

PedroGuarita
Active Contributor
0 Likes
679

You can sort those fields and in that way it will only show the content in the first record.

Use structure of type slis_t_sortinfo_alv and when calling the FM use that table.



 data : s_sort   TYPE slis_t_sortinfo_alv.

  l_sort-spos = 1.
  l_sort-fieldname = 'PERNR'.
  l_sort-up = 'X'.
  APPEND l_sort TO s_sort.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-cprog
      i_callback_pf_status_set = 'ALV_ST'
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_top_of_page   = 'TOP_OF_PAGE'
      is_layout                = gs_layout
      it_fieldcat              = gt_fieldcat
      i_background_id          = 'ALV_BACKGROUND'
      it_sort                  = gs_sort
      i_save                   = 'A'
      is_variant               = gs_variant
      it_events                = gt_events
      it_event_exit            = ft_event_exit
    TABLES
      t_outtab                 = t_output[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

You can sort those fields and in that way it will only show the content in the first record.

Use structure of type slis_t_sortinfo_alv and when calling the FM use that table.



 data : s_sort   TYPE slis_t_sortinfo_alv.

  l_sort-spos = 1.
  l_sort-fieldname = 'PERNR'.
  l_sort-up = 'X'.
  APPEND l_sort TO s_sort.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-cprog
      i_callback_pf_status_set = 'ALV_ST'
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_top_of_page   = 'TOP_OF_PAGE'
      is_layout                = gs_layout
      it_fieldcat              = gt_fieldcat
      i_background_id          = 'ALV_BACKGROUND'
      it_sort                  = gs_sort
      i_save                   = 'A'
      is_variant               = gs_variant
      it_events                = gt_events
      it_event_exit            = ft_event_exit
    TABLES
      t_outtab                 = t_output[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

4 REPLIES 4
Read only

PedroGuarita
Active Contributor
0 Likes
680

You can sort those fields and in that way it will only show the content in the first record.

Use structure of type slis_t_sortinfo_alv and when calling the FM use that table.



 data : s_sort   TYPE slis_t_sortinfo_alv.

  l_sort-spos = 1.
  l_sort-fieldname = 'PERNR'.
  l_sort-up = 'X'.
  APPEND l_sort TO s_sort.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-cprog
      i_callback_pf_status_set = 'ALV_ST'
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_top_of_page   = 'TOP_OF_PAGE'
      is_layout                = gs_layout
      it_fieldcat              = gt_fieldcat
      i_background_id          = 'ALV_BACKGROUND'
      it_sort                  = gs_sort
      i_save                   = 'A'
      is_variant               = gs_variant
      it_events                = gt_events
      it_event_exit            = ft_event_exit
    TABLES
      t_outtab                 = t_output[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

Read only

Former Member
0 Likes
679

The user should use a display variant to do this.

Rob

Read only

Former Member
0 Likes
679

Hi,

You can sort your internal table and then can delete the duplicate entries from it. If your business need requires you to insert empty rows then you can probably insert some empty rows in it.

DELETE ADJACENT DUPLICATES FROM ITAB.

Hope this helps.

Thanks,

Samantak.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
679

Why dont you use a hierarchical sequential alv ?

There are lot of examples in SDN.

@Samantak - Inseritng duplicate lines will create problem when user clicks the sort button