Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8735

Performance select inside loop

$
0
0

Hi Experts,

I have a tuning program that is causing me some trouble, I am new to tuning so please help me.

Here is my problem :

 

LOOP AT ti_chave_completa.

 

     l_centro_de = ti_chave_completa-rprctr_de.

     l_centro_at = ti_chave_completa-rprctr_ate.

     l_conta_de ti_chave_completa-racct_de.

     l_conta_at ti_chave_completa-racct_ate.


SELECT rprctr racct hsl sgtxt budat refdocnr blart

       FROM glpca

       APPENDING TABLE ti_glpca_docreal

       WHERE kokrs  = p_kokrs

         AND ryear  v_ano_low

         AND ( rprctr  BETWEEN  l_centro_de AND   l_centro_at )

         AND rldnr   c_8a

         AND rvers   '000'

         AND rbukrs  p_bukrs

         AND poper   >= v_mes_low

         AND ( rrcty = c_zero OR rrcty  = c_dois )

         AND ( racct BETWEEN l_conta_de AND l_conta_at ).


***** Then the program does another loop and  select if there is a v_ano_high in the parameters-***********


IF v_ano_low NE v_ano_high.

     IF NOT v_ano_high IS INITIAL.

 

       LOOP AT ti_chave_completa.

 

         l_centro_de = ti_chave_completa-rprctr_de.

         l_centro_at = ti_chave_completa-rprctr_ate.

         l_conta_de ti_chave_completa-racct_de.              "<--Keys

         l_conta_at ti_chave_completa-racct_ate.

 

         SELECT rprctr racct hsl sgtxt budat refdocnr blart

           FROM glpca

           APPENDING TABLE ti_glpca_docreal

           WHERE rldnr   c_8a

             AND ( rrcty = c_zero OR rrcty  = c_dois )

             AND rvers  '000'

             AND ryear  = v_ano_high

             AND poper <= v_mes_high

             AND rbukrs  p_bukrs

             AND ( rprctr  BETWEEN  l_centro_de

             AND   l_centro_at)

             AND kokrs  = p_kokrs

             AND kokrs   p_kokrs

             AND ( racct BETWEEN l_conta_de

             AND l_conta_at).


*****I tried to remove the select from the loop but the ti_chave_completa  keys are causing me problems.

Any suggestion to help solve this would be great.



Viewing all articles
Browse latest Browse all 8735

Trending Articles