Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI for FB60

Former Member
0 Likes
19,285

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
9,361

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

7 REPLIES 7
Read only

RaymondGiuseppi
Active Contributor
0 Likes
9,361

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

Read only

Former Member
0 Likes
9,362

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

Read only

0 Likes
9,361

Hi Manjo,

I need to park an vendor invoice in fb60 .would you pls tell me which is the bapi used for that??

Read only

0 Likes
9,361

Hi Karthik,

Already one more thread was open with the same question. Please check.

FI vendor invoice PARKING for transaction FB60

http://scn.sap.com/message/10193927

Thanks,

Kiran

Read only

0 Likes
9,361

Hi,

Thank you for your reply. you are try to say that there  is no bapi available for this

Read only

0 Likes
9,361

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.

Read only

Former Member
0 Likes
9,361

HI,

Check these given links:

Hope this will work for you.

Regards:

Alok