SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

cash book report problem very slow



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
pranaypanchbhai
Участник
Участник



Joined: 26 Mar 2010
Posts: 9

PostPosted: Fri Jul 09, 2010 10:24 am    Post subject: cash book report problem very slow Reply with quote

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.

  datefrom = ddate-low.
  dateto = ddate-high.
  if datefrom < dybegin.
*    message e000(zcashbook).
  endif.
  if datefrom > dateto.
    message e001(zcashbook).
  endif.


* 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.

  write : /20(10) 'Totals ', 59(13) ndbtotal, 73(13) ncrtotal.
  nbalance = ndbtotal - ncrtotal.
  write : /1(10) dateto, 20 'Closing Balance'.
  if nbalance > 0.
     write : 73(13) nbalance.
  else.
     nbalance = -1 * nbalance.
     write : 59(13) nbalance.
  endif.

  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.

  write : /10 'BANK / CASH BOOK : ' , accname..
  write : /15 'Profit Center : ', pcenter.
  write : /20 'Period From ', datefrom, 'To ', dateto.
  skip.
  write : /1 sy-datum, 65 'Page No.: ', sy-pagno.
  uline.
  write : /1(10) 'DCNO', 12(35) 'Account Description', 59(13) '  Dr/Receipt', 73(13) '  Cr/Payment'.
  uline.
  skip.
Back to top
View user's profile Send private message
ghost
Специалист
Специалист


Age: 37
Joined: 18 Jan 2008
Posts: 71
Location: Tashkent-Astana-Moscow

PostPosted: Fri Jul 09, 2010 11:35 am    Post subject: Reply with quote

жесть Shocked
_________________
Пользователь не знает, чего он хочет, пока не увидит то, что он получил. (Э. Йодан)
Back to top
View user's profile Send private message Send e-mail Blog
vga
Мастер
Мастер


Age: 170
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Fri Jul 09, 2010 11:57 am    Post subject: Reply with quote

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

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Armann
Модератор
Модератор



Joined: 01 Jan 2008
Posts: 422
Location: Moscow

PostPosted: Fri Jul 09, 2010 12:49 pm    Post subject: Reply with quote

6. Goto 'Tips&Tricks' in tr. SE30 and study it very carefully
Back to top
View user's profile Send private message Blog
Dmitriy
Аналитик
Аналитик


Age: 47
Joined: 14 Nov 2008
Posts: 300
Location: Russia

PostPosted: Fri Jul 09, 2010 9:01 pm    Post subject: Reply with quote

ghost wrote:
жесть Shocked

Да, есть немного.)

_________________
ABAP/4 You
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.