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: 

Performance

Former Member
0 Kudos

Hi Frnds,

I have a program.

in that requirement is like first fetch kdgrp from kotg908 table then..using KDGRP,......fetch knumh from a910 table..

then using knumh fetch kbetr from konp table..

Ihave written coding for the above requirement as below..

SELECT * FROM kotg908 INTO CORRESPONDING FIELDS OF TABLE i_extract_kotg

WHERE kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

zzkonda IN s_cpg AND

kondm IN s_mpg AND

datbi GE sy-datum AND

datab LE sy-datum.

IF sy-subrc = 0.

LOOP AT i_extract_kotg WHERE zzkonda IN s_cpg.

SELECT knumh FROM a910 INTO TABLE i_extract_910

WHERE kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

kdgrp EQ i_extract_kotg AND

datbi GT sy-datum AND

datab LE sy-datum.

IF sy-subrc = 0.

LOOP AT i_extract_910.

SELECT SINGLE kbetr FROM konp INTO i_extract_910-kbetr

WHERE knumh EQ i_extract_910-knumh.

can u suggest a better way as per performance? Plaese..

21 REPLIES 21

Former Member
0 Kudos

1.> If you just want kdgrp , then just select that field instead of select *

2.>LOOP AT i_extract_kotg WHERE zzkonda IN s_cpg.

instead of the above statemnet you can use

loop at i_extract_kotg assigining <fs> (field symbol)

3. I dont knw abt your logic that why u are using select in loop but that can also be avoided

Regards

Bhanu

Former Member
0 Kudos

Hi Dude,

Please avoid the select statement inside the loop instead of Write the Read statement in the loop,

it will give good performence

Regards

Ramakrishna Pathi

0 Kudos

hey how can i write a read statement for the above selction?

can u suggest..?

0 Kudos

Hi Shruthi,

This a sample code try to use the same logic in your program.Performancewise also it will give you better results.

SELECT vbeln

audat

erzet

kunnr

ernam

netwr

knumv

angdt

INTO TABLE it_vbak

FROM vbak

WHERE vbeln IN s_vbeln

AND kunnr IN s_kunnr

AND ernam IN s_ernam.

IF NOT it_vbak IS INITIAL.

SELECT vbeln

posnr

matnr

arktx

matkl

meins

kwmeng

mwsbp

FROM vbap

INTO TABLE it_vbap

FOR ALL ENTRIES IN it_vbak

WHERE vbeln = it_vbak-vbeln.

endif.

Loop at it_vbak into wa_vbak.

Read table it_vbap into wa_vbap with key vbeln = it_vbak-vbeln.

then write the fields what ever you want

endloop.

Thanks,

Sathish

Former Member
0 Kudos

Hi,

define internal table it_extract_kotg with selective fields def.

like data: begin of it_extract_kotg occurs 0,

field1 like table-field1,

;

;

end of it_extract_kotg.

2. Remove * in loop and remove into corresponding fields of by giving fields in sequence as define in internal table.

like select field1 field2 ..........from kotg908 into table it_extract_kotg where

..............................

3. dont use second loop. use select stmt jus like first one but dont forget to give the ref of first internal table by giving for all entries stmt.

like this

select field1 field2...... from a910 into table itab for all entries in it_extract_kotg where

give ref of key fields of first internal table in where condition.

4. now make a final internal table of required fields.

take a loop on first internal table

and read second internal table inside that.

and pass the variable to final table.

enjoy.

regards

vijay

for any further clarification you most welcome.

Former Member
0 Kudos

Hi,

Use for all entries for 2nd and 3rd select query.

SELECT * FROM kotg908 INTO CORRESPONDING FIELDS OF TABLE i_extract_kotg

WHERE kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

zzkonda IN s_cpg AND

kondm IN s_mpg AND

datbi GE sy-datum AND

datab LE sy-datum.

IF sy-subrc = 0.

SELECT knumh FROM a910 INTO TABLE i_extract_910

FOR ALL ENTRIES IN i_extract_kotg WHERE kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

kdgrp EQ i_extract_kotg-kdgrp AND

datbi GT sy-datum AND

datab LE sy-datum.

IF sy-subrc = 0.

SELECT kbetr FROM konp INTO i_extract_910_new

FOR ALL ENTRIES IN i_extract_910

WHERE knumh EQ i_extract_910-knumh.

ENDIF.

ENDIF.

ENDIF.

after this selection use loop and read to read the internal table.

If u do like this performance will be improved...Don't write select queries inside the loop.

0 Kudos

Is there any speficic condition that i should use for

FOR ALL ENTRIES..?

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

hi,

well for all entries is very usefull for fetching multitable data. this stmt gives a high performance where

tables are not well connected through key fields.

so if u wanna high performance in your case, use for all entries.

cheers.....

regards

vijay

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

If u use select query inside the loop, for every record , select query will go and hit database, so performance will be low.

Alternate for the above scenario is, For all entries, it'll hit database only once. so performance will be high.

0 Kudos

Hi,

Sorry, some problem in net. so it was posted multiple times.

Former Member
0 Kudos

Hi,

Try the below code instead of writing the select inside the loop.

SELECT * FROM kotg908 INTO CORRESPONDING FIELDS OF TABLE i_extract_kotg

WHERE kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

zzkonda IN s_cpg AND

kondm IN s_mpg AND

datbi GE sy-datum AND

datab LE sy-datum.

*if not i_extract_kotg[] is intial.*

SELECT knumh FROM a910 INTO TABLE i_extract_910 for all entries in i_extract_kotg

WHERE kdgrp = i_extract_kotg-kdgrp

kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

datbi GT sy-datum AND

datab LE sy-datum.

endif.

Former Member
0 Kudos

Hi,

Use the below code instead of writing select inside the LOOP.

SELECT * FROM kotg908 INTO CORRESPONDING FIELDS OF TABLE i_extract_kotg

WHERE kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

zzkonda IN s_cpg AND

kondm IN s_mpg AND

datbi GE sy-datum AND

datab LE sy-datum.

if not i_extract_kotg[] is intial.

SELECT knumh FROM a910 INTO TABLE i_extract_910 for all entries in i_extract_kotg

WHERE kdgrp = i_extract_kotg-kdgrp

kappl EQ c_sales AND

kschl EQ c_cond_type AND

vkorg EQ p_sorg AND

vtweg EQ p_dich AND

spart EQ p_div AND

datbi GT sy-datum AND

datab LE sy-datum.

endif.

Former Member
0 Kudos

Hi,

If u post a question.. give a message if any answers helps u or solves the problem..

Thanks.