2010 Sep 16 9:29 PM
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
2010 Sep 16 11:09 PM
Post your code and someone might analyze it for you. Have you traced the code and analyzed the results?
2010 Sep 17 5:45 AM
2010 Sep 17 7:00 AM
**********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
2010 Sep 17 2:56 PM
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?
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |