cancel
Showing results for 
Search instead for 
Did you mean: 

DATA is getting repeated multiple times

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI ,

Check whether the table lt_class_overview has duplicate entries even after the DELETE DUPLICATES statement.

Regards,

Aditya.

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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 ).

gill367
Active Contributor
0 Kudos

In the second query also i guess you need to do th esort and deletion accrding to the Class field.

so there also write the same

sort lt_class_overview by CLASS.

delete adjacent duplicates from lt_class_overview comparing CLASS .

thanks

sarbjeet singh

Former Member
0 Kudos

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

former_member184578
Active Contributor
0 Kudos

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

gill367
Active Contributor
0 Kudos

May be just write the sort and delete adjacent duplicate statements

outside the select query

only once sort them and delete duplicates and then bind it to node.

thanks

sarbjeet singh

Former Member
0 Kudos

Thanks Kiran

With this my first table is not affecting but in second table, still overwriting first entry and fetching results corresponding to second entry only.