Posted: Fri Jul 09, 2010 10:24 am Post subject: cash book report problem very slow
hiiiiiiiiiii
i have cash book report but it take more time to execute please tell me the how to reduce the execution time i have send my report
plz refer it and reply
Code:
report zcashbook no standard page heading line-size 85 line-count 65.
tables : bkpf, bseg, lfa1,kna1,skat, t001.
data : begin of w_hcbook,
docno type bkpf-belnr,
docdate type bkpf-budat,
pcenter type bseg-prctr,
assn type bseg-zuonr,
orderno type bseg-aufnr,
refno type bkpf-xblnr,
dbamt type bseg-dmbtr,
cramt type bseg-dmbtr,
end of w_hcbook.
data : begin of w_cbook,
docno type bkpf-belnr,
docdate type bkpf-budat,
pcenter type bseg-prctr,
op_acode type bseg-hkont,
name1 type lfa1-name1,
assn type bseg-zuonr,
orderno type bseg-aufnr,
refno type bkpf-xblnr,
stext type bseg-sgtxt,
dbamt type bseg-dmbtr,
cramt type bseg-dmbtr,
runbal type bseg-dmbtr,
end of w_cbook.
data : i_hcbook like w_hcbook occurs 0.
data : i_cbook like w_cbook occurs 0.
data : compname type t001-butxt.
data : orderno type bseg-aufnr.
data : nopen_bal type bseg-dmbtr.
data : ndbtotal type bseg-dmbtr.
data : ncrtotal type bseg-dmbtr.
data : nbalance type bseg-dmbtr.
data : npopenbal type bseg-dmbtr.
data : dybegin type bkpf-budat.
data : currmonth type bkpf-monat.
data : curryear type bkpf-gjahr.
data : datefrom type bkpf-budat.
data : dateto type bkpf-budat.
data : accname type skat-txt50.
* Assumption. : In the beginning of year user will pass the JV to
* distribute balances of
parameter cocode type bkpf-bukrs obligatory.
parameter acccode type bseg-hkont.
parameter pcenter type bseg-prctr.
*PARAMETER FYEAR TYPE BSEG-GJAHR OBLIGATORY.
select-options ddate for bkpf-budat obligatory.
* Calculate begining of finfncial year date.
at selection-screen.
call function 'GET_CURRENT_YEAR'
exporting
bukrs = cocode
date = sy-datum
importing
currm = currmonth
curry = curryear.
* PREVM =
* PREVY =
concatenate curryear '04' '01' into dybegin.
* CALCULATE OPENING BALANCE FOR THE SPECIFIED PROFIT CENTER.
start-of-selection.
if pcenter is not initial.
nopen_bal = 0.
select * from bkpf where bukrs = cocode and budat <= datefrom.
select * from bseg where bukrs = cocode and belnr = bkpf-belnr
and hkont = acccode and prctr = pcenter.
if bseg-shkzg = 'S'.
nopen_bal = nopen_bal + bseg-dmbtr.
else.
nopen_bal = nopen_bal - bseg-dmbtr.
endif.
endselect.
endselect.
else.
nopen_bal = 0.
select * from bkpf where bukrs = cocode and budat < datefrom.
select * from bseg where bukrs = cocode and belnr = bkpf-belnr and hkont = acccode.
if bseg-shkzg = 'S'.
nopen_bal = nopen_bal + bseg-dmbtr.
else.
nopen_bal = nopen_bal - bseg-dmbtr.
endif.
endselect.
endselect.
endif.
* now pick up all transactions for account selected.
select * from bkpf where bukrs = cocode and budat >= datefrom and budat <= dateto order by budat.
select * from bseg where bukrs = cocode and belnr = bkpf-belnr and hkont = acccode.
w_hcbook-docno = bseg-belnr.
w_hcbook-docdate = bkpf-budat.
w_hcbook-pcenter = bseg-prctr.
w_hcbook-orderno = bseg-aufnr.
w_hcbook-refno = bkpf-xblnr.
if bseg-zuonr is not initial.
w_hcbook-assn = bseg-zuonr.
endif.
if bseg-shkzg = 'H'.
w_hcbook-dbamt = bseg-dmbtr.
else.
w_hcbook-cramt = bseg-dmbtr.
endif.
append w_hcbook to i_hcbook.
endselect.
endselect.
* pick up the opposite transaction required to display in report.
loop at i_hcbook into w_hcbook.
select * from bseg where bukrs = cocode and belnr = w_hcbook-docno.
if bseg-aufnr is not initial.
* orderno = bseg-aufnr.
endif.
if bseg-hkont <> acccode.
* append to other internal table.
w_cbook-docno = bseg-belnr.
w_cbook-docdate = w_hcbook-docdate.
w_cbook-pcenter = w_hcbook-pcenter.
w_cbook-orderno = w_hcbook-orderno.
if w_cbook-orderno is initial.
w_cbook-orderno = bseg-aufnr.
endif.
w_cbook-op_acode = bseg-hkont.
w_cbook-stext = bseg-sgtxt.
w_cbook-assn = w_hcbook-assn.
w_cbook-refno = w_hcbook-refno.
if bseg-shkzg = 'H'.
w_cbook-dbamt = bseg-dmbtr.
w_cbook-runbal = w_cbook-runbal + bseg-dmbtr.
else.
w_cbook-cramt = bseg-dmbtr.
w_cbook-runbal = w_cbook-runbal - bseg-dmbtr.
endif.
select single * from skat where saknr = bseg-hkont and spras = 'E' and ktopl = 'CA01'.
w_cbook-name1 = skat-txt50.
if bseg-lifnr is not initial.
select single * from lfa1 where lifnr = bseg-lifnr.
w_cbook-name1 = lfa1-name1.
endif.
if bseg-kunnr is not initial.
select single * from kna1 where kunnr = bseg-kunnr.
w_cbook-name1 = kna1-name1.
endif.
append w_cbook to i_cbook.
clear w_cbook.
endif.
endselect.
endloop.
write : /1(10) datefrom, 12(40) 'Opening Balance'.
if nopen_bal > 0.
write : 59(13) nopen_bal.
else.
npopenbal = nopen_bal * -1.
write : 73(13) npopenbal.
endif.
ndbtotal = 0.
ncrtotal = 0.
if nopen_bal > 0.
ndbtotal = ndbtotal + nopen_bal.
else.
ncrtotal = ncrtotal + npopenbal.
endif.
loop at i_cbook into w_cbook.
write : /1(10) w_cbook-docno, 12(40) w_cbook-name1.
if w_cbook-dbamt <> 0.
write : 59(13) w_cbook-dbamt.
ndbtotal = ndbtotal + w_cbook-dbamt.
else.
write : 73(13) w_cbook-cramt.
ncrtotal = ncrtotal + w_cbook-cramt.
endif.
* modified by Arun Mathur to increase width of assignment to 20
write : /12(14) 'Doc. No. :', (20) w_cbook-assn.
if w_cbook-orderno is not initial.
write : /12 'order No.:', w_cbook-orderno.
endif.
if w_cbook-refno is not initial.
write : /12 'Ref. No.:', w_cbook-refno.
endif.
write : /12(40) w_cbook-stext.
endloop.
uline.
top-of-page.
select single * from t001 where bukrs = cocode.
compname = t001-butxt.
write : /30 compname.
select single * from skat where saknr = acccode and spras = 'E' and ktopl = 'CA01'.
accname = skat-txt50.
Age: 165 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Fri Jul 09, 2010 11:57 am Post subject:
1) rewrite you code for using index table bsis, bsak
2) Use internal table for storing bkpf
3) Use gjahr for join bkpf and bseg
4) Use cashing internal table for lfa1, kna1
5) Use FOR ALL ENTRIES for reading from bseg, if need _________________ Молитва - это запрос разработчику на изменение кода программы.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.