Skip to Content
0
Jan 19, 2009 at 10:28 AM

FI_ReportDevelopment

59 Views

Dear Experts,

I developed this repot,but in output the all debit and credit values or not comming in standard table of sap BSEG it is showing all values can any body help me how to get all regards.

Thaks is advance.

*&---------------------------------------------------------------------*
*& Report  ZSTMTCUST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  zstmtcust no standard page heading
line-size 130.

tables : bkpf,bseg.

types : begin of ty_final,
        bukrs type bkpf-bukrs,
        belnr type bkpf-belnr,
        gjahr type bkpf-gjahr,
        blart type bkpf-blart,
        budat type bkpf-budat,
*       WAERS TYPE BKPF-WAERS,
        buzei type bseg-buzei,
        shkzg type bseg-shkzg,
        kunnr type bseg-kunnr,
        sgtxt type bseg-sgtxt,
        zuonr type bseg-zuonr,
        dmbtr type bseg-dmbtr,
*       dmbtr_h type bseg-dmbtr,
        name1 type kna1-name1,
        stras type kna1-stras,
        land1 type kna1-land1,
        ort01 type kna1-ort01,
        ltext type t003t-ltext,
        end of ty_final.


   types : begin of ty_bkpf,
           bukrs type bkpf-bukrs,
           belnr type bkpf-belnr,
           gjahr type bkpf-gjahr,
           blart type bkpf-blart,
           budat type bkpf-budat,
           waers type bkpf-waers,
           end of ty_bkpf.


   types : begin of ty_bseg,
           bukrs type bseg-bukrs,
           belnr type bseg-belnr,
           buzei type bseg-buzei,
           shkzg type bseg-shkzg,
           kunnr type bseg-kunnr,
           sgtxt type bseg-sgtxt,
           zuonr type bseg-zuonr,
           dmbtr type bseg-dmbtr,
           end of ty_bseg.

types : begin of ty_kna1,
        kunnr type kna1-kunnr,
        name1 type kna1-name1,
        stras type kna1-stras,
        land1 type kna1-land1,
        ort01 type kna1-ort01,
        end of ty_kna1.

types : begin of ty_t003t,
       blart type t003t-blart,
       ltext type t003t-ltext,
       end of ty_t003t.

types : begin of ty_bsis,
        belnr type bsis-belnr,
        pswbt type bsis-pswbt,
        end of ty_bsis.


   data : t_bkpf type standard table of ty_bkpf initial size 1,
          w_bkpf type ty_bkpf.

   data : t_bseg type standard table of ty_bseg initial size 1,
          w_bseg type ty_bseg.

   data : t_final type standard table of ty_final initial size 1,
           w_final type ty_final.

  data : t_kna1 type standard table of ty_kna1 initial size 1,
         w_kna1 type ty_kna1.

data : t_t003t type standard table of ty_t003t initial size 1,
         w_t003t type ty_t003t.


data : t_bsis type standard table of ty_bsis initial size 1,
         w_bsis type ty_bsis.



  data : bal   type p decimals 2,
         opbal type p decimals 2,
         db    type p decimals 2,
         cr    type p decimals 2.
         bal   = 0.
         opbal = 0.
         db    = 0.
         cr    = 0.

select-options :    ccode  for bkpf-bukrs default '0002',
*                    DOCNO  FOR BKPF-BELNR,
                    year   for bkpf-gjahr default '2009',
                    custno for bseg-kunnr default 'c-00049',
                    posdt  for bkpf-budat.

select bukrs
       belnr
       gjahr
       blart
       budat
       waers
       from bkpf into table t_bkpf
       where bukrs  in  ccode
*       AND BELNR IN DOCNO
       and gjahr in year
       and budat in posdt
       and waers = 'SAR'
       and bldat in posdt.

check t_bkpf is not initial.
 select   bukrs
          belnr
          buzei
          shkzg
          sgtxt
          zuonr
          kunnr
          dmbtr
          from bseg into table t_bseg
          for all entries in  t_bkpf
          where  bukrs = t_bkpf-bukrs
          and BELNR = T_BKPF-BELNR
          and kunnr in custno.

check t_bseg is not initial.
select kunnr
       name1
       stras
       land1
       ort01
       from
       kna1
       into table t_kna1
       for all entries in t_bseg
       where kunnr = t_bseg-kunnr.

check t_bseg is not initial.
 select blart
        ltext
        from
        t003t
        into table t_t003t
        for all entries in t_bkpf
        where blart = t_bkpf-blart
        and spras = 'E'.

*check t_bkpf is not initial.
*       select  belnr
*               dmbtr
*               from
*               bsis
*               into table t_bsis
*               for all entries in t_bkpf
*               where belnr = t_bkpf-belnr.

loop at t_bkpf into w_bkpf.
read table t_bseg into w_bseg with key belnr = w_bkpf-belnr.
read table t_kna1 into w_kna1 with key kunnr = w_bseg-kunnr.
read table t_t003t into w_t003t with key  blart = w_bkpf-blart.

w_final-bukrs = w_bkpf-bukrs.
w_final-belnr = w_bkpf-belnr.
*w_final-blart = w_bkpf-blart.
w_final-budat = w_bkpf-budat.
*W_FINAL-WAERS = W_BKPF-WAERS.
w_final-shkzg = w_bseg-shkzg.
w_final-buzei = w_bseg-buzei.
w_final-kunnr = w_bseg-kunnr.
w_final-sgtxt = w_bseg-sgtxt.
w_final-zuonr = w_bseg-zuonr.
w_final-dmbtr = w_bseg-dmbtr  / 1000.
*W_FINAL-dmbtr_h = W_bseg-dmbtr  / 1000.
w_final-name1 = w_kna1-name1.
w_final-stras = w_kna1-stras.
w_final-land1 = w_kna1-land1.
w_final-ort01 = w_kna1-ort01.
w_final-ltext = w_t003t-ltext.
append w_final to t_final.
delete adjacent duplicates from t_final comparing dmbtr.
endloop.
clear w_final.
*lOOP AT T_FINAL INTO W_FINAL.
*   if w_final-SHKZG  eq 'S'.
*       db = w_final-dmbtr.
*  elseif w_final-SHKZG eq  'H'.
*      cr = w_final-dmbtr.
*     endif.
*endloop.
*clear w_final.

sort by t_final.

loop at t_final into w_final.

 if w_final-shkzg eq 'S'." and w_final-buzei eq 002.
 if sy-subrc = 0.
    db  =  w_final-dmbtr." + w_bseg-dmbtr.
    bal =  bal + db.

         write : /05 w_final-zuonr,
                  20 w_final-ltext,
                  45 w_final-budat,
                  58 w_final-belnr,
                  70 w_final-sgtxt,
                  95 db.
 endif.
 endif.
 if w_final-shkzg  eq 'H'." and w_final-buzei eq 001.
 if sy-subrc = 0.
    cr =  w_final-dmbtr." + w_bseg-dmbtr.
         write : /05 w_final-zuonr,
                  20 w_final-ltext,
                  45 w_final-budat,
                  58 w_final-belnr,
                  70 w_final-sgtxt,
                  110 cr.
 endif.
 endif.
*endif.
*        AT last.
*        SUM.
*        uline /100(20).
*        WRITE: /85 'TOTAL:',100 bal.
*        uline /100(20).
*        ENDAT.
endloop.
clear w_final.

top-of-page.
      write : 40  'CUSTOMER STATEMENTS'.
      uline /40(25).
      write :/05 'CoCode      :',ccode-low.
      write :/05 'Customer No :',custno-low, 'To:', custno-high,
              30 'Customer Name :',w_final-name1,
             /30 'Street        :',w_final-stras,
             /30 'City          :',w_final-ort01,w_final-land1.

      write :/05 'Postingdate :',posdt-low, 'To:', posdt-high.
      uline.

      write : /05 'AsstNumber',
               20 'DocumentType',
               45 'PostingDATE',
               58 'DOCUMENTNO',
               70 'Description',
*               60
*               80 'CUSTNO',
*               90 'CURRANCY',
               107 'AMOUNT'.
               uline /02(120).

Edited by: Julius Bussche on Jan 19, 2009 11:34 AM

Please use meaningfull subject titles and code tags