Application Development and Automation 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: 
Read only

opening balance report input date range and prctr

Former Member
0 Likes
780

dear gurus,

i have to calculate opening balance where all the transaction before budat-low with respect to belnr from bkpf where

then compare all belnr with bseg's belnr then sum all wrbtr with respect to belnr but it takes lot time ,

report takes lot btime tell me short way

regards

tarun

dear gurus,

i have to calculate opening balance where all the transaction before budat-low with respect to belnr from bkpf where

then compare all belnr with bseg's belnr then sum all wrbtr with respect to belnr but it takes lot time ,

report takes lot btime tell me short way

regards

tarun

4 REPLIES 4
Read only

brad_bohn
Active Contributor
0 Likes
749

Post your code and someone might analyze it for you. Have you traced the code and analyzed the results?

Read only

deepak_dhamat
Active Contributor
0 Likes
749

hi ,

Post your query and parameter declaration

Regards

Deepak.

Read only

0 Likes
749
**********oprn balance**********

* select belnr wrbtrhkont
  SELECT BUDAT BELNR
 INTO CORRESPONDING FIELDS OF TABLE IT_BKPF3
 FROM BKPF
 WHERE  BUDAT  < S_BUDAT-LOW .
*IN S_BUDAT OR  BUDAT



*IN S_BUDAT OR  BUDAT

if S_PRCTR is not initial.


    SELECT   BELNR WRBTR HKONT PRCTR   
         FROM BSEG INTO IT_BSEG FOR ALL ENTRIES IN  IT_BKPF3
        WHERE BELNR = IT_BKPF3-BELNR AND  
                  ( HKONT = '0000031200' OR HKONT = '0000031201'
              OR HKONT = '0000030066' OR   HKONT = '0000060011' 
              OR  HKONT = '0000060012' ) and prctr in S_PRCTR .

    ENDSELECT.
 else.
    SELECT   BELNR WRBTR HKONT PRCTR   
        FROM BSEG INTO IT_BSEG FOR ALL ENTRIES IN  IT_BKPF3
        WHERE BELNR = IT_BKPF3-BELNR AND 
                  ( HKONT = '0000031200' OR HKONT = '0000031201'
            OR HKONT = '0000030066' OR   HKONT = '0000060011'  
            OR  HKONT = '0000060012' ) .

    ENDSELECT.
endif.


  LOOP AT IT_BSEG INTO WA_IT_BSEG WHERE PRCTR EQ IT_FINAL3-PRCTR.


    WA_FINAL3-OBB = WA_IT_BSEG-WRBTR +  WA_FINAL3-OBB.




    AT END OF PRCTR.


      MODIFY IT_FINAL3 FROM WA_FINAL3 TRANSPORTING OBB
             WHERE PRCTR =  WA_IT_BSEG-PRCTR."WA_FINAL1-PRCTR and


      CLEAR : WA_FINAL3-OBB , WA_IT_BSEG-WRBTR.
    ENDAT .





  ENDLOOP.

Edited by: Rob Burbank on Sep 17, 2010 10:01 AM

Read only

0 Likes
749

If you traced that selection, you'll probably find that a table scan is being used on both BKPF and BSEG. Neither SELECT is well-formed - the optimizer can't even go with a bounded range scan on the BKPF~2 index because you haven't supplied the BUKRS or BSTAT fields and then you don't supply the key fields for the BSEG selection. You would be far better off using BSIS/BSAS (or a profit center/period report approach and then filtering out docs that don't meet the BUDAT criteria) - review some of the standard reports in the system. Surely though, your profit center report can be period based and not posting date based?