Application Development 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: 

Duplicate Values

Former Member
0 Kudos

hi,

i have a view which gives me duplicate values, is there any way to avoid this.

Using programmatically, u can specify distinct, but how do u do the same in view.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi all,

Let me explain u in detail.

i have three tables kna1,knb1 and bsid.

1. The end user would give me the company code and i need to fetch all customer numbers based on company code.

Eg., SG which satisfies 30 customer numbers.

2. I need to pass all 30 customer numbers into table kna1 where it fetches related names,address,postal code etc.,

3. Now comes the third part where the customer number will be passed to table BSID to check whether any open items exist or not. If open items exist, then i need to display only those customer numbers with address postal code.

4. Problem is i am getting duplicate vales cos same customer might have many open items.

4. These can be easily done thru programmatically.

but how do u implement in view.

The key areas are:

kna1 - KUnnr

knb1 - kunnr and bukrs

bsid - kunnr and bukrs

Thanks in advance

8 REPLIES 8

former_member181962
Active Contributor
0 Kudos

Hi Ananda,

I think you must define your join conditions in such a way that there will be no duplicates, if the view has bee created by you. All the key fields of atleast one table must be included in the join conditon.

Regards,

Ravi

Former Member
0 Kudos

Hi,

There should be a key which identifies duplicates while updating through view.

Regards

KER

Former Member
0 Kudos

Hi Anandha,

Is the view is custome view, then in the table joins

pass all the keys.It will feth unique records from the tables.

Hope this will help you.

Thanks&Regards,

Siri.

Kindly Award points if it is useful.

Former Member
0 Kudos

Anandha,

Problem is in the JOIN condition. Post ur JOIN condition for more help.

Thanks

Kam

Former Member
0 Kudos

Hi all,

Let me explain u in detail.

i have three tables kna1,knb1 and bsid.

1. The end user would give me the company code and i need to fetch all customer numbers based on company code.

Eg., SG which satisfies 30 customer numbers.

2. I need to pass all 30 customer numbers into table kna1 where it fetches related names,address,postal code etc.,

3. Now comes the third part where the customer number will be passed to table BSID to check whether any open items exist or not. If open items exist, then i need to display only those customer numbers with address postal code.

4. Problem is i am getting duplicate vales cos same customer might have many open items.

4. These can be easily done thru programmatically.

but how do u implement in view.

The key areas are:

kna1 - KUnnr

knb1 - kunnr and bukrs

bsid - kunnr and bukrs

Thanks in advance

0 Kudos

Hi Anandha,

I think you have two other posts for the same (I could not find them now though).

Any way, you have to implement this using search help exits.

Take a look at the following link which explains search help exits,

http://help.sap.com/saphelp_46c/helpdata/en/cf/21ee52446011d189700000e8322d00/frameset.htm

Also take a look at fm F4IF_SHLP_EXIT_EXAMPLE,

you have to filter out the duplicate entries during 'DISP'.

On another note, see whether you can avoid reading BSID (it is a huge table normally) to determine whether customer has open items. I think if SKFOR in KNKK is not empty that means customer has open items.

NOTE: You can get credit control area KKBER for a company code from T001 and then use it for selecting from KNKK.

This way you will have atmost one record.

Hope this helps..

Sri

Message was edited by: Srikanth Pinnamaneni

Message was edited by: Srikanth Pinnamaneni

Message was edited by: Srikanth Pinnamaneni

Former Member
0 Kudos

hi shrikanth,

Please let me know how to eliminate duplicate entries using function module. I mean how would i get the final internal table or some sort to link it to view.

In case of program, it is easily done,. buyt through this function module, please help me out.

0 Kudos

Hi Anandha,

You will get the entries in table RECORD_TAB. But the table will not be of your structure so first you have to move the table into another table which you define with your output fields and then use a DELETE ADJACENT DUPLICATES statement and then overwrite RECORD_TAB again.

For example,

Let us say you have KUNNR and NAME1 on the display then,

***First declare a table in your exit fm as,

DATA: BEGIN OF t_display OCCURS 0,

kunnr LIKE kna1-kunnr,

name1 LIKE kna1-name1,

END OF t_display.

****Then here

IF CALLCONTROL-STEP = 'DISP'.

LOOP AT record_tab.

t_display = record_tab.

APPEND t_display.

ENDLOOP.

SORT t_display BY kunnr.

DELETE ADJACENT DUPLICATES FROM t_display COMPARING kunnr.

REFRESH record_tab.

LOOP AT t_display.

record_tab = t_display.

APPEND record_tab.

ENDLOOP.

ENDIF.

Hope this helps..

Remember RECORD_TAB is just a sequence of characters and your t_display should exactly reflect all the fields on display..

Sri