TABLE  for Opening & closing Balance of G/L

Hi all,
I would like to know the name of the TABLE from where i can get the closing balance of previous fiscal and the opening balance of this fiscal year.(As there is a mismatch between the c/f balance.)
Thanks for your Patience & Time
Regards
SAP4ME

Pankaj
Thanks for the reply.
But i am not able to get the closing balance in GLT0 table.
We have the opening balance only.
My issue is that the C/F balance has not been moved properly to the new fiscal year for a particular G/L code.
Now i want to check what made the discrepancy.
If you have any other inputs,kindly provide.
Thanks for you time
Regards
SAP4ME

Similar Messages

  • GL_DAILY_BALANCES table for daily opening/closing balance

    Hi All,
    I need to know something about the GL_Daily_Balances table. In eTRM, it says that the table gives the balances for a particular day. My requirement is to show the opening and closing balances on daily basis. But, I found that all the END_OF_DAY columns (END_OF_DAY1...END_OF_DAY35) are NULL.
    Can anyone tell me why these columns are NULL ? Under what conditions, they are null ? How can I get the opening /closing balance then?
    Thanks!
    Yogini

    Hi Yogini,
    This table is populated when balance processing is enabled in the definition of each set of books, do you have it?
    You can read about in the metalink note # 1072012.6
    Bye

  • Opening & closing balances for Vendor

    Hi Experts,
    I am doing a report where in i need to get the opening & closing balances for Vendor(s). I am using BSIK & BSAK tables. Are there any more tables involved and how do i carry out the calculations?
    Please help.
    Thanks
    Dany

    Hi,
    There are various t. code to check line items for vendor like: S_ALR_87012103 but Any table is not helping to check opening/closeing balance for vendor.
    Table BSIK and BSAK are having are records for open items and close items for vendor and system calculate the balance by using these tables.
    Regards,
    Vinod

  • Opening & closing balance for Multiple Vendors

    Hi Friends,
    I have an issue. This is my code.
    *& Report  ZVEN_OPEN_CLOSE_BAL
    REPORT  ZVEN_OPEN_CLOSE_BAL.
    *& Report  ZVEN_OPEN_CLOSE_BAL
    TABLES:lfa1,bsik.
    TYPES: BEGIN OF ty_bsik,
           bukrs TYPE bsik-bukrs,
           lifnr TYPE bsik-lifnr,
           augbl TYPE bsik-augbl,
           zuonr TYPE bsik-zuonr,
           gjahr TYPE bsik-gjahr,
           xblnr TYPE bsik-xblnr,
           belnr TYPE bsik-belnr,
           buzei TYPE bsik-buzei,
           blart TYPE bsik-blart,
           bldat TYPE bsik-bldat,
           budat TYPE bsik-budat,
           shkzg TYPE bsik-shkzg,
           dmbtr TYPE bsik-dmbtr,
    *       bal   TYPE char30,
           sgtxt TYPE bsik-sgtxt,
           END OF ty_bsik.
    TYPES: BEGIN OF ty_bsak,
           bukrs TYPE bsik-bukrs,
           lifnr TYPE bsak-lifnr,
           augbl TYPE bsak-augbl,
           zuonr TYPE bsak-zuonr,
           gjahr TYPE bsik-gjahr,
           belnr TYPE bsak-belnr,
           buzei TYPE bsik-buzei,
           budat TYPE bsak-budat,
           bldat TYPE bsak-bldat,
           xblnr TYPE bsak-xblnr,
           blart TYPE bsak-blart,
           shkzg TYPE bsak-shkzg,
           dmbtr TYPE bsik-dmbtr,
    *      shkzg1 TYPE bsak-shkzg,
           sgtxt TYPE bsak-sgtxt,
           END OF ty_bsak.
    TYPES: BEGIN OF ty_lfc1,
            lifnr TYPE lfc1-lifnr,
            bukrs TYPE lfc1-bukrs,
            gjahr TYPE lfc1-gjahr,
            umsav TYPE lfc1-umsav,
            END OF ty_lfc1.
    TYPES: BEGIN OF ty_all,
            lifnr TYPE bsik-lifnr,
            zuonr TYPE bsik-zuonr,
            xblnr TYPE bsik-xblnr,
            belnr TYPE bsik-belnr,
            hkont TYPE bseg-hkont,
            blart TYPE bsik-blart,
            ltext TYPE text20,
            bldat TYPE bsik-bldat,
            budat TYPE bsik-budat,
            opbal TYPE p DECIMALS 2,
            deb   TYPE p DECIMALS 2 ,"bsik-dmbtr,
            cre   TYPE p DECIMALS 2,"bsik-dmbtr,
            bal   TYPE p DECIMALS 2,
            augbl TYPE bsik-augbl,
            sgtxt TYPE bsik-sgtxt,
          END OF ty_all.
    TYPE-POOLS: slis.
    DATA:  t_layout   TYPE slis_layout_alv,
           s_fieldtab TYPE slis_fieldcat_alv,
           t_fieldtab TYPE slis_t_fieldcat_alv,
           wa_header TYPE slis_listheader,
           it_header TYPE  slis_t_listheader.
    DATA:it_bsik TYPE TABLE OF ty_bsik,
         it_bsak TYPE TABLE OF ty_bsak,
         it_all  TYPE TABLE OF ty_all,
         it_lfc1 TYPE TABLE OF ty_lfc1,
         it_t003 TYPE TABLE OF t003t,
         wa_bsik TYPE ty_bsik,
         wa_bsak TYPE ty_bsak,
         wa_all  TYPE ty_all,
         wa_lfc1 TYPE ty_lfc1,
         wa_t003 TYPE t003t.
    DATA:  gt_fldcat    TYPE slis_t_fieldcat_alv,
           gs_fldcat    TYPE slis_fieldcat_alv,
           gs_layout    TYPE slis_layout_alv,
           gv_save      TYPE c VALUE 'X'.
    types :BEGIN OF ty_bseg,
            BUKRS TYPE BUKRS,
            BELNR  TYPE BELNR_D,
            GJAHR  TYPE GJAHR,
            BUZEI  TYPE BUZEI,
            koart type koart,
            HKONT TYPE HKONT,
           END OF ty_bseg.
    DATA: it_bseg type TABLE OF ty_bseg,
          wa_bseg type ty_bseg.
      data t_balence TYPE TABLE OF BAPI3008_3 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr,
                     s_bukrs FOR bsik-bukrs,
                     s_budat FOR bsik-budat OBLIGATORY.
    PARAMETERS : p_gjahr TYPE bsik-gjahr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process_data.
      PERFORM display.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_data .
      break naidu.
      SELECT  bukrs
              lifnr
              augbl
              zuonr
              gjahr
              xblnr
              belnr
              buzei
              blart
              bldat
              budat
              shkzg
              dmbtr
              sgtxt FROM bsik
              INTO TABLE it_bsik
              WHERE lifnr IN s_lifnr AND
                    bukrs IN s_bukrs AND
                    budat IN s_budat AND
                    gjahr = p_gjahr .
      SELECT bukrs
             lifnr
             augbl
             zuonr
             gjahr
             belnr
             buzei
             budat
             bldat
             xblnr
             blart
             shkzg
             dmbtr
             sgtxt FROM bsak
             INTO TABLE it_bsak
             WHERE lifnr IN s_lifnr AND
                   bukrs IN s_bukrs AND
                   budat IN s_budat AND
                   gjahr = p_gjahr .
    if it_bsik is INITIAL and it_bsak  is INITIAL.
    *DATA  v_date type budat.
    *data :year(4),
    *      month(2),
    *      date(2).
    *  year  = s_budat-low+0(4).
    *  date  = s_budat-low+6(2).
    *  month = s_budat-low+4(2).
    *  month = month - 01.
    *CONCATENATE year month date INTO v_date .
    *  SELECT  bukrs
    *          lifnr
    *          augbl
    *          zuonr
    *          gjahr
    *          xblnr
    *          belnr
    *          buzei
    *          blart
    *          bldat
    *          budat
    *          shkzg
    *          dmbtr
    *          sgtxt FROM bsik
    *          INTO TABLE it_bsik
    *          WHERE lifnr IN s_lifnr AND
    *                bukrs in s_bukrs and
    *                budat eq v_date AND
    *                gjahr = p_gjahr .
    *  SELECT bukrs
    *         lifnr
    *         augbl
    *         zuonr
    *         gjahr
    *         belnr
    *         buzei
    *         budat
    *         bldat
    *         xblnr
    *         blart
    *         shkzg
    *         dmbtr
    *         sgtxt FROM bsak
    *         INTO TABLE it_bsak
    *         WHERE lifnr IN s_lifnr AND
    *               bukrs IN s_bukrs AND
    *               budat eq v_date AND
    *               gjahr = p_gjahr .
      CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
        EXPORTING
          companycode        = s_bukrs-low
          vendor             = s_lifnr-low
          keydate            = s_budat-low
    *     BALANCESPGLI       = ' '
    *     NOTEDITEMS         = ' '
    *   IMPORTING
    *     RETURN             =
        TABLES
          keybalance         = t_balence
      endif.
    ENDFORM.                    " GET_DATA
    *&      Form  PROCESS_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM process_data .
      DATA:v_bal TYPE netpr.
      LOOP AT it_bsak INTO wa_bsak.
        wa_bsik-bukrs  =    wa_bsak-bukrs.
        wa_bsik-lifnr  =    wa_bsak-lifnr.
        wa_bsik-augbl  =    wa_bsak-augbl.
        wa_bsik-zuonr  =    wa_bsak-zuonr.
        wa_bsik-gjahr  =    wa_bsak-gjahr.
        wa_bsik-belnr  =    wa_bsak-belnr.
        wa_bsik-buzei  =    wa_bsak-buzei.
        wa_bsik-budat  =    wa_bsak-budat.
        wa_bsik-bldat  =    wa_bsak-bldat.
        wa_bsik-xblnr  =    wa_bsak-xblnr.
        wa_bsik-blart  =    wa_bsak-blart.
        wa_bsik-shkzg  =    wa_bsak-shkzg.
        wa_bsik-dmbtr  =    wa_bsak-dmbtr.
        wa_bsik-sgtxt  =    wa_bsak-sgtxt .
        APPEND wa_bsik TO it_bsik.
        CLEAR:wa_bsik.
      ENDLOOP.
      IF it_bsik IS NOT INITIAL .
        SELECT lifnr bukrs gjahr umsav
               FROM lfc1
              INTO TABLE it_lfc1 FOR ALL ENTRIES IN  it_bsik
              WHERE
                    lifnr  EQ it_bsik-lifnr AND
                    bukrs  EQ it_bsik-bukrs AND
                    gjahr  EQ it_bsik-gjahr.
        SELECT  * FROM t003t
          INTO TABLE it_t003
          FOR ALL ENTRIES IN it_bsik
            WHERE blart = it_bsik-blart AND
                  spras = 'EN'.
    *&Bindu........................................
          select bukrs  "Company Code
                 belnr  "Document Number
                 gjahr  "Fiscal Year
                 buzei  "Line item
                 koart  "Account Type
                 hkont  "General Ledger Account
            from bseg into TABLE it_bseg
                      FOR ALL ENTRIES IN it_bsik
                      WHERE belnr eq it_bsik-belnr and
                            bukrs in s_bukrs and
                            gjahr eq p_gjahr and
                            BUZEI eq it_bsik-buzei.
      ENDIF.
      SORT it_bsik BY lifnr.
      DATA:c,
            l_dmbtr type p DECIMALS 2.
    DATA:v1(15),
         v2(3).
    DATA:v_umsav(18).
    DATA v_fbal TYPE umsav.
      LOOP AT it_bsik INTO wa_bsik.
            READ TABLE it_lfc1 INTO wa_lfc1 WITH KEY lifnr = wa_bsik-lifnr
                                                 bukrs = wa_bsik-bukrs
                                                 gjahr = wa_bsik-gjahr.
        if sy-subrc = 0.
    at FIRST.
    v_umsav = wa_lfc1-umsav.
      SPLIT v_umsav at '.' INTO v1 v2.
          wa_all-LTEXT = 'Opening Balance'.
          IF v2+2(1) = '-'.
          wa_all-cre = wa_lfc1-umsav.
          ELSE.
            wa_all-deb = wa_lfc1-umsav.
          ENDIF.
           wa_all-bal = wa_lfc1-umsav.
           v_fbal = wa_all-bal.
    APPEND wa_all to it_all.
    CLEAR wa_all.
    endat.
    endif.
        AT NEW lifnr.
          c = 0.
        ENDAT.
        wa_all-lifnr = wa_bsik-lifnr.
        wa_all-zuonr = wa_bsik-zuonr.
        wa_all-xblnr = wa_bsik-xblnr.
        wa_all-belnr = wa_bsik-belnr.
        wa_all-blart = wa_bsik-blart.
        wa_all-bldat = wa_bsik-bldat.
        wa_all-budat = wa_bsik-budat.
    *&Bindu............
      READ TABLE it_bseg into wa_bseg WITH KEY belnr = wa_bsik-belnr
                                               buzei = wa_bsik-buzei."Bindu.......
    if sy-subrc = 0.
        wa_all-hkont = wa_bseg-hkont. "Bindu.....
    endif.
        IF wa_bsik-shkzg = 'S'.
          wa_all-deb = wa_bsik-dmbtr.
        ELSEIF wa_bsik-shkzg = 'H'.
          wa_all-cre = wa_bsik-dmbtr.
        ENDIF.
        READ TABLE  it_t003 INTO wa_t003 WITH KEY blart = wa_bsik-blart.
        IF sy-subrc = 0.
          wa_all-ltext = wa_t003-ltext.
        ENDIF.
    *    READ TABLE it_lfc1 INTO wa_lfc1 WITH KEY lifnr = wa_bsik-lifnr
    *                                             bukrs = wa_bsik-bukrs
    *                                             gjahr = wa_bsik-gjahr.
    *break naidu.
        IF sy-subrc = 0.
    *      IF c = 0.
    *        clear:l_dmbtr.
    *        wa_all-opbal = wa_lfc1-umsav.
    *        c = c + 1.
    *        IF wa_bsik-shkzg = 'S'.
    *          wa_all-bal =  wa_all-opbal + wa_bsik-dmbtr.
    *        ELSEIF wa_bsik-shkzg = 'H'.
    *          wa_all-bal =  wa_all-opbal - wa_bsik-dmbtr.
    *        ENDIF.
            l_dmbtr = wa_all-bal.
    *      ELSE.
    *          wa_all-bal =  l_dmbtr + wa_bsik-dmbtr.
    *        ELSEIF wa_bsik-shkzg = 'H'.
    *          wa_all-bal = l_dmbtr - wa_bsik-dmbtr.
    *        ENDIF.
          ENDIF.
    *  IF wa_bsik-shkzg = 'S'.
    *          wa_all-bal =  wa_all-opbal + wa_bsik-dmbtr.
    *        ELSEIF wa_bsik-shkzg = 'H'.
    *          wa_all-bal =  wa_all-opbal - wa_bsik-dmbtr.
    *        ENDIF.
    if v_fbal is NOT INITIAL.
    wa_all-bal = v_fbal + wa_all-deb - wa_all-cre.
    CLEAR:v_fbal.
    else.
    wa_all-bal = v_bal + wa_all-deb - wa_all-cre.
        ENDIF.
        wa_all-augbl = wa_bsik-augbl.
        wa_all-sgtxt = wa_bsik-sgtxt.
    *v_balance  = wa_all-bal.
    APPEND wa_all TO it_all.
    v_bal = wa_all-bal.
    CLEAR :wa_all.
    *& Closing Balence.................
        at last.
       wa_all-LTEXT = 'Closing Balance'.
    *      IF .
          wa_all-BAL = v_bal.
    APPEND wa_all to it_all.
    CLEAR wa_all.
    *      ENDIF.
    endat.
      ENDLOOP.
    ENDFORM.                    " PROCESS_DATA
    *&      Form  DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display .
      DATA : ls_layout  TYPE  slis_layout_alv.
      PERFORM create_fldcat.
      ls_layout-expand_all = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-expand_fieldname = 'X'.
      ls_layout-zebra = 'X'.
    if it_all is initial .
        wa_all-LTEXT = 'Opening Balance'.
        wa_all-bal = t_balence-LC_BAL.
        wa_all-lifnr = s_lifnr-low.
        APPEND wa_all to it_all.
        ENDIF.
      IF it_all IS NOT INITIAL.
            CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program = sy-repid
            is_layout          = ls_layout
            it_fieldcat        = gt_fldcat
            i_save             = 'X'
          TABLES
            t_outtab           = it_all[]
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ELSE.
        MESSAGE 'There is no Data for the given selection screen' TYPE 'I' DISPLAY LIKE 'E'.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " DISPLAY
    *&      Form  CREATE_FLDCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_fldcat .
      PERFORM : append_val USING 'LIFNR'       'IT_ALL' 'vendor'  '' '' 'X' ' '.
      PERFORM : append_val USING 'HKONT'       'IT_ALL' 'G/L Acc'  '' '' 'X' ' '.
      PERFORM : append_val USING 'ZUONR'       'IT_ALL' 'account'  '' '' '' ''.
      PERFORM : append_val USING 'XBLNR'       'IT_ALL' 'number'  '' '' 'X' ''.
      PERFORM : append_val USING 'BELNR'       'IT_ALL' 'ref no'  '' '' 'X' ''.
      PERFORM : append_val USING 'BLART'       'IT_ALL' 'type'  '' '' 'X' ''.
      PERFORM : append_val USING 'LTEXT'       'IT_ALL' 'type text'  '' '' 'X' ''.
      PERFORM : append_val USING 'BLDAT'       'IT_ALL' 'doc date'  '' '' 'X' ''.
      PERFORM : append_val USING 'BUDAT'       'IT_ALL' 'post date'  '' '' 'X' ''.
      PERFORM : append_val USING 'OPBAL'       'IT_ALL' 'op balance'  '' '' '' ''.
      PERFORM : append_val USING 'DEB'         'IT_ALL' 'debit' '' '' '' ''.
      PERFORM : append_val USING 'CRE'         'IT_ALL' 'credit'  '' '' '' ''.
      PERFORM : append_val USING 'BAL'         'IT_ALL' 'balance'  '' '' '' ''.
      PERFORM : append_val USING 'AUGBL'       'IT_ALL' 'clr doc'  '' '' 'X' ''.
      PERFORM : append_val USING 'SGTXT'       'IT_ALL' 'text '  '' '' 'X' ''.
    ENDFORM.                    " CREATE_FLDCAT
    *&      Form  APPEND_VAL
    *       text
    *      -->P_0578   text
    *      -->P_0579   text
    *      -->P_TEXT_010  text
    *      -->P_0581   text
    *      -->P_0582   text
    *      -->P_0583   text
    FORM append_val  USING    p_a
                              p_b
                              p_c
                              p_d
                              p_e
                              p_f
                              p_g.
      CLEAR gs_fldcat.
      gs_fldcat-fieldname  = p_a.
      gs_fldcat-tabname    = p_b.
      gs_fldcat-seltext_m  = p_c.
      gs_fldcat-qfieldname = p_d.
      gs_fldcat-datatype   = p_e.
      gs_fldcat-no_zero    = p_f.
      gs_fldcat-do_sum     = p_g.
      APPEND gs_fldcat TO gt_fldcat.
    ENDFORM.                    " APPEND_VAL
    This is working for single vendor.
    Now my problem is Opening & closing balance should be displayed for multiple vendors.
    Please suggest me.
    Thanks in advance.

    Hi Friends,
    I have an issue. This is my code.
    *& Report  ZVEN_OPEN_CLOSE_BAL
    REPORT  ZVEN_OPEN_CLOSE_BAL.
    *& Report  ZVEN_OPEN_CLOSE_BAL
    TABLES:lfa1,bsik.
    TYPES: BEGIN OF ty_bsik,
           bukrs TYPE bsik-bukrs,
           lifnr TYPE bsik-lifnr,
           augbl TYPE bsik-augbl,
           zuonr TYPE bsik-zuonr,
           gjahr TYPE bsik-gjahr,
           xblnr TYPE bsik-xblnr,
           belnr TYPE bsik-belnr,
           buzei TYPE bsik-buzei,
           blart TYPE bsik-blart,
           bldat TYPE bsik-bldat,
           budat TYPE bsik-budat,
           shkzg TYPE bsik-shkzg,
           dmbtr TYPE bsik-dmbtr,
    *       bal   TYPE char30,
           sgtxt TYPE bsik-sgtxt,
           END OF ty_bsik.
    TYPES: BEGIN OF ty_bsak,
           bukrs TYPE bsik-bukrs,
           lifnr TYPE bsak-lifnr,
           augbl TYPE bsak-augbl,
           zuonr TYPE bsak-zuonr,
           gjahr TYPE bsik-gjahr,
           belnr TYPE bsak-belnr,
           buzei TYPE bsik-buzei,
           budat TYPE bsak-budat,
           bldat TYPE bsak-bldat,
           xblnr TYPE bsak-xblnr,
           blart TYPE bsak-blart,
           shkzg TYPE bsak-shkzg,
           dmbtr TYPE bsik-dmbtr,
    *      shkzg1 TYPE bsak-shkzg,
           sgtxt TYPE bsak-sgtxt,
           END OF ty_bsak.
    TYPES: BEGIN OF ty_lfc1,
            lifnr TYPE lfc1-lifnr,
            bukrs TYPE lfc1-bukrs,
            gjahr TYPE lfc1-gjahr,
            umsav TYPE lfc1-umsav,
            END OF ty_lfc1.
    TYPES: BEGIN OF ty_all,
            lifnr TYPE bsik-lifnr,
            zuonr TYPE bsik-zuonr,
            xblnr TYPE bsik-xblnr,
            belnr TYPE bsik-belnr,
            hkont TYPE bseg-hkont,
            blart TYPE bsik-blart,
            ltext TYPE text20,
            bldat TYPE bsik-bldat,
            budat TYPE bsik-budat,
            opbal TYPE p DECIMALS 2,
            deb   TYPE p DECIMALS 2 ,"bsik-dmbtr,
            cre   TYPE p DECIMALS 2,"bsik-dmbtr,
            bal   TYPE p DECIMALS 2,
            augbl TYPE bsik-augbl,
            sgtxt TYPE bsik-sgtxt,
          END OF ty_all.
    TYPE-POOLS: slis.
    DATA:  t_layout   TYPE slis_layout_alv,
           s_fieldtab TYPE slis_fieldcat_alv,
           t_fieldtab TYPE slis_t_fieldcat_alv,
           wa_header TYPE slis_listheader,
           it_header TYPE  slis_t_listheader.
    DATA:it_bsik TYPE TABLE OF ty_bsik,
         it_bsak TYPE TABLE OF ty_bsak,
         it_all  TYPE TABLE OF ty_all,
         it_lfc1 TYPE TABLE OF ty_lfc1,
         it_t003 TYPE TABLE OF t003t,
         wa_bsik TYPE ty_bsik,
         wa_bsak TYPE ty_bsak,
         wa_all  TYPE ty_all,
         wa_lfc1 TYPE ty_lfc1,
         wa_t003 TYPE t003t.
    DATA:  gt_fldcat    TYPE slis_t_fieldcat_alv,
           gs_fldcat    TYPE slis_fieldcat_alv,
           gs_layout    TYPE slis_layout_alv,
           gv_save      TYPE c VALUE 'X'.
    types :BEGIN OF ty_bseg,
            BUKRS TYPE BUKRS,
            BELNR  TYPE BELNR_D,
            GJAHR  TYPE GJAHR,
            BUZEI  TYPE BUZEI,
            koart type koart,
            HKONT TYPE HKONT,
           END OF ty_bseg.
    DATA: it_bseg type TABLE OF ty_bseg,
          wa_bseg type ty_bseg.
      data t_balence TYPE TABLE OF BAPI3008_3 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr,
                     s_bukrs FOR bsik-bukrs,
                     s_budat FOR bsik-budat OBLIGATORY.
    PARAMETERS : p_gjahr TYPE bsik-gjahr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process_data.
      PERFORM display.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_data .
      break naidu.
      SELECT  bukrs
              lifnr
              augbl
              zuonr
              gjahr
              xblnr
              belnr
              buzei
              blart
              bldat
              budat
              shkzg
              dmbtr
              sgtxt FROM bsik
              INTO TABLE it_bsik
              WHERE lifnr IN s_lifnr AND
                    bukrs IN s_bukrs AND
                    budat IN s_budat AND
                    gjahr = p_gjahr .
      SELECT bukrs
             lifnr
             augbl
             zuonr
             gjahr
             belnr
             buzei
             budat
             bldat
             xblnr
             blart
             shkzg
             dmbtr
             sgtxt FROM bsak
             INTO TABLE it_bsak
             WHERE lifnr IN s_lifnr AND
                   bukrs IN s_bukrs AND
                   budat IN s_budat AND
                   gjahr = p_gjahr .
    if it_bsik is INITIAL and it_bsak  is INITIAL.
    *DATA  v_date type budat.
    *data :year(4),
    *      month(2),
    *      date(2).
    *  year  = s_budat-low+0(4).
    *  date  = s_budat-low+6(2).
    *  month = s_budat-low+4(2).
    *  month = month - 01.
    *CONCATENATE year month date INTO v_date .
    *  SELECT  bukrs
    *          lifnr
    *          augbl
    *          zuonr
    *          gjahr
    *          xblnr
    *          belnr
    *          buzei
    *          blart
    *          bldat
    *          budat
    *          shkzg
    *          dmbtr
    *          sgtxt FROM bsik
    *          INTO TABLE it_bsik
    *          WHERE lifnr IN s_lifnr AND
    *                bukrs in s_bukrs and
    *                budat eq v_date AND
    *                gjahr = p_gjahr .
    *  SELECT bukrs
    *         lifnr
    *         augbl
    *         zuonr
    *         gjahr
    *         belnr
    *         buzei
    *         budat
    *         bldat
    *         xblnr
    *         blart
    *         shkzg
    *         dmbtr
    *         sgtxt FROM bsak
    *         INTO TABLE it_bsak
    *         WHERE lifnr IN s_lifnr AND
    *               bukrs IN s_bukrs AND
    *               budat eq v_date AND
    *               gjahr = p_gjahr .
      CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
        EXPORTING
          companycode        = s_bukrs-low
          vendor             = s_lifnr-low
          keydate            = s_budat-low
    *     BALANCESPGLI       = ' '
    *     NOTEDITEMS         = ' '
    *   IMPORTING
    *     RETURN             =
        TABLES
          keybalance         = t_balence
      endif.
    ENDFORM.                    " GET_DATA
    *&      Form  PROCESS_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM process_data .
      DATA:v_bal TYPE netpr.
      LOOP AT it_bsak INTO wa_bsak.
        wa_bsik-bukrs  =    wa_bsak-bukrs.
        wa_bsik-lifnr  =    wa_bsak-lifnr.
        wa_bsik-augbl  =    wa_bsak-augbl.
        wa_bsik-zuonr  =    wa_bsak-zuonr.
        wa_bsik-gjahr  =    wa_bsak-gjahr.
        wa_bsik-belnr  =    wa_bsak-belnr.
        wa_bsik-buzei  =    wa_bsak-buzei.
        wa_bsik-budat  =    wa_bsak-budat.
        wa_bsik-bldat  =    wa_bsak-bldat.
        wa_bsik-xblnr  =    wa_bsak-xblnr.
        wa_bsik-blart  =    wa_bsak-blart.
        wa_bsik-shkzg  =    wa_bsak-shkzg.
        wa_bsik-dmbtr  =    wa_bsak-dmbtr.
        wa_bsik-sgtxt  =    wa_bsak-sgtxt .
        APPEND wa_bsik TO it_bsik.
        CLEAR:wa_bsik.
      ENDLOOP.
      IF it_bsik IS NOT INITIAL .
        SELECT lifnr bukrs gjahr umsav
               FROM lfc1
              INTO TABLE it_lfc1 FOR ALL ENTRIES IN  it_bsik
              WHERE
                    lifnr  EQ it_bsik-lifnr AND
                    bukrs  EQ it_bsik-bukrs AND
                    gjahr  EQ it_bsik-gjahr.
        SELECT  * FROM t003t
          INTO TABLE it_t003
          FOR ALL ENTRIES IN it_bsik
            WHERE blart = it_bsik-blart AND
                  spras = 'EN'.
    *&Bindu........................................
          select bukrs  "Company Code
                 belnr  "Document Number
                 gjahr  "Fiscal Year
                 buzei  "Line item
                 koart  "Account Type
                 hkont  "General Ledger Account
            from bseg into TABLE it_bseg
                      FOR ALL ENTRIES IN it_bsik
                      WHERE belnr eq it_bsik-belnr and
                            bukrs in s_bukrs and
                            gjahr eq p_gjahr and
                            BUZEI eq it_bsik-buzei.
      ENDIF.
      SORT it_bsik BY lifnr.
      DATA:c,
            l_dmbtr type p DECIMALS 2.
    DATA:v1(15),
         v2(3).
    DATA:v_umsav(18).
    DATA v_fbal TYPE umsav.
      LOOP AT it_bsik INTO wa_bsik.
            READ TABLE it_lfc1 INTO wa_lfc1 WITH KEY lifnr = wa_bsik-lifnr
                                                 bukrs = wa_bsik-bukrs
                                                 gjahr = wa_bsik-gjahr.
        if sy-subrc = 0.
    at FIRST.
    v_umsav = wa_lfc1-umsav.
      SPLIT v_umsav at '.' INTO v1 v2.
          wa_all-LTEXT = 'Opening Balance'.
          IF v2+2(1) = '-'.
          wa_all-cre = wa_lfc1-umsav.
          ELSE.
            wa_all-deb = wa_lfc1-umsav.
          ENDIF.
           wa_all-bal = wa_lfc1-umsav.
           v_fbal = wa_all-bal.
    APPEND wa_all to it_all.
    CLEAR wa_all.
    endat.
    endif.
        AT NEW lifnr.
          c = 0.
        ENDAT.
        wa_all-lifnr = wa_bsik-lifnr.
        wa_all-zuonr = wa_bsik-zuonr.
        wa_all-xblnr = wa_bsik-xblnr.
        wa_all-belnr = wa_bsik-belnr.
        wa_all-blart = wa_bsik-blart.
        wa_all-bldat = wa_bsik-bldat.
        wa_all-budat = wa_bsik-budat.
    *&Bindu............
      READ TABLE it_bseg into wa_bseg WITH KEY belnr = wa_bsik-belnr
                                               buzei = wa_bsik-buzei."Bindu.......
    if sy-subrc = 0.
        wa_all-hkont = wa_bseg-hkont. "Bindu.....
    endif.
        IF wa_bsik-shkzg = 'S'.
          wa_all-deb = wa_bsik-dmbtr.
        ELSEIF wa_bsik-shkzg = 'H'.
          wa_all-cre = wa_bsik-dmbtr.
        ENDIF.
        READ TABLE  it_t003 INTO wa_t003 WITH KEY blart = wa_bsik-blart.
        IF sy-subrc = 0.
          wa_all-ltext = wa_t003-ltext.
        ENDIF.
    *    READ TABLE it_lfc1 INTO wa_lfc1 WITH KEY lifnr = wa_bsik-lifnr
    *                                             bukrs = wa_bsik-bukrs
    *                                             gjahr = wa_bsik-gjahr.
    *break naidu.
        IF sy-subrc = 0.
    *      IF c = 0.
    *        clear:l_dmbtr.
    *        wa_all-opbal = wa_lfc1-umsav.
    *        c = c + 1.
    *        IF wa_bsik-shkzg = 'S'.
    *          wa_all-bal =  wa_all-opbal + wa_bsik-dmbtr.
    *        ELSEIF wa_bsik-shkzg = 'H'.
    *          wa_all-bal =  wa_all-opbal - wa_bsik-dmbtr.
    *        ENDIF.
            l_dmbtr = wa_all-bal.
    *      ELSE.
    *          wa_all-bal =  l_dmbtr + wa_bsik-dmbtr.
    *        ELSEIF wa_bsik-shkzg = 'H'.
    *          wa_all-bal = l_dmbtr - wa_bsik-dmbtr.
    *        ENDIF.
          ENDIF.
    *  IF wa_bsik-shkzg = 'S'.
    *          wa_all-bal =  wa_all-opbal + wa_bsik-dmbtr.
    *        ELSEIF wa_bsik-shkzg = 'H'.
    *          wa_all-bal =  wa_all-opbal - wa_bsik-dmbtr.
    *        ENDIF.
    if v_fbal is NOT INITIAL.
    wa_all-bal = v_fbal + wa_all-deb - wa_all-cre.
    CLEAR:v_fbal.
    else.
    wa_all-bal = v_bal + wa_all-deb - wa_all-cre.
        ENDIF.
        wa_all-augbl = wa_bsik-augbl.
        wa_all-sgtxt = wa_bsik-sgtxt.
    *v_balance  = wa_all-bal.
    APPEND wa_all TO it_all.
    v_bal = wa_all-bal.
    CLEAR :wa_all.
    *& Closing Balence.................
        at last.
       wa_all-LTEXT = 'Closing Balance'.
    *      IF .
          wa_all-BAL = v_bal.
    APPEND wa_all to it_all.
    CLEAR wa_all.
    *      ENDIF.
    endat.
      ENDLOOP.
    ENDFORM.                    " PROCESS_DATA
    *&      Form  DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display .
      DATA : ls_layout  TYPE  slis_layout_alv.
      PERFORM create_fldcat.
      ls_layout-expand_all = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-expand_fieldname = 'X'.
      ls_layout-zebra = 'X'.
    if it_all is initial .
        wa_all-LTEXT = 'Opening Balance'.
        wa_all-bal = t_balence-LC_BAL.
        wa_all-lifnr = s_lifnr-low.
        APPEND wa_all to it_all.
        ENDIF.
      IF it_all IS NOT INITIAL.
            CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program = sy-repid
            is_layout          = ls_layout
            it_fieldcat        = gt_fldcat
            i_save             = 'X'
          TABLES
            t_outtab           = it_all[]
          EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
      ELSE.
        MESSAGE 'There is no Data for the given selection screen' TYPE 'I' DISPLAY LIKE 'E'.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " DISPLAY
    *&      Form  CREATE_FLDCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_fldcat .
      PERFORM : append_val USING 'LIFNR'       'IT_ALL' 'vendor'  '' '' 'X' ' '.
      PERFORM : append_val USING 'HKONT'       'IT_ALL' 'G/L Acc'  '' '' 'X' ' '.
      PERFORM : append_val USING 'ZUONR'       'IT_ALL' 'account'  '' '' '' ''.
      PERFORM : append_val USING 'XBLNR'       'IT_ALL' 'number'  '' '' 'X' ''.
      PERFORM : append_val USING 'BELNR'       'IT_ALL' 'ref no'  '' '' 'X' ''.
      PERFORM : append_val USING 'BLART'       'IT_ALL' 'type'  '' '' 'X' ''.
      PERFORM : append_val USING 'LTEXT'       'IT_ALL' 'type text'  '' '' 'X' ''.
      PERFORM : append_val USING 'BLDAT'       'IT_ALL' 'doc date'  '' '' 'X' ''.
      PERFORM : append_val USING 'BUDAT'       'IT_ALL' 'post date'  '' '' 'X' ''.
      PERFORM : append_val USING 'OPBAL'       'IT_ALL' 'op balance'  '' '' '' ''.
      PERFORM : append_val USING 'DEB'         'IT_ALL' 'debit' '' '' '' ''.
      PERFORM : append_val USING 'CRE'         'IT_ALL' 'credit'  '' '' '' ''.
      PERFORM : append_val USING 'BAL'         'IT_ALL' 'balance'  '' '' '' ''.
      PERFORM : append_val USING 'AUGBL'       'IT_ALL' 'clr doc'  '' '' 'X' ''.
      PERFORM : append_val USING 'SGTXT'       'IT_ALL' 'text '  '' '' 'X' ''.
    ENDFORM.                    " CREATE_FLDCAT
    *&      Form  APPEND_VAL
    *       text
    *      -->P_0578   text
    *      -->P_0579   text
    *      -->P_TEXT_010  text
    *      -->P_0581   text
    *      -->P_0582   text
    *      -->P_0583   text
    FORM append_val  USING    p_a
                              p_b
                              p_c
                              p_d
                              p_e
                              p_f
                              p_g.
      CLEAR gs_fldcat.
      gs_fldcat-fieldname  = p_a.
      gs_fldcat-tabname    = p_b.
      gs_fldcat-seltext_m  = p_c.
      gs_fldcat-qfieldname = p_d.
      gs_fldcat-datatype   = p_e.
      gs_fldcat-no_zero    = p_f.
      gs_fldcat-do_sum     = p_g.
      APPEND gs_fldcat TO gt_fldcat.
    ENDFORM.                    " APPEND_VAL
    This is working for single vendor.
    Now my problem is Opening & closing balance should be displayed for multiple vendors.
    Please suggest me.
    Thanks in advance.

  • Opening & Closing balance of RG23A part II are miss matching for SECS only

    Hi Gurus,
    Opening & Closing balance for the month of May & April are mismatching for SECS only. where as BED & all other values are getting matched with April closeing & May opening.
    I have checked from Jan till Aprill everything is ok but after this in May i have problem.
    My closeing value in April for SECS is 40K where in May opening it is showing 5K. I use J2i6 to download the register.
    Plz can any one tell me how should i track this inconsistency.

    Its possible that some transactions are posted after you extract the report.  Extract the report again (J2I5) and print them. 
    Have you configured different GL accounts for posting BED, ECS & HCS.  From your description, it seems same GL is assigned for all three components.
    Ravi.

  • GL account opening/closing balances by day

    Hi All.
    I wish to list day by day opening and closing balances of G/L account by restricting the result to a time interval.
    Anyone know how to write the query for G/L account opening & closing balances by day?
    I found this in the forum and modify it to below:
    declare @fr char(10)
    declare @to char(10)
    set @fr=convert (char(10),[%0],20)
    set @to=convert (char(10),[%1],20)
    declare @PrCl dec(19,6)
    declare @de dec(19,6)
    declare @cr dec(19,6)
    declare @acc char(20)
    declare @Pracc char(20)
    Create table #W
      (M char(10), Acc char(20), Me char(100), Tid char(10), Br char(10), TT char(30), Op dec(19,6),De dec(19,6),Cr dec(19,6),Cl dec(19,6) )
    Insert into #W (M,Acc,Me,Tid,Br,TT,Op,De,Cr,Cl)
    SELECT convert (char(10),T1.[RefDate],20)Mo, T1.[Account],T0.Memo, T0.TransId, T0.BaseRef, CASE
    WHEN T0.TransType = 13 THEN 'AR Inv'
    WHEN T0.TransType = 14 THEN 'AR CN'
    WHEN T0.TransType = 18 THEN 'AP Inv'
    WHEN T0.TransType = 19 THEN 'AP CN'
    WHEN T0.TransType = 24 THEN 'Incoming Payment'
    WHEN T0.TransType = 30 THEN 'JE'
    WHEN T0.TransType = 46 THEN 'Outgoing Payment'
    ELSE 'Other'
    END AS 'Trans Type',
      0,T1.[Debit] De , T1.[Credit] Cr,0
    FROM OJDT T0 INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId
    Group by T1.[Account],convert (char(10),T1.[RefDate],20),T0.Memo, T0.TransId, T0.BaseRef, T0.TransType,  T1.Debit, T1.Credit
    Order By T1.[Account],convert (char(10),T1.[RefDate],20)
    Declare cu cursor for
    Select acc,de,cr from #W
      for update
    set @PrAcc=''
    Open cu
    Fetch next from cu into @acc,@de,@cr
    While @@FETCH_STATUS = 0
    Begin
    If @acc!=@PrAcc set @PrCl=0
    Update #W
       set op=@PrCl,
           cl=@PrCl-@Cr+@de
      where current of cu
    set @PrCl=@PrCl-@Cr+@de
    set @PrAcc=@acc
    Fetch next from cu into @acc,@de,@cr
    End
    deallocate cu
    Select * from #w
    Where M between @fr and @to
    Drop table #W
    but some of the rows are missing from the result. e.g. row with the same value of debit/credit ( same TransId and BaseRef) will come out once only in the result.
    Please guide me on the above issue.
    Thanks & Best Regards,
    Leng

    Hi,
    You have to make use of many tables for this purpose.
    1. You have to claculate the previuos period and finscal year for the given date..
    2. You have to calculate the G/L balances for this period for the given G/L account from table GLT0.(You can use some of the standard function modules for the same)
    3. You have get the line items from the various tables like BSIS,BSAS,BSIK, BASK, BSID and BSAD for the dates from the begining of the month to the given date-1. sum upthis amount with the amount retrieved from step 2 .This will be the opening balance for the given date.
    4.retrieve the data from he same tables like step 3 for the given date. This will the transactions of the given date.
    5. sum up  the amounts from step 4 with step 3. this will be the closing balance for that date.
    let me know id you want any further info..
    Reward the points if i answered your question..

  • Opening & Closing balances of Vendor

    Hi Experts,
    I am doing a report where in i need to get the opening & closing balances for Vendor(s). I am using BSIK & BSAK tables. Are there any more tables involved and how do i carry out the calculations?
    Please help.
    Thanks
    Dany

    hi Dn,
    That would suffice for your requirement .
    Regards,
    Santosh

  • EBS Importing Opening / Closing Balances

    I am Importing EBS via transation FF.5 (APACS EBS), the file is importing all details except the Opening Balance and Closing Balance.  I have checked Algorithm and they are set up.   Using 4.7 Enterprise.  Has anyone got any suggestions.

    Hi,
    There are various t. code to check line items for vendor like: S_ALR_87012103 but Any table is not helping to check opening/closeing balance for vendor.
    Table BSIK and BSAK are having are records for open items and close items for vendor and system calculate the balance by using these tables.
    Regards,
    Vinod

  • Calculating Opening & Closing Balances

    Hi Experts.
    I want to know how to calculate Opening & closing Balances of stock Like MB5B transaction using reports.
    I am giving Material N0, Posting date,Plant as Input
    & want to extract Material Document Number, Quantity, Issues & receipts seperately, Opening & Closing Balance of Stock.Also it should be performed day wise.
    This report should be a normal report without using ALV's.
    Can Some Body Help me. Also let me know which tables & fields are being used.
    Thanks.
    Ravi S

    Hi,
    There are various t. code to check line items for vendor like: S_ALR_87012103 but Any table is not helping to check opening/closeing balance for vendor.
    Table BSIK and BSAK are having are records for open items and close items for vendor and system calculate the balance by using these tables.
    Regards,
    Vinod

  • Mismatchin in opening & closing balance  ofj2i9 & j2i6 register

    Hi,
    We have done utilization on 1st of Month but the posting date was entered as 31st of previous month.
    Now the system showing mismatch in J2I9 & J2I6 between opening & closing balances for the previous period. The entry is missing in J2I9 but the same it is showing in J2I6 as Dr Entry. Why the system is not showing the Dr Entry in J2I9.And moreover the opening & closing balances are matching for the current and last month, but there is mismatch in the month of Dec in the same month utilization was carried out on 1st of Jan but posting date was entered as 31st Dec. What could be reason?
    Rgs

    HI !
    Now that we have not maintained the values in J_2iRG1bal, so how do I  correct the problem, what should I do so that the opening balance & closing balance values appear in the RG1 report.
    Kindly suggest.
    Regards,
    DGN

  • Getting Opening & Closing Balance in Customer Ledger Report

    Hi Guys.
    I am developing a report of Customer Ledger. There I have to display the Opening Balance & Closing balance of individual customers on m onthly basis.
    I have date related objects
    1. Fiscal Year/Period,
    2. Fiscal Year Variant,
    3. Posting Date,
    4. Clearing Date and
    5. Entry Date.

    I am sorry for the above posting...
    Hi Guys.
    I am developing a report of Customer Ledger. There I have to display the Opening Balance & Closing balance of individual customers on m onthly basis from debit amout and .credit amount.
    I have date related objects
    1. Fiscal Year/Period,
    2. Fiscal Year Variant,
    3. Posting Date,
    4. Clearing Date and
    5. Entry Date.
    I have created a variable on posting date with "interval". 
    Please let me know how to restict the keyfigures to get my report to display Opening & Closing Balance.
    ThanX in advance
    Peter

  • Authorization for opening & Closing posting periods - OB52

    Hi,
    Is there any way to set authorization for opening & closing of posting periods in OB52?
    My scenario:
    I have 2 company codes - A & B assigned to 2 different posting period variant - say PPA & PPB.
    The user belonging to CoCd A should not be able to open/close posting period of CoCd B and vice versa.
    Is this possible through any authorization settings?
    Request your help on this.
    Regards,
    Sridevi

    Hi Sridevi
    Please go through the following:
    You can assign authorization groups for permitted posting periods. This means that, for example, some posting periods can only be opened for particular users within monthly or annual closing. You can only assign the authorization group at document header level and it only affects period 1. The authorization object is called F_BKPF_BUP (Accounting document: Authorizations for posting periods). Read the corresponding chapter on "User maintenance" in the "Assigning authorizations" topic.
    "User maintenance"
    Due to the modular authorization concept of the system, you can define authorization profiles which are tailored to the workplace of your employees. You can, for example, assign authorization to a workplace in the Accounts Receivable, Accounts Payable or General Ledger Accounting areas.
    By assigning authorizations you define which business-related objects your employees are allowed to process and which editing functions are allowed.
    In the following activities for authorization management, you must carry out the following for employees who are to work with the system:
    Assign authorizations
    The authorizations are assigned by specifying permitted values for the pre-defined objects.
    Define profiles
    In the SAP system, authorizations are grouped together in workplace profiles. Therefore one or more profiles must be allocated to the individual employee in the master record.
    I hope this helps.
    Regards
    Kavitha

  • SAP Tables  for Open Customer Orders and Sales History

    Dear Experts.
    I am looking to get SAP SD related tables for the following,
    1) SAP tables for Open Customer Orders     
    From SAP, I need to get all tables that Contain all open customer orders for products.
    2) Sales History
    From SAP, I need to get all tables that contain the previous month's sales history (shipped customer orders).
    Please Help!!

    hi
    check the following link
    http://www.erpgenie.com/abap/tables_sd.htm
    hope it will help you
    regards,
    sreelatha gullapalli

  • Table for  Open items of the customer

    Hi all ,
    In whch table can the open items of the customer are stored.
    thanks

    check BSID  table for open items and BSAD for cleared items
    alll the best

  • MB5B Report table for Open and Closing stock on date wise

    Hi Frds,
    I am trying get values of Open and Closing stock on date wise form the Table MARD and MBEW -Material Valuation but it does not match with MB5B reports,
    Could anyone suggest correct table to fetch the values Open and Closing stock on date wise for MB5B reports.
    Thanks
    Mohan M

    Hi,
    Please check the below links...
    Query for Opening And  Closing Stock
    Inventory Opening and Closing Stock
    open stock and closing stock
    Kuber

Maybe you are looking for