on 03-17-2011 5:05 AM
Data is repeating multiple times in table.Below is the code:
data lv_index type sy-tabix .
read table lt_class_overview into ls_class_overview index lv_index.
select kCLASS sKSCHL
into corresponding fields of ls_class_overview
from ( ( KLAH AS k
INNER JOIN SWOR AS s ON kCLINT = sCLINT )
INNER JOIN KSSK AS ks ON sCLINT = ksCLINT
AND ks~OBJEK = ls_bapi_equip_display-EQUIPMENT ) .
APPEND ls_class_overview to lt_class_overview.
delete adjacent duplicates from lt_class_overview.
endselect.
lo_nd_class_overview->bind_table( new_items = lt_class_overview set_initial_elements = abap_true ).
Thanks
Kiran
HI ,
Check whether the table lt_class_overview has duplicate entries even after the DELETE DUPLICATES statement.
Regards,
Aditya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think you can sort the table first according to some field and then delete the duplicates.
sort lt_class_overview by <field name>.
delete adjacent duplicates from lt_class_overview comparing <field name> .
thanks
sarbjeet singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Sarabjeet
With this statement this query is working perfectly.But when i am adding another query then again duplicates are coming
and in second table also.
i have two tables in the view having one context node
Below is the code:
data lv_index type sy-tabix .
read table lt_class_overview into ls_class_overview index lv_index.
select kCLASS sKSCHL
into corresponding fields of ls_class_overview
from ( ( KLAH AS k
INNER JOIN SWOR AS s ON kCLINT = sCLINT
AND s~SPRAS = 'EN' )
INNER JOIN KSSK AS ks ON sCLINT = ksCLINT
AND ks~OBJEK = ls_bapi_equip_display-EQUIPMENT ) .
APPEND ls_class_overview to lt_class_overview.
sort lt_class_overview by CLASS.
delete adjacent duplicates from lt_class_overview comparing CLASS .
endselect.
select ctATBEZ cATWRT
into corresponding fields of ls_class_overview
from ( CABNT AS ct
INNER JOIN CAWN AS c ON ctATINN = cATINN
INNER JOIN KSML AS ks ON cATINN = ksIMERK
INNER JOIN KLAH AS kl ON ksKLART = klKLART
AND kl~CLASS = ls_class_overview-CLASS ).
APPEND ls_class_overview to lt_class_overview.
sort lt_class_overview by ATBEZ.
delete adjacent duplicates from lt_class_overview comparing ATBEZ .
endselect.
*APPEND ls_class_overview to lt_class_overview.
lo_nd_class_overview->bind_table( new_items = lt_class_overview set_initial_elements = abap_true ).
Okay...i Am sorting it by Class and getting relevant results for one entry(for CLASS) but when i am debugging , second query is overwriting the first entry and giving results corresponding to second entry.....so say i am getting 10 values then in first table that entry is repeating 10 times.How to resolve it?
Thanks
Kiran
Hi kiran.,
In the second query instead of populating values to same structure., take one more local structure with the fields u want and sort by the required field and then delete adjacent duplicates., since in the second query u are fetching ATBEZ and ATWRT., there is no CLASS field so when u are sorting by CLASS it doesn't make any sense... thats y u r getting multiple repeated items.,
Reply if u need some more clarifications.,
Thanks & Regards,
Kiran
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.