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: 

how to select data from cluster table

Former Member
0 Kudos

hi experts,

I have a report which picks data from bseg (cluster table ) for a month report it is taking around 4 minutes to process.I feel it is not good when take the report after some months.

how to select data from these table???how to declare itab for these cluster tables????can we include any search condition or any other kind of internal table???

please advice.

mani

2 REPLIES 2

Former Member
0 Kudos

Hi Manikandan,

The following code may be helpful to understand how to select the data from cluster table.

Types: Begin of ty_kna1,

Kunnr type kna1-kunnr,

adrnr type kna1-adrnr,

end of ty_kna1,

begin of ty_bseg,

belnr type bseg-belnr,

kunnr type bseg-kunnr,

end of ty_bseg,

begin of ty_final,

belnr type bseg-belnr,

kunnr type kna1-kunnr,

adrnr type kna1-adrnr,

end of ty_final.

Data: it_kna1 type table of ty_kna1,

wa_kna1 type ty_kna1,

it_bseg type table of ty_bseg,

wa_bseg type ty_bseg,

it_final type table of ty_final,

wa_final type ty_final.

Select kunnr adrnr from kna1 into table it_kna1 where....

if sy-subrc = 0.

select belnr kunnr into table it_bseg for all entries in it_kna1 where kunnr = it_kna1-kunnr.

endif.

sort it_kna1 by kunnr.

Loop at it_bseg into wa_bseg.

move wa_bseg-belnr to wa_final-belnr.

read table it_kna1 into wa_kna1 with kunnr = wa_bseg-kunnr binary search.

if sy-subrc = 0.

move: wa_kna1-kunnr to wa_final-kunnr,

wa_kna1-belnr to wa_final-belnr.

endif.

append wa_final to it_final.

clear wa_final.

endloop.

Loop at it_final into wa_final.

write: / wa_final-belnr, wa_final-kunnr, wa_final-adrnr.

endloop.

Reward if useful.

Thankyou,

Regards.

Former Member
0 Kudos

U can have your secondary index's on this table, that can help in fast data read.

But try to limit the no. of fields as secondary index.