Problem with subroutine- need urgrnt help

hai all,
need help in subroutine.
in a report program,
i had calculated to get the total collection amount and need to generate a list for every day.
on next day that collection amount must come as a poeninig balance at the top of the list.
this i had done using two subroutines.
i have to call the subroutine for opening balance for previous day's collection  first.  after that in have to calculate the todays collection.
how can i have this please give me a suggession.
thanks in advance.
this is my report.
i want the 'Progressive Total C/O ' from subroutine form f002_item_data. of today to be come in
'Progressive Total B/F -
' ,106 w_total_bf.  of  the  subroutine form f001_progressive_total on next day..
here is the code.....
*& Report  ZVR023_COLL_STATEMENT                                       *
report  zvr023_coll_statement           no standard page heading        .
      MODULE. MSD                                              *
      Objective :                                                   *
      Program   : Updates Tables (   )    Downloads data (  )       *
                  Outputs List   ( X  )                             *
      Date Created                                                  *
      Author                                                *
      Location                                                      *
      LDB                .....                                      *
      External Dependencies                                         *
Amendment History                                                  *
Who        Change ID    Reason                                      *
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯                                     *
XXXXXXXXX  AADDMMYYYY Where XXXX = Developers Name................. *
           AA- Developers Initial ................................  *
      Includes                                                      *
*INCLUDE   :                                                           *
      Tables                                                        *
tables   : vbak,bsid,kna1,t001,adrc,vbrk,knvv.
      Types                    Begin with TY_                       *
types : begin of ty_cust,
        belnr type bseg-belnr,
        wrbtr type bseg-wrbtr,
        xref1 type bseg-xref1,
        kunnr type kna1-kunnr, " sarang
        bschl type bseg-bschl,
        hkont type bseg-hkont,
        end of ty_cust.
types : begin of ty_bp,
        kunnr type vbak-kunnr,
        bukrs type bseg-bukrs,
        budat type bkpf-budat,
        end of ty_bp.
types : begin of ty_kna1,
        kunnr type kna1-kunnr,
        name1 type kna1-name1,
        ort01 type kna1-ort01,
        end of ty_kna1.
types   : begin of ty_lst,
          vbeln      type vbrk-vbeln,                          " INVOICE NO
          fkart      type vbrk-fkart,
          posnr      type vbrp-posnr ,
          fkimg      type vbrp-fkimg ,                         " qty
          fkdat      type vbrk-fkdat,                          " date
          vkorg      type vbrk-vkorg,                          " sales org
          vtweg      type vbrk-vtweg,                          " division
          spart      type vbrk-spart,                          " distribution
          knumv      type vbrk-knumv,                          " Number of the document condition
          matnr      type vbrp-matnr ,
          med_prod   type jptmg0-med_prod,
          kunrg      type vbrk-kunrg,
          kwert      type konv-kwert,
          kbetr      type konv-kbetr,
          netwr      type vbrk-netwr,
Address Details
         KUNRG type vbrk-KUNRG,
          name1      type kna1-name1,
          stras      type kna1-stras,
          pstlz      type kna1-pstlz,
***Added For Billing
         bukrs       type vbrk-bukrs,                          " Company code
         xblnr       type vbrk-xblnr,                          " Bill Ref
         ismpublication type mara-ismpublication,
Condition Type
         kschl_zj01  type konv-kschl,
         kschl_zdis  type konv-kschl,
         kschl_znet  type konv-kschl,
         kwert_zj01  type konv-kawrt,                          " Base Condition
         kwert_zdis  type konv-kawrt,
         kwert_znet  type konv-kawrt,
         adrnr  type kna1-adrnr,
         end of ty_lst.
types   : begin of ty_lst1,
          vbeln      type vbrk-vbeln,                          " INVOICE NO
          fkart      type vbrk-fkart,
          fkdat      type vbrk-fkdat,                          " date
          fkimg      type vbrp-fkimg,                          " qty
          kunrg      type vbrk-kunrg,                          " Payer
          fkimg_1    type vbrp-fkimg,                          " qty
          fkimg_2    type vbrp-fkimg,                          " qty
          fkimg_3    type vbrp-fkimg,                          " qty
          fkimg_4    type vbrp-fkimg,                          " qty
          fkimg_5    type vbrp-fkimg,                          " qty
          matnr      type vbrp-matnr,
          med_prod   type jptmg0-med_prod,
          kwert      type konv-kwert,
          kbetr      type konv-kbetr,
          netwr      type vbrk-netwr,
Address Details
        KUNRG      type vbrk-KUNRG,
          name1      type kna1-name1,
          stras      type kna1-stras,
          pstlz      type kna1-pstlz,
***Added For Billing
         bukrs type vbrk-bukrs ,
         xblnr type vbrk-xblnr,
         ismpublication type mara-ismpublication,
****SPLIT FOR RATE
         kbetr_1   type   konv-kbetr,
         kbetr_2   type   konv-kbetr,
         kbetr_3   type   konv-kbetr,
Condition Type
         kschl_zj01 type konv-kschl,
         kschl_zdis type konv-kschl,
         kschl_znet type konv-kschl,
         kwert_zj01 type konv-kawrt,                          " Base Condition
         kwert_zdis type konv-kawrt,
         kwert_znet type konv-kawrt,
         end of ty_lst1.
types   : begin of ty_condition,
          kschl type konv-kschl,                                " Condition Type
          kwert type konv-kwert,                                " Condition Value
          knumv type konv-knumv,                                " Document Condi
          kposn type konv-kposn,
          kbetr type konv-kbetr,                                " Condition Rate
          end of ty_condition.
types : begin of ty_bkpf ,
belnr type bkpf-belnr,
gjahr type bkpf-gjahr,
bukrs type bkpf-bukrs,
end of ty_bkpf.
      Constants                Begin with C_                        *
*CONSTANTS:                                                            *
      Data                     Begin with W_                        *
data     : w_cnt type i .
*DATA     : W_DMBTR  TYPE BSID-DMBTR.   " Open Value
*DATA     : W_KWERT TYPE  VBRP-FKIMG.   " Invoice Value
*DATA     : W_QTY_CON TYPE  VBRP-FKIMG.   " QTY
*DATA     : W_TO_QTY_CON TYPE  VBRP-FKIMG.   " QTY
*DATA     : W_DIFF TYPE  BSID-DMBTR.   " W_DIFF Bt Open & Invoice
*DATA     : W_DMBTR_CR  TYPE BSID-DMBTR.   " Cr Value
*DATA     : W_DMBTR_DR  TYPE BSID-DMBTR.   " Dr Value
*DATA     : W_DMBTR_TO  TYPE BSID-DMBTR.   " Total Value
*DATA :     W_KDGRP(2) .
*DATA  :    W_CNT_IS TYPE I.
*DATA  :    W_CNT_IS1 TYPE I.
*DATA  :    W_CNT_IS2 TYPE I.
*DATA  :    W_CNT_FIRST TYPE I.
*DATA  :    W_CNT_ITAB TYPE I.
*DATA  :    W_CNT_FIRST1(2).
*DATA  :    W_CNT_TAB(62),
          W_CNT_TAB_HEA(62),
*data:           W_CNT_POS TYPE I.
Variable for balance window
data : w_open_bal type dmshb_x8,
       w_total_bf type dmshb_x8,
       w_sub_tot  type dmshb_x8,
       w_total_co type dmshb_x8,
       w_bill_bal type dmshb_x8,
       w_drn_bal type dmshb_x8,
       w_othr_chr type dmshb_x8,
       w_total_bal type dmshb_x8,
       w_coll_bal type dmshb_x8,
       w_unsd_cr  type  dmshb_x8, "Unsold Credit
       w_inceve  type  dmshb_x8, "Incentive
       w_cr_nt   type  dmshb_x8. "Cr Note
data     : w_pos  type bseg-wrbtr.   " Total Value
data     : w_neg  type bseg-wrbtr.   " Total Value
data : w_du_start_date like sy-datum,
       w_du_end_date like sy-datum .
**vARIABLE DEFINED FOR CONSOLIDATED WINDOW
data    : w_prod_cnt type i .
data    : w_prod_ch(2)  .
data    : w_prod_rate type i .
      Infotypes                   ( HR Module Specific)             *
*INFOTYPES :                                                           *
      Internal tables          Begin with IT_                       *
data : it_bp type table of ty_bp with header line,
       it_bp1 type table of ty_bp with header line,
       it_bp2 type table of ty_bp with header line,
       it_bp3 type table of ty_bp with header line,
       it_kna1 type table of ty_kna1 with header line,
       it_cust type table of ty_cust with header line,
       it_cust1 type table of ty_cust with header line,
       it_bkpf type table of ty_bkpf with header line,
       it_cust2 type table of ty_cust with header line,
       it_cust3 type table of ty_cust with header line.
data : it_pos like rfposxext occurs 1 with header line,
it_check like rfposxext occurs 1 with header line,
it_pos_bc1 like rfposxext occurs 1 with header line,
it_pos_bc like rfposxext occurs 1 with header line,
it_pos_nc like rfposxext occurs 1 with header line,
       it_pos1 like rfposxext occurs 1 with header line,
       it_sec like rfposxext occurs 1 with header line.
data : it_bal like rfposxext occurs 1 with header line.
data : w_text(100) type c.
data : w_cnt1(3).
data : l_date like mara-ismpublperiod .
data : p_date1 like  jkpaz-jkpavon.
data : l_day_c(2).
data : l_month_c(2).
data : l_base_yr_c(4).
data : w_text1(100) type c.
data : w_text2(100) type c.
      Field Symbols            Begin with FS_                       *
*FIELD-SYMBOLS:                                                        *
field-symbols:  type ty_condition.
      Insert                                                        *
*INSERT   :                                                            *
      Select Options          Begin with SO_                        *
selection-screen skip 1.
selection-screen:  begin of block b1 with frame title text-001.
select-options  :  so_bukrs for vbrk-bukrs no intervals no-extension obligatory  .
select-options  :  so_kunrg for vbrk-vkorg no intervals no-extension obligatory,
                   so_vkbur for knvv-vkbur no intervals no-extension ,
                   so_fkdat for bsid-budat  no-extension obligatory ,
                   so_bdat1 for bsid-budat  no-display ,
                   so_bdat3 for bsid-budat  no-display ,
                   so_kunnr for kna1-kunnr no-display.
selection-screen:  end of block b1.
      Parameters              Begin with PR_                        *
*PARAMETERS     :                                                      *
selection-screen begin of block b3 with frame title text-003.
parameters pr_3 radiobutton group rad1.
parameters pr_4 radiobutton group rad1.
selection-screen end of block b3.
selection-screen begin of block b2 with frame title text-002.
parameters pr_1 radiobutton group rad.
parameters pr_2 radiobutton group rad.
selection-screen end of block b2.
*INITIALISATION   :
      At selection-screen                                           *
*AT SELECTION-SCREEN.
      S T A R T   O F   S E L E C T I O N                           *
start-of-selection.
  if pr_3 is not initial.
Code commented/added by Praveen on 20.07.2006
   SELECT kunnr INTO CORRESPONDING FIELDS OF TABLE it_bp1 FROM knvv
                                   WHERE vkorg IN so_kunrg
                                     AND kunnr GE '0004000000'
                                     AND kunnr LE '0004999999'.
    select kunnr into corresponding fields of table it_bp1 from knvv
                                    where vkorg in so_kunrg
                                      and aufsd <> '01'
                                      and kunnr ge '0004000000'
                                      and kunnr le '0004999999' .
                                     and
                                     PLTYP ne 'HB'.
*ends here
  endif.
  if pr_4 is not initial.
    clear so_kunnr[].
    clear so_kunnr.
    so_kunnr-sign = 'I'.
    so_kunnr-option = 'BT'.
    so_kunnr-low =  '0001000000'.
    so_kunnr-high = '0001999999'.
    append so_kunnr.
    so_kunnr-sign = 'I'.
    so_kunnr-option = 'BT'.
    so_kunnr-low =  '0002000000'.
    so_kunnr-high = '0002999999'.
    append so_kunnr.
    so_kunnr-sign = 'I'.
    so_kunnr-option = 'BT'.
    so_kunnr-low =  '0007000000'.
    so_kunnr-high = '0007999999'.
    append so_kunnr.
Code commented/added by Praveen on 20.07.2006
    select kunnr into corresponding fields of table it_bp1 from knvv
                                    where vkorg in so_kunrg and
                                        kunnr in so_kunnr and
                                        vkbur in so_vkbur.
                                   AND kunnr GE '0001000000'
                                   AND kunnr LE '0001999999'   .
    select kunnr into corresponding fields of table it_bp1 from knvv
                                       where vkorg in so_kunrg and
                                           aufsd <> '01' and
                                           kunnr in so_kunnr and
                                           vkbur in so_vkbur.
                                   AND kunnr GE '0001000000'
                                   AND kunnr LE '0001999999'   .
ends here
  endif.
  if pr_1 = 'X'.
    perform cust_prog.
    perform cust_line.
    perform f001_progressive_total.
    perform f002_item_data.
  elseif pr_2 = 'X'.
    perform cust_line.
    perform f002_item_data.
  endif.
*&      Form  cust_prog
      text
form cust_prog.
  clear it_bp3[].
  p_date1 = so_fkdat-low.
  call function 'Z_VF053_DATE_GET_YEAR_MONTH'
    exporting
      i_date  = p_date1
    importing
      e_dd    = l_day_c
      e_month = l_month_c
      e_year  = l_base_yr_c.
  ranges so_bdat2 for bsid-budat.
  clear : so_bdat3[].
  if l_day_c > 01.
    l_day_c = '01'.
    concatenate   l_base_yr_c l_month_c l_day_c     into l_date.
    so_bdat2-low = l_date.
    so_bdat2-high = so_fkdat-low - 1.
  else.
    so_bdat2-low = '00000000'.
    so_bdat2-high = '00000000'.
  endif.
  so_bdat2-sign = 'I'.
  so_bdat2-option = 'BT'.
  append so_bdat2 to so_bdat3.
  select kunnr bukrs budat into corresponding fields of table it_bp3 from bsid
                                     for all entries in it_bp1
                                     where bukrs in so_bukrs
                                       and kunnr = it_bp1-kunnr
                                       and budat in so_bdat3.
select kunnr bukrs budat
appending corresponding fields of table it_bp3
from bsad
for all entries in it_bp1
where bukrs in so_bukrs
and kunnr = it_bp1-kunnr
and budat in so_bdat3.
  sort it_bp3 by kunnr .
  delete adjacent duplicates from it_bp3 comparing kunnr.
  sort it_bp3 by kunnr .
  clear w_total_bf.
endform.                    "cust_prog
*&      Form  cust_line
      text
form cust_line.
  clear it_bp[].
  select kunnr bukrs budat
  into corresponding fields of table it_bp
  from bsid
  for all entries in it_bp1
  where bukrs in so_bukrs
  and kunnr = it_bp1-kunnr
  and budat in so_fkdat.
  select kunnr bukrs budat
  appending corresponding fields of table it_bp
  from bsad
  for all entries in it_bp1
  where bukrs in so_bukrs
  and kunnr = it_bp1-kunnr
  And budat in so_fkdat.
  sort it_bp by kunnr .
  delete adjacent duplicates from it_bp comparing kunnr.
  sort it_bp by kunnr .
endform.                    "cust_line
*&      Form  f001_progressive_total
      text
form f001_progressive_total.
  if not it_bp3[] is initial.
    clear : w_text ,w_cnt,p_date1,l_base_yr_c, l_month_c,l_day_c,l_date.
   w_cnt1 = sy-tabix .
   CONCATENATE w_cnt1 '  Feaching Data  '  INTO w_text.
   CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
     EXPORTING
       text = w_text.
    ranges so_bdat2 for bsid-bldat.
    clear : so_bdat1[].
    p_date1 = so_fkdat-low.
    call function 'Z_VF053_DATE_GET_YEAR_MONTH'
      exporting
        i_date  = p_date1
      importing
        e_dd    = l_day_c
        e_month = l_month_c
        e_year  = l_base_yr_c.
    if l_day_c > 01.
      l_day_c = '01'.
      concatenate   l_base_yr_c l_month_c l_day_c     into l_date.
      so_bdat2-low = l_date.
      so_bdat2-high = so_fkdat-low - 1.
    else.
      l_day_c = so_fkdat-low.
      so_bdat2-low = l_date.
      so_bdat2-high = '00000000'.
    endif.
    so_bdat2-sign = 'I'.
    so_bdat2-option = 'BT'.
    append so_bdat2 to so_bdat1.
    export so_bdat1 to memory id 'DATE1'.
    export it_bp3 to memory id 'IT_BP3'.
    clear : so_bdat1, it_bp3.
    submit  z_rfitemar1
            with x_aisel = 'X'
            with x_norm = 'X'
            with dd_bukrs-low = so_bukrs-low                "#EC *
            and return.
    clear : it_pos[], it_pos .
    import it_pos from memory id 'zit_pos'.
    free memory id 'zit_pos'.
    delete it_pos where blart <> 'DZ'.
Here Plz Clear all the varible to avoid overlap
    clear : w_open_bal,w_du_start_date,w_du_end_date.
    select belnr bukrs gjahr into corresponding fields of table it_bkpf
    from bkpf  for all entries in it_pos where belnr = it_pos-belnr and gjahr = it_pos-gjahr
and bukrs = it_pos-bukrs and xreversal = ' '.
endif.
    loop at it_pos.
      clear it_bkpf.
      read table it_bkpf with key bukrs = it_pos-bukrs belnr = it_pos-belnr gjahr = it_pos-gjahr.
      if sy-subrc eq 0.
        append it_pos to it_check.
      endif.
    endloop.
    it_pos[] = it_check[].
***opening bal
since runtime error is coming while summing the alternate way is being used ... done by jayakumar on 11 10 06
   LOOP AT it_pos .
     SUM .
     w_open_bal = it_pos-dmshb .
     EXIT .
   ENDLOOP .
    loop at it_pos .
   read table it_cust3 with key belnr = it_pos-belnr.
   it_pos-dmshb = it_cust3-wrbtr.
      w_open_bal = w_open_bal + it_pos-dmshb .
    endloop .
    if w_open_bal < 0 .
      w_open_bal = w_open_bal * -1.
    endif.
    w_total_bf = w_total_bf + w_open_bal.
endif.
  write :20 'Progressive Total B/F -
' ,106 w_total_bf.
  skip 1 .
endform.                    "f001_progressive_total
*&      Form  f002_item_data
      text
form f002_item_data.
  if not it_bp[] is initial.
    select * into corresponding fields of table it_kna1 from kna1
                          for all entries in it_bp
                          where kunnr = it_bp-kunnr .
    export so_fkdat to memory id 'DATE'.
    export it_bp to memory id 'IT_BP'.
    clear : so_fkdat, it_bp.
    submit  z_rfitemar1
            with x_aisel = 'X'
            with x_norm = 'X'
            with dd_bukrs-low = so_bukrs-low                "#EC *
            and return.
   DELETE it_pos WHERE u_xreversal <> ' '.
    clear : it_pos[], it_pos .
    import it_pos from memory id 'zit_pos'.
    free memory id 'zit_pos'.
    delete it_pos where blart <> 'DZ'.
    sort it_pos by belnr.
   APPEND LINES OF it_pos TO it_pos1.
   DELETE ADJACENT DUPLICATES FROM it_pos COMPARING belnr." commented by sarang
    clear : it_cust[], it_cust.
    if not it_pos[] is initial.
      select belnr wrbtr xref1 kunnr bschl 
      into corresponding fields of table it_cust
      from bseg
      for all entries in it_pos
      where belnr = it_pos-belnr
      and bukrs = it_pos-bukrs
      and gjahr = it_pos-gjahr
      and bschl in ('15','40') . 
     it_cust2[] = it_cust[].
      delete it_cust where bschl ne 15.
      delete it_cust2 where bschl ne 40.
      sort it_pos by konto.
    else.
      write : 20 '**No Transaction to Display**'.
    endif.
   DELETE it_pos WHERE u_xreversal = 'X'.
    tables bkpf.
    loop at it_pos.
      select single  * from bkpf where belnr = it_pos-belnr and bukrs = it_pos-bukrs and gjahr = it_pos-gjahr and xreversal = ' '.
      if sy-subrc = 0.
        append it_pos to it_pos_bc1.
      endif.
    endloop.
    clear it_pos.
    it_pos[] = it_pos_bc1[].
    sort it_pos by konto belnr xref3.
    loop at it_pos.
      read table it_cust2 with key belnr = it_pos-belnr.
      on change of it_pos-konto or "IT_CUST2-xref1 or
      it_pos-belnr.
        it_pos_bc[] = it_pos[].
        delete it_pos_bc[] where konto ne it_pos-konto.
        delete it_pos_bc[] where belnr ne it_pos-belnr.
        loop at it_pos_bc.
          sum.
          exit.
        endloop.
        append it_pos_bc to it_pos_nc.
      endon.
    endloop.
    free it_pos.
    it_pos[] = it_pos_nc[].
    data : w_amt1 type bseg-dmbtr,
          w_amt2 type bseg-dmbtr.
    clear : w_amt1 , w_amt2.
    sort it_pos by budat belnr konto.
    data : w_ch(5) type c,
           w_i type i.
    w_i = 0.
    loop at it_pos where shkzg = 'H' .
      clear w_text.
      w_i = w_i + 1 .
      w_ch = w_i.
      read table it_cust with key belnr = it_pos-belnr  kunnr = it_pos-konto.
      read table it_kna1 with key kunnr = it_pos-konto .
     CONCATENATE it_kna1-name1 INTO w_text.
      w_text = it_kna1-name1.
     CONDENSE w_text NO-GAPS.
      write : / w_ch left-justified  , 07 it_pos-budat ,20 it_pos-belnr(10) ,31 it_pos-konto(10),42 w_text(60).
      read table it_cust2 with key belnr = it_pos-belnr.
      if it_cust2-xref1 = 'Cash Payment' or it_cust2-xref1 = 'Cash'.
        if it_pos-dmshb < 0 .
         it_pos-dmshb = it_pos-dmshb * -1 .
          it_pos-dmshb = it_cust2-wrbtr.
        else.                              "+PM28072006
         it_pos-dmshb = it_pos-dmshb * -1 . "+PM28072006
          it_pos-dmshb = it_cust2-wrbtr.
        endif.
        write : 72 it_pos-dmshb.
        w_amt1 = w_amt1 + it_pos-dmshb.
      else.
        if it_pos-dmshb < 0 .
         it_pos-dmshb = it_pos-dmshb * -1 .
           it_pos-dmshb = it_cust2-wrbtr.
        else.                            "+PM28072006
         it_pos-dmshb = it_pos-dmshb * -1."+PM28072006
          it_pos-dmshb = it_cust2-wrbtr.
        endif.
        write : 87  it_pos-dmshb.
        w_amt2 = w_amt2 + it_pos-dmshb.
      endif .
    endloop .
  else.
    write : 20 '**No Transaction to Display**'.
  endif.
  clear : it_cust1[] ,w_pos .
  it_cust1[] = it_cust[] .
  sort it_cust1 by wrbtr.
  delete it_cust1 where xref1 <> 'Cash Payment' .
  delete it_cust1 where xref1 <> 'Cash' .
  loop at it_cust1.
    sum .
    w_pos = it_cust1-wrbtr .
    exit .
  endloop .
  clear :it_cust1[],w_neg .
  it_cust1[] = it_cust[] .
  sort it_cust1 by wrbtr.
  delete it_cust1 where xref1 = 'Cash Payment' .
  delete it_cust1 where xref1 = 'Cash' .
  loop at it_cust1.
    sum .
    w_neg = it_cust1-wrbtr .
    exit .
  endloop .
  if w_pos < 0.
    w_pos = w_pos * -1 .
  else.                 "+PM28072006
    w_pos = w_pos * -1. "+PM28072006
  endif.
  if w_neg < 0.
    w_neg = w_neg * -1 .
  else.                 "+PM28072006
    w_neg = w_neg * -1. "+PM28072006
  endif.
  write sy-uline(125) .
  write : /20 'Total Collection Amount -
>'.
  write : 76 w_amt1 ,91 w_amt2.
  w_sub_tot = w_amt1 + w_amt2.
  if w_sub_tot < 0.
    w_sub_tot = w_sub_tot * -1.
  endif.
  write : 106 w_sub_tot.
  if pr_1 = 'X'.
    w_total_co = w_total_bf + w_sub_tot.
    if w_total_co < 0.
      w_total_co = w_total_co * -1.
    endif.
    write : /20 'Progressive Total C/O -
>'.
    write : 106 w_total_co.
  endif.
  write sy-uline(125) .
endform.                    "f002_item_data
     ENDIF .
*END-OF-SELECTION.
      E N D       O F   S E L E C T I O N                           *
      At line selection                                             *
*AT LINE-SELECTION.
      User Command Processing                                       *
*AT USER-COMMAND.
      Top Of Page                                                   *
top-of-page.
  select single * from t001 where bukrs = so_bukrs-low .
  select single * from adrc where addrnumber = t001-adrnr . "EC *
  write : /05  t001-butxt.
CONCATENATE adrc-house_num1 '-' adrc-street INTO w_text1.
CONCATENATE adrc-city1 '-' adrc-post_code1 INTO w_text2.
WRITE : /05  w_text1 .
WRITE : /05  w_text2 .
  write : /05  'Sales Organisation:', so_kunrg-low.
  write : /05  'Sales Office:', so_vkbur-low.
  skip 1.
  if pr_3 = 'X'.
    write : /05 'Agent Circulation Collection Statement From ' , so_fkdat-low , ' to ' ,so_fkdat-high .
  else.
    write : /05 'Advertisement  Collection Statement From ' , so_fkdat-low , ' to ' ,so_fkdat-high .
  endif.
  if pr_3 = 'X'.
    write  :/ sy-uline(125) .
    write :/07 'Date' ,20 'Doc No',31 'Code' ,42 'Agent Name & Place',84 'BY CASH' ,97 'BY CHQ/DD' ,115 'Prog. Total'.
    write  :/ sy-uline(125) .
  else.
   write  :/ sy-uline(125) .
   write :/07 'Date' ,20 'Doc No',31 'Code' ,42 'Advertisers Name' ,  84 'BY CASH' ,97 'BY CHQ/DD' ,115 'Prog. Total'.
   write  :/ sy-uline(125) .
  endif .
      End Of Page                                                   *
END-OF-PAGE.END-OF-PAGE.

Hello Selvi
There is no need to use two subroutine. Actually, this would be bad programming. Instead use a switch for your subroutine which determines whether the calculation should be done for the actual and the previous day, e.g.:
PERFORM do_calculation
                                 USING 'X'          " 'X' = calculate for previous day as well
                                 USING p_date   " current date
                          CHANGING gt_list.   " itab with list data
And that's how the subroutine could look like:
FORM do_calculation
                         USING VALUE(ud_calculate_previous_day)  TYPE c
                                    VALUE(ud_date)                             TYPE d
                  CHANGING ct_list    TYPE <table type>.
* define local data
  DATA:
     ld_date_prev  TYPE d,
     lt_list_prev     TYPE <table type>.  " list for previous day
* Do the calculations for the current day
  IF ( ud_calculate_previous_day = 'X' ).
    ld_date_prev = ud_date - 1.
    PERFORM do_calculation
                                     USING ' '  " ' ' = no calculation for previous day
                                                ld_date_prev
                              CHANGING lt_list_prev.   " itab with list data
  ENDIF.
* Post-processing after calculation for both days
ENDFORM.
Regards
  Uwe

Similar Messages

  • HT5622 I have reset my iPhone, but later I could not activate it, it's not accepting my ID / Password. I restored it but still having the same problem. I need your help. Thank you.

    I have reset my iPhone, but later I could not activate it, it's not accepting my ID / Password. I restored it but still having the same problem. I need your help. Thank you.

    Try making a new Apple ID? I don't really understand what you mean.. Make a new apple ID, log in with that one and then when you are on your phone log out of it and THEN log in our old ID? If you still can't log in the old one then it's most probably a bug or something.. Anyway.. Good luck with your problem!!

  • Having problem buying online.need your help since it's my first time here.apple is asking for my billing address but when i enter my address here in qatar,it's saying i should enter a valid zip code within the u.s.does it mean i can't buy online

    having problem buying online.need your help since it's my first time here.apple is asking for my billing address but when i enter my address here in qatar,it's saying i should enter a valid zip code within the u.s.does it mean i can't buy online even if it wil be shipped within u.s. only?

    To buy in for delivery in Qatar, you should be starting from the Apple Qatar site:
    http://www.apple.com/qa/
    Do you have an Apple-ID? if you do, then you should not have to enter your Address again, and may be able to sidestep the US Zip Code issue.

  • Encore CS4 (version 4.0.0.258) will not finish burning to blu-ray disc when using a menu template.  DVD burning works fine.  Anyone know the problem with blu-ray?  HELP!

    Encore CS4 (version 4.0.0.258) will not finish burning to blu-ray disc when using a menu template.   DVD burning works fine with menu template.  Anyone know the problem with blu-ray?  HELP!

    For CS4 you must update the Roxio component, especially with Win8
    http://forums.adobe.com/thread/1309029 http://docs.roxio.com/patches/pxengine4_18_16a.zip
    http://corel.force.com/roxio/articles/en_US/Master_Article/000012592-PX-Engine-Description -and-Download

  • HT201210 I tried to update to IPad 5.1, but when it finished and tried to restore the backup, it shows me that Itunes could not back up because a session could not be started with iPad. need your help please

    I tried to update to IPad 5.1, but when it finished and tried to restore the backup, it shows me that Itunes could not back up because a session could not be started with iPad. need your help please

    This has happened to me a couple of times and what I do is quit iTunes and restart my Mac and then try again and then it will work.
    If iTunes has already created the backup, you should still be able to restore from the backup when you are connected to iTunes. Right click on the iPad name on the left side of iTunes and select restore from backup. After the process completes, sync with iTunes to transfer all of your apps, music, photos and other media back onto the iPad.

  • Problems with my new E5, help needed

    I just got me a new E5 about a week ago.  Despite reading a lot on this forum, I still have two major issues setting up this device; so I need some help.  Problem number one is that I cannot set up my email.  I have "aol" email that falls under "other" in the email set up section. Some of the screens listed in Pool of Knowledge subsection (like choosing POP3 or IMAP) does not even come up in my e5 during email setup screens. What to do to set up aol email account.
    Problem number 2 is that I cannot transfer my contacts and other data from old device (Nokia X2-01) to the new e5. I paired them easily using Bluetooth but when it get to the point of transferring the data, I hear a "click" sound in the e5 and "Bluetooth disconnected.... " error message comes on. I have tried upteenth times but I get the same result. When I tried to transfer contacts one by one, using Bluetooth business card option it works; but I have over 800 contacts and I would like to use the switch route.  What to do to solve this problem?.  I hope I do not have a faulty device.
    With God, all things are possible

    I can't help you with the contacts problem, but have you made any progress with email? Just because you pick the Other category, doesn't mean you need to enter every server detail. I use Earthlink email, but simply typing my email address causes the wizard to fill in every other detail besides my password. (Curiously, it always uses the wrong SMTP server.) But once setup finishes, I can change any of the settings. I hope that helps. (And BTW, the above may not apply if you opt for using Nokia's push service.)

  • Serious problem with database need help

    hello experts
    i am working with MS-ACCESS and connecting it with java programing
    now the problem with me are
    according to my need i have to create a table that contain Autonumber field
    but when i insert element in this table by query
    String query1 = "insert into Forum (Subject,Author,Date,Reply) values('"+param1+"','"+username+"','"+dateformat+"',"+reply+")";
    st1 = con1.createStatement(); it gives sql exception but when i remove
    autonumber field and make it simple field it works ok but i want to keep autonumber field and thn want to insert it
    is it possible to create a dynamic table in ms-access through java query like
    String query3 = "create table"+"topicId"+"( message varchar(1000) NOT NULL,author varchar(50) NOT NULL, date varchar(30) NOT NULL)";
    here topic id some variable that contain table name
    i think problem is that MS-ACCESS has no varchar data type plz help me
    The complete code i written is as follow
    <html>
    <%@ page language="java" import="java.sql.*,java.text.*"  %>
    <head>
    <title> Processing the post request </title>
    </head>
    <body background ="images/modbkgnd.jpg" bgproperties="fixed" >
    <%
       String param1="",param2="",topicId="";
       Connection con1=null;
       Statement  st1=null;
       ResultSet rs1=null;
       int a=2,reply=0;
       java.util.Date date = new java.util.Date();
       DateFormat df ;
       df = DateFormat.getDateInstance(DateFormat.FULL ,java.util.Locale.UK);
       String dateformat = df.format(date);
       String username = (String)session.getAttribute("forumlogin");
       param1=request.getParameter("Subject");
       param2 =request.getParameter("message");
    try
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       con1 = DriverManager.getConnection("jdbc:odbc:lingua");
       String query1 = "insert into Forum (Subject,Author,Date,Reply) values('"+param1+"','"+username+"','"+dateformat+"',"+reply+")";
       st1 = con1.createStatement();
       out.print("hello i am here");
       boolean posubject = st1.execute(query1);
       out.print("hello i am here");
       String query2 = "select *from Forum";
       rs1 = st1.executeQuery(query2); //retriving table id for creating
        out.print("hello i am here");  //  message table
       while(rs1.next())
           topicId = rs1.getString(1);
       String query3 = "create table"+"topicId"+"( message varchar(1000) NOT NULL,author varchar(50) NOT NULL, date varchar(30) NOT NULL)";
       boolean createtable = st1.execute(query3);
       out.print("hello i am here");
       if(createtable)
          String query4 = "insert into"+"topicId"+"values('"+param2+"','"+username+"','"+dateformat+"')";
          boolean insertmess = st1.execute(query4);
    }catch(SQLException ex){
        out.print("sql exception");
    finally
       st1.close();
       con1.close();
    %>
    </body>
    </html>

    hello experts
    first i change my Date to date and thn try but it was not working.
    and thn i try as dinesh_tcs said
    i change my query as
    String query3 = "create table"+"topicId"+"( message string NOT NULL,author string NOT NULL, date string NOT NULL)";
    but nothing help me
    one more thing actually i don,t want to insert manually the field of autonumber what i want that my query work when i leave the autonumber field to insert values in the table ( or whatever way i want to insert values in that table by keeping autonuber given by MS_ACCESS)
    plz do the change in code i have maintained above or if not possible thn write the query that u have tested

  • Airport Express problem with iMac G5 iSight - help needed!

    I bought an Airport Express (AX) last week, upgraded my OS to Leopard and installed Airport Utility fine. I could join my existing wireless network and everything worked fine for streaming itunes through my stereo. But this week Airport Utility has stopped being able to find the AX and I can't work out why - really need some help! Its in the same place as last week, close to the computer, and I tried another location right next to the Imac but didn't work. When I restore factory settings Airport Utility does recognise the device, and allows me to update settings for wirelessly connecting to my existing wireless network, so the light on the AX is solid green. But then AU again says it cannot find any AX wireless device. Can anyone tell me what I'm doing wrong???

    Hi I'm still battling with this - have connected the AX to my Imac via ethernet and it shows up fine in Airport Utility. Status light is green and it says its set up to connect to my existing wireless network using wireless connection. Security in Network Preferences is the same for both: WPA2 Personal.
    So I don't think there's a problem with the AX, and my current wireless network (BT Home Hub) is working fine.
    And when I restore factory settings Airport Utility can see the AX before updating settings so the wireless side of AX must work too.
    I'm figuring it must be something about the settings that mean AU can't see it anymore. But I can't work out what, since security is the same.
    Any ideas would be great!

  • Problem with tables -- need help!

    I am having problems with table formatting, when using
    Preformatted text. The tables look fine in the WYSIWYG editor, but
    have lots of extra space above and below the text when looking at
    the output files.
    I will attach the code from one of the HTML files from my
    project, so you can see what I'm talking about.
    Thanks.

    Well, if you're talking about the single-celled table with
    the line:
    <p class=Preformatted>[assembly:
    Ace.AceAssembly]</p>
    </pre>
    ... you can eliminate the <P> tags. that will give you
    one line less. Otherwise, your remaining space is the result of the
    <PRE> tag. It, like the <XMP> tag, gives it one line of
    space beneath as well.
    Your alternative beyond that would be to, when needed, wrap
    up the script in Javascript. That line, for instance, wouldn't need
    it.

  • Problem with ichat, need help reinstalling.

    Hey guys, I'm new to mac so I need a little help.
    I did something last night to my comp and I'm not sure what it was. But when I click on the iChat icon it just comes up with a ? I search in spotlight and it's not there. I must have deleted it while getting rid of some other things. I don't have time machine and I need some help reinstalling. When I bought the mac it had Tiger and I still have those disc, but right now I have upgraded to Leopard. Where can I find iChat to reinstall? I looked on the iLife section of the Tiger discs but I couldn't find it. Any info will help.
    Thanks

    update
    I downloaded pacifist and got ichat to reinstall from my Tiger 10.4.9 disc, however, now when I try to open iChat it says, You cannot use the application “iChat” with this version of Mac OS X. I have leopard 10.5.2. Does anyone know how to update the version I have? I use the mac updater but it doesn't find anything.

  • Problem with sysdba need help

    I faced a difficult problem with sysdba. The thing is, I don't have a user name " 1/2@3 ". But the moment I connected as 1/2@3 as sysdba, then it connected automatically and to utter surprise I could drop a user.
    If it is so, then how the database will remain secure.
    Definitely there is a solution and I need it urgently.

    Hi
    c:\> sqlplus "/ as sysdba"
    After logging into SQL, check the username using:
    SQL> Show user
    If the above command returns "sys", change the password of the user "sys" using:
    SQL> Alter user sys identified by "yourpassword";
    Thank You

  • Big problems with IMac-need help

    I have an older model iMac G5 that my daughter has been using on week-ends when she comes home from the local college. She said that she was having a lot of problems with Safari quitting, getting weird messages with MS Office and kernel panics. I decided that the best thing to do would be to erase and install Leopard. During the installation process I got a message that Leopard could not install due to a problem with the base system. I then tried to install from the restore discs (which were backups that I had on hand since I couldn't find the originals) and from a Tiger install disc. I got errors each time. Now there was no longer an operating system on the iMac. I took it to the local genius bar. The genius seemed kind of frazzled since he was helping several people, but he seemed sure that it was the hard drive because of the kernel panics and the fact that he couldn't install anything onto the computer from an external firewire drive.
    I purchased a new hard drive from Amazon and a friend who is very knowledgeable about these things installed it for me. We still couldn't install an operating system. We then installed it using Target Mode by putting the Tiger DVD on a Powerbook. I then proceeded with Software Update. I had no problems with applications like iTunes and DVD player. However, whenever I tried to upgrade the operating system I got this message "The digital signature for this package is incorrect. The package may have been tampered with or corrupted since being signed by "Apple". I used Disc Utility with the Tiger DVD and it showed no problems.
    So, there is obviously something really wrong. I have no idea what it is. Any ideas out there? Should I take the iMac back to the genius bar? I don't want to spend a lot more money on it, since it is just used on week-ends when my daughter is home. Thanks.

    It could be any of those things, but likely is the motherboard. Take it in and have Apple look at it.
    Let us know what they say, please.

  • Problems with an exercise with java, need fast help

    hi
    I have a problem with an exercise. You have to make a circle and buttons with left, right, under, above, leftabove, leftunder, rightabove, rightunder. Everytime you click on a button, the circle has to move a little bit to that side.
    I have already the left en the right, but with the others I don't no what to do.
    Can somebody help me please.

    LOL @ Sscotties... :o)
    To the OP:
    How To Ask Questions The Smart Way

  • Select distinct problem with muliple join tables, help needed

    Hi,
    I have two main tables. Each has its of sub joined tables.
    guest_id_for_reservation connects two major tables. This has
    to be that way
    because my guest may change the room status from single to
    double (and the
    similar exceptional requests).
    guests reservation
    guest_id_for_reservation
    countrytable hoteltable
    delegationtable roomtype
    I form a query. I want to select distinct those results. But
    it does not
    work.
    If I do not include any table related to reservation table
    and its sub
    joined tables (disregarding guest_id_for_reservation), it
    works.
    Is there a specific syntax for select distinct of this type
    or any
    workaround.?
    Thank you
    Hakan

    Hi I'm still battling with this - have connected the AX to my Imac via ethernet and it shows up fine in Airport Utility. Status light is green and it says its set up to connect to my existing wireless network using wireless connection. Security in Network Preferences is the same for both: WPA2 Personal.
    So I don't think there's a problem with the AX, and my current wireless network (BT Home Hub) is working fine.
    And when I restore factory settings Airport Utility can see the AX before updating settings so the wireless side of AX must work too.
    I'm figuring it must be something about the settings that mean AU can't see it anymore. But I can't work out what, since security is the same.
    Any ideas would be great!

  • Problem with a Servlet - URGENT help

    Hello
    i really need your help. here i uploaded my web project: http://www.2shared.com/file/4450238/aaa4d9cd/JMSTest.html
    it's about 2 servlets, one Test servlet sending a message, and another one, Receiver, to receive the message sent via JMS (i use ActiveMQ)
    i didn't know what's wrong, if i call http://localhost:8080/JMSTest , then i enter something into that textfield, then i press the button(form action is http://localhost:8080/test ). it writes that "Mesaj trimis" (message sent - written by me in Romanian), and when i call http://localhost:8080/receiver i did not receive the message. Why?
    I use queue, so i think the send message is stored in a queue until a receiver receives it.
    Please download the project, isn't complicated.
    I did not know what's the problem.
    here is the server.xml file from Tomcat conf folder:
    <?xml version="1.0" encoding="UTF-8"?>
    <Server port="8005" shutdown="SHUTDOWN">
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
      <!-- Global JNDI resources
           Documentation at /docs/jndi-resources-howto.html
      -->
      <GlobalNamingResources>
        <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users
        -->
        <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
      </GlobalNamingResources>
      <Service name="Catalina">
        <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>      
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
        <Engine defaultHost="localhost" name="Catalina"> 
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
          <!-- Define the default virtual host
               Note: XML Schema validation will not work with Xerces 2.2.
           -->
          <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
            <!-- SingleSignOn valve, share authentication between web applications
                 Documentation at: /docs/config/valve.html -->
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
            -->
            <!-- Access log processes all example.
                 Documentation at: /docs/config/valve.html -->
            <!--
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
                   prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
            -->
           <Context path="/JMSTest" docBase="JMSTest"
            debug="5" reloadable="true" crossContext="true">
        <Resource name="jms/ConnectionFactory" auth="Container"
                     type="org.apache.activemq.ActiveMQConnectionFactory"
                     description="JMS Connection Factory"
                     factory="org.apache.activemq.jndi.JNDIReferenceFactory"
                     brokerURL="vm://localhost"
                     brokerName="LocalActiveMQBroker"
                     userName="activemq" password="activemq"
                     useEmbeddedBroker="false"
                     clientID="TomcatClientID" />
        <Resource name="jms/myQueue" auth="Container"
                     type="org.apache.activemq.command.ActiveMQQueue"
                     description="JMS Queue"
                     factory="org.apache.activemq.jndi.JNDIReferenceFactory"
                     physicalName="TEST.FOO" />
        <Resource name="jms/myTopic" auth="Container"
                     type="org.apache.activemq.command.ActiveMQTopic"
                     description="JMS Topic"
                     factory="org.apache.activemq.jndi.JNDIReferenceFactory"
                     physicalName="TEST.BAR"/>
    </Context>
           </Host>
        </Engine>
      </Service>
    </Server>or, how should i do this, but using Sun Message Queue? my way is using Apache MQ
    Thanks
    Edited by: Talkabout on Dec 13, 2008 7:15 AM

    I didn't go all through your code, but I'd say you should make sure that the Receiver servlet is up and running BEFORE your access the Sender servlet.

Maybe you are looking for

  • Zooming an image and scrolling it using a JScrollPane

    Hi all, I know this is one of the most common problems in this forum but i cant get any of the replys to work in my code. The problem: I create an image with varying pixel colors depending on the value obtained from an AbstractTableModel and display

  • Can we call same VI statically and dynamically in same application ?

    Hi, I am having an application where i call a VI dynamically using VI server. However at some other place in the same application, i call the VI statically (i.e. the VI icon is placed in the block diagram of parent VI). But when i run the application

  • Text printing problem in sap script

    In ABAP, we have an excise printing program, in which we have to add one expenses which is being calculated properly in proforma invoice and sales order. The expense head is amortization amout, the amount is being added in the excise invoice total bu

  • PL/SQL XML Parser demo

    i've downloaded the Pl/SQL XML parser demo - xslsample / domsample - followed the guide , etc but I'm getting .... BEGIN xslsample ('/export/home/oracle/plmx/sample','family.xml','iden.xsl','family.out','errors.txt'); END; ERROR at line 1: ORA-29516:

  • Stamps - Where can I get a wider variety?

    Where can I go to find a wider variety of stamps for acrobat? Can I edit the ones that are pre-packaged with the product or easily create a stamp with a similar professional look as to the ones that are packaged with the product? As an example, these