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

avoiding duplicate record

Former Member
0 Likes
1,288

Hi everyone

i have a report and in that one i have displayed hot pack data i.e. Component,Soft.Component,Level,Support pack,supp.pack type.

i have retrieved this data from the table cvers and cvers_ref.

now i got the output but my requirement is changed now.

i dont want multiple records having same support type.

only one record is required for every support type.

can any suggest me like what condition i have to put in the select statement to avoid duplicate support types please...

its very urgent

12 REPLIES 12
Read only

GauthamV
Active Contributor
0 Likes
1,251

hi,

check this sample code.

do the same for ur program by comparing support type.

SELECT pernr begda werks btrtl orgeh persk plans kostl aedtm

FROM pa0001 INTO CORRESPONDING FIELDS OF

TABLE it_pa0001 FOR ALL ENTRIES IN it_pa0000

WHERE pernr = it_pa0000-pernr AND

aedtm > date1.

SORT it_pa0001 BY pernr aedtm.

DELETE ADJACENT DUPLICATES FROM it_pa0001 COMPARING pernr.

Read only

Former Member
0 Likes
1,251

Hello,

You'll have to check your join condition to avoid the duplicate records.

Or once you've ur internal table use DELETE ADJACENT DUPLICATES by comparing the key.

Reward, if useful.

Rgds,

Raghu.

Read only

Former Member
0 Likes
1,251

It could be done by using

SELECT DISTINCT <supporttypes>

from <table>

into...

where...

groupby <supporttypes>.

Or once the entire data is fetched into internal table. you may sort it by support type and then delete adjacent duplicates comparing support type.

Reward if useful.

Read only

Former Member
0 Likes
1,251

Hi,

Try this...

DELETE ADJACENT DUPLICATES FROM itab COMPARING SUPPORTTYPE(FIELDNAME)

Cheers,

Sai

Edited by: Saikumar on Jun 24, 2008 8:56 AM

Read only

Former Member
0 Likes
1,251

Ravi,

i would suggest as you said you are getting right output but the thing is that you are getting duplicate records.

for getting rid of it dont temper you select statement because if you so so than you might be have to do some more changes in your program.

the simplest solution is that try to use delete adjecent duplicate from itab comapring <support type> at last just before reuse alv fm is called.

Amit.

Read only

Former Member
0 Likes
1,251

Hi,

In Select Condition use UPTO 1 ROW

Regards.

Read only

Former Member
0 Likes
1,251

Hi,

sort the final internal table by the support type.

And then use the delete adjacent duplicates for that internal table.

for eg. sort itab by matnr.

delete adjacent duplicates from itab comparing matnr.

hope this may help you.

thanks

Read only

0 Likes
1,251

i have done the following change but still the same output. please look in to the code and let me know where i have to change

select pcomponent pEXTRELEASE prelease fPATCH f~patch_type

into corresponding fields of table fintab from cvers as p inner join pat03 as f

on pcomponent = faddon_id.

select kdesc_text kcomponent into corresponding fields of table fint from cvers_ref as k inner join cvers as l

on kcomponent = lcomponent where k~LANGU = 'EN'.

sort fintab BY component.

DELETE ADJACENT DUPLICATES FROM fintab COMPARING component.

loop at fintab into wa_ftab.

loop at fint into wa_fint.

write 😕 wa_ftab-component under 'Component', wa_ftab-release under 'SoftComp',wa_ftab-EXTRELEASE under 'Level',

wa_ftab-patch under 'SuppPackType',wa_ftab-patch_type under 'Descrp',

wa_fint-DESC_TEXT under 'SupportPack'.

skip.

endloop.

endloop.

Read only

Former Member
0 Likes
1,251

Hi Ravi,

Its Better you use DISTINCT keyword in select statement.. before the field which you need.

Hope this would be helpful

Regards

Narin Nandivada

Read only

0 Likes
1,251

hi

can anyone modify the select stamt using distinct. i tried but no result.

Read only

Former Member
0 Likes
1,251

Hi Ravi,

you will get your problem solved by using SELECT DISTINCT ... in the Select query.

Reward if find helpful.

all the best.

Anirban Bhattacharjee

Read only

Former Member
0 Likes
1,251

HI,

Try to use SELECT [DISTINCT] <cols> ... WHERE

in your select query.using this the the system excludes duplicate entries.

Hope it would be useful

Regards,

Bhumika