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

how to avoid duplicates values from alvgird see below code

laxman_sankhla3
Participant
0 Likes
1,705

how to avoid duplicates values from alvgird see below code

in below query docno no is repeated again and again

how i can avoid duplication in this query.

select * into corresponding fields of table itab

from J_1IEXCHDR

inner join J_1IEXCDTL

on J_1IEXCDTLlifnr = J_1IEXCHDRlifnr

where J_1IEXCHDr~status = 'P'.

how to avoid duplicates values from alvgird see below code

in below query docno no is repeated again and again

how i can avoid duplication in this query.

select * into corresponding fields of table itab

from J_1IEXCHDR

inner join J_1IEXCDTL

on J_1IEXCDTLlifnr = J_1IEXCHDRlifnr

where J_1IEXCHDr~status = 'P'.

4 REPLIES 4
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,308

Hi,

There are two options based on your need.

If the entire row of the table is same then you can sort the internal table using SORT . And then delete the duplicate entreis using DELETE ADJACENT DUPLICATES.

Then your ALV Will display only unique rows.

But if only docno fileds has sames values and other fileds have different values you can use the following code to display only one value for the same doc number.

DATA: ls_sort TYPE lvc_s_sort.

DATA: lt_sort TYPE lvc_t_sort.

ls_sort-spos = column position.

ls_sort-fieldname = column fieldname.

ls_sort-group = abap_true.

APPEND ls_sort TO lt_sort.

then pass this to the it_sort import parameter of the ALV's SET_TABLE_FOR_FIRST_DISPLAY method.

Regards,

Sesh

Read only

former_member184495
Active Contributor
0 Likes
1,308

hi,

you can either use SELECT DISTINCT, but better avoid using this if the fields in the query are not a part of index,

hence use DELETE ADJACENT DUPLICATES from the internal table and then pass to ALV,

Cheers,

Aditya.

Read only

Former Member
0 Likes
1,308

Hi Laxman,

after that select statement

select * into corresponding fields of table itab

from J_1IEXCHDR

inner join J_1IEXCDTL

on J_1IEXCDTLlifnr = J_1IEXCHDRlifnr

where J_1IEXCHDr~status = 'P'.

<b>if sy-subrc = 0.

delete adjucent duplicates from itab comparing <field name of itab internal table>

endif.</b>

this will delete your duplicate entries.once you done with this call the alv FM.

<b> call function 'REUSE_ALV_GRID_DISPLAY'</b>

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'IT_USER_COMMAND'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = 'Purchase Order Details'

  • I_GRID_SETTINGS = I_GRID_SETTINGS

is_layout = wa_layout

it_fieldcat = it_fieldcat

  • IT_EXCLUDING = IT_EXCLUDING

  • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

it_sort = it_sort

  • IT_FILTER = IT_FILTER

  • IS_SEL_HIDE = IS_SEL_HIDE

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT = IS_VARIANT

it_events = it_event

  • IT_EVENT_EXIT = IT_EVENT_EXIT

  • IS_PRINT = IS_PRINT

  • IS_REPREP_ID = IS_REPREP_ID

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

  • IT_HYPERLINK = IT_HYPERLINK

  • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

  • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

  • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

  • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

tables

<b> t_outtab = ITAB</b>

exceptions

program_error = 1

others = 2

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

Thanks

Vikranth Khimavath

Read only

Former Member
0 Likes
1,308

hi

good

if you r getting the duplicate value in your alv grid than you can't do anything by the select statement, you have to pass that particular varible through a funtion module which ll return you only single value , and than you can use that value as per your requirement.

thanks

mrutyun^