Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BAPI for FB50

Hi Experts,

Is there any BAPI for FB50. BDC is giving me error. When i enter more than 7 items through SHDB recording any i click on insert button, enter the record and then save, it gives me error Specify account number because when i click on insert button, the business area gets applied to all line items, then i have to manually clear the business area. Then only it gets saved. Please suggect me if there is any BAPI for FB50.

Tags:
Former Member
Former Member replied

See this Sample Code..

*&---------------------------------------------------------------------*
*& Report  ZBAPIACCDOCUMENTPOST1                                       *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZBAPIACCDOCUMENTPOST1                   .

*&---HEADER DECLARATION
DATA: HEADER TYPE BAPIACHE09. " HEADER DATA


*&----G/L ACCOUNT ITEM
DATA: ACCOUNTGL TYPE STANDARD TABLE OF BAPIACGL09.


*&----ACCOUNTS PAYABLE ITEMS

DATA: ACCOUNTPAYABLE TYPE STANDARD TABLE OF BAPIACAP09.
DATA: WA_ACCOUNTPAYABLE TYPE BAPIACAP09.

*&---CURRENCY ITEMS
DATA: CURRENCY_AMOUNT TYPE STANDARD TABLE OF BAPIACCR09.

*&----RETURN PARAMETER
DATA: RETURN TYPE STANDARD TABLE OF BAPIRET2 with header line.
**********************************************************************
*	WORK-AREA DECLARATION
**********************************************************************
*&----WORKAREA FOR G/L ACCOUNT ITEM
DATA: WA_ACCOUNTGL TYPE BAPIACGL09.

*&---WORKAREA FOR CURRENCY ITEMS
DATA: WA_CURRENCY_AMOUNT TYPE BAPIACCR09.
**********************************************************************
	INITIALIZATION.
**********************************************************************
HEADER-OBJ_TYPE = 'BEBD'.
HEADER-OBJ_KEY = '1000000050'.
HEADER-OBJ_SYS = 'B3TCLNT800'.
HEADER-HEADER_TXT = 'TEST HEADER'.
HEADER-USERNAME = 'DEVELOPER'.
HEADER-COMP_CODE = 'JKT1'.
HEADER-FISC_YEAR = '2008'.
HEADER-DOC_DATE = SY-DATUM.
HEADER-PSTNG_DATE = SY-DATUM.
HEADER-TRANS_DATE = SY-DATUM.
HEADER-DOC_TYPE = 'KR'.
HEADER-BUS_ACT = 'RMRP'.


*WA_ACCOUNTGL-ITEMNO_ACC = '0000000010'.
*WA_ACCOUNTGL-GL_ACCOUNT = '0000400200'.
*WA_ACCOUNTGL-ITEM_TEXT = 'SO_DOC'.
*WA_ACCOUNTGL-DE_CRE_IND = 'S'.
*wa_accountgl-costcenter = 'JK000'.
*WA_ACCOUNTGL-VENDOR_NO = 'A125'.
*WA_ACCOUNTGL-REF_KEY_3 = '31'.
*
*APPEND WA_ACCOUNTGL TO ACCOUNTGL.
*CLEAR WA_ACCOUNTGL.
*
*WA_ACCOUNTGL-ITEMNO_ACC = '0000000020'.
*WA_ACCOUNTGL-GL_ACCOUNT = '0000400200'.
*WA_ACCOUNTGL-ITEM_TEXT = 'SO_DOC'.
*WA_ACCOUNTGL-DE_CRE_IND = 'H'.
*wa_accountgl-costcenter = 'JK000'.
*WA_ACCOUNTGL-REF_KEY_3 = '40'.
*
*APPEND WA_ACCOUNTGL TO ACCOUNTGL.
*CLEAR WA_ACCOUNTGL.


WA_ACCOUNTPAYABLE-ITEMNO_ACC = '10'.
WA_ACCOUNTPAYABLE-VENDOR_NO = 'A125'.
WA_ACCOUNTPAYABLE-REF_KEY_3 = '31'.
WA_ACCOUNTPAYABLE-BUS_AREA = 'JKTD'.

APPEND WA_ACCOUNTPAYABLE TO ACCOUNTPAYABLE.
CLEAR WA_ACCOUNTPAYABLE.


WA_ACCOUNTPAYABLE-ITEMNO_ACC = '20'.
WA_ACCOUNTPAYABLE-GL_ACCOUNT = '400200'.
WA_ACCOUNTPAYABLE-REF_KEY_3 = '40'.
WA_ACCOUNTPAYABLE-BUS_AREA = 'JKTD'.

APPEND WA_ACCOUNTPAYABLE TO ACCOUNTPAYABLE.
CLEAR WA_ACCOUNTPAYABLE.



WA_CURRENCY_AMOUNT-ITEMNO_ACC = '0000000010'.
WA_CURRENCY_AMOUNT-AMT_DOCCUR = '500'.
WA_CURRENCY_AMOUNT-CURRENCY = 'INR'.
APPEND WA_CURRENCY_AMOUNT TO CURRENCY_AMOUNT.
CLEAR WA_CURRENCY_AMOUNT.

WA_CURRENCY_AMOUNT-ITEMNO_ACC = '0000000020'.
WA_CURRENCY_AMOUNT-AMT_DOCCUR = '-500'.
WA_CURRENCY_AMOUNT-CURRENCY = 'INR'.
APPEND WA_CURRENCY_AMOUNT TO CURRENCY_AMOUNT.
CLEAR WA_CURRENCY_AMOUNT.

**************************************************************
*	START-OF-SELECTION
**************************************************************

START-OF-SELECTION.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    DOCUMENTHEADER          = HEADER
*   CUSTOMERCPD             =
*   CONTRACTHEADER          =
* IMPORTING
*   OBJ_TYPE                =
*   OBJ_KEY                 =
*   OBJ_SYS                 =
  TABLES
*   ACCOUNTGL               = ACCOUNTGL
*   ACCOUNTRECEIVABLE       =
   ACCOUNTPAYABLE          = ACCOUNTPAYABLE
*   ACCOUNTTAX              =
    CURRENCYAMOUNT          = CURRENCY_AMOUNT
*   CRITERIA                =
*   VALUEFIELD              =
*   EXTENSION1              =
    RETURN                  = RETURN
*   PAYMENTCARD             =
*   CONTRACTITEM            =
*   EXTENSION2              =
*   REALESTATE              =
          .


IF return-type EQ 'S'.

COMMIT WORK.
*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
** EXPORTING
**   WAIT          =
* IMPORTING
*   RETURN        = RETURN
*          .
WRITE:/ RETURN-TYPE.
write:/ return-message.

ELSE.
WRITE:/ RETURN-TYPE.
write:/ return-message.

ENDIF.

Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 11:09 AM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question