Skip to Content
avatar image
Former Member

BAPI for FB60

Hi guru'd,

i have some vender documents in excel and i have to post it in FB60, is there any BAPI for the same?

please tell me with codes.

regards Nitin.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 20, 2008 at 12:36 PM

    Hi,

    For FB60 use any of the following BAPI,

    BAPI_ACC_DOCUMENT_POST or BAPI_ACC_GL_POSTING_POST

    Sample code:

    DATA: doc_header LIKE bapiache08,
          doc_item   LIKE bapiacgl08 OCCURS 0 WITH HEADER LINE,
          doc_values LIKE bapiaccr08 OCCURS 0 WITH HEADER LINE,
          return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
          obj_type   LIKE bapiache08-obj_type,
          obj_key    LIKE bapiache02-obj_key,
          obj_sys    LIKE bapiache02-obj_sys,
          docnum     LIKE bkpf-belnr.
     
    * Get last SA type document posted to build document key.
    SELECT MAX( belnr )
      INTO docnum
      FROM bkpf
      WHERE bukrs = '1500'
        AND bstat = ' '
        AND blart = 'SA'
        AND gjahr = sy-datlo(4).
    * Create new document number to be used.
    docnum = docnum + 1.
    * Begin to populate docnument header.
    CONCATENATE '0' docnum '00' sy-datlo(4) INTO doc_header-obj_key.
    doc_header-obj_type = 'ZBKPF'.
    CONCATENATE sy-sysid '150' INTO doc_header-obj_sys.
    doc_header-username = sy-uname.
    doc_header-header_txt = 'TEST BOC BAPI POSTING'.
    doc_header-comp_code = '1500'.
    doc_header-doc_date = '20040901'.
    doc_header-pstng_date = sy-datlo.
    doc_header-doc_type = 'SA'.
    CONCATENATE '0' docnum INTO docnum.
    doc_header-fisc_year = '2004'.
    doc_header-ac_doc_no = docnum.
    * Fill Line 1 of Document Item
    doc_item-itemno_acc = '1'.
    doc_item-gl_account = '0000084600'.
    doc_item-stat_con = 'S'.
    doc_item-pstng_date = sy-datlo.
    doc_item-item_text = 'TEST POSTING DEBIT ITEM'.
    doc_item-costcenter = '0000006300'.
    doc_item-orderid = 'M5253'.
    APPEND doc_item.
    CLEAR doc_item.
    * Fill Line 2 of Document Item
    doc_item-itemno_acc = '2'.
    doc_item-gl_account = '0000021960'.
    doc_item-stat_con = 'H'.
    doc_item-pstng_date = sy-datlo.
    doc_item-item_text = 'TEST POSTING CREDIT ITEM'.
    APPEND doc_item.
    CLEAR doc_item.
    * Fill Line 1 of Document Value.
    doc_values-itemno_acc = '1'.
    doc_values-currency_iso = 'GBP'.
    doc_values-amt_doccur = '0.02'.
    APPEND doc_values.
    CLEAR doc_values.
    * Fill Line 2 of Document Value
    doc_values-itemno_acc = '2'.
    doc_values-currency_iso = 'GBP'.
    doc_values-amt_doccur = '0.02'.
    APPEND doc_values.
    CLEAR doc_values.
    * All tables filled - now call BAPI.
    CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
      EXPORTING
        documentheader       = doc_header
    * IMPORTING
    *   OBJ_TYPE             =
    *   OBJ_KEY              =
    *   OBJ_SYS              =
      TABLES
        accountgl            = doc_item
        currencyamount       = doc_values
        return               = return
    *   EXTENSION1           =
              .
    LOOP AT return WHERE type = 'E'.
      EXIT.
    ENDLOOP.
    IF sy-subrc EQ 0.
      WRITE: / 'BAPI call failed - debug and fix!'.
    ELSE.
      CLEAR return.
      REFRESH return.
    *  COMMIT WORK AND WAIT.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    * EXPORTING
    *   WAIT          =
       IMPORTING
         return        = return.
      WRITE: / 'BAPI call worked!!'.
      WRITE: / doc_header-obj_key, ' posted'.
    ENDIF.

    Regards,

    Manoj Kumar P

    Edited by: Manoj Kumar on Dec 20, 2008 1:37 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I have tried a lot, However BAPI is available for MIRO to park or held the documents. Where for FB60, BAPI or FM is not available to park/held the documents. FM is available for posting the documents.

      Thanks,

      Kiran.

  • Dec 20, 2008 at 09:33 AM

    Look at OSS [Note 306504 - Collective note: BAPIs for the AC interface|https://service.sap.com/sap/support/notes/306504] and perform some search at SDN on keywords: [BAPI FB60|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_forums_rm&query=bapi+fb60&adv=false&sortby=cm_rnd_rankvalue] to look for samples.

    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 20, 2008 at 01:59 PM

    HI,

    Check these given links:

    bapi-for-txn-fb60

    bapi-for-fb60

    Hope this will work for you.

    Regards:

    Alok

    Add comment
    10|10000 characters needed characters exceeded