Application Development 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: 

BAPI_ACC_DOCUMENT_POST in down payment

Former Member
0 Kudos

Hi!

When i create a Purchase order i have to make an automatic down payment request (F-47), i'm working with an user exit that calls the BAPI_ACC_DOCUMENT_POST bapi from the PO transaction. Anybody have a code example on how to use this bapi with this scenario?. I made a local program to test the bapi with this call:

CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

EXPORTING

DOCUMENTHEADER = WA_DOCHEAD

  • CUSTOMERCPD =

  • CONTRACTHEADER =

TABLES

  • ACCOUNTGL =

  • ACCOUNTRECEIVABLE =

ACCOUNTPAYABLE = IT_VENDOR

  • ACCOUNTTAX =

CURRENCYAMOUNT = IT_CURRENCY

  • CRITERIA =

  • VALUEFIELD =

  • EXTENSION1 =

RETURN = IT_RETURN

  • PAYMENTCARD =

  • CONTRACTITEM =

  • EXTENSION2 =

  • REALESTATE =

.

The IT_RETURN itab from BAPI_ACC_DOCUMENT_CHECK returns "Document check - no errors" .

the IT_RETURN itab from BAPI_ACC_DOCUMENT_POST returns

"Document posted successfully"

But no document had been posted! i look at the BKPF itab and nothing was created.

Please help.

Thanks in advance.

John.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Need to commit your work in the test program. May not need to do it in the user exit if it is called before PO save.

Use BAPI_TRANSACTION_COMMIT to commit your work, there is a WAIT (set it to 'X') parameter if you want the commit to be synchronous.

Rishi

11 REPLIES 11

Former Member
0 Kudos

Need to commit your work in the test program. May not need to do it in the user exit if it is called before PO save.

Use BAPI_TRANSACTION_COMMIT to commit your work, there is a WAIT (set it to 'X') parameter if you want the commit to be synchronous.

Rishi

0 Kudos

Hi Rishi !

I am using the bapi commit. here's the test code:


*&---------------------------------------------------------------------*
*& Report  YPRUEBA_BAPI_DOCUMENT_POST                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  YPRUEBA_BAPI_DOCUMENT_POST              .
*     ******************************************************************
*     ************* LLENAR ESTRUCTURAS BAPI ****************************
*     ******************************************************************
      DATA: WA_DOCHEAD      TYPE BAPIACHE09,
            IT_ACCOUNT      TYPE TABLE OF BAPIACGL09,
            WA_ACCOUNT      TYPE BAPIACGL09,
            IT_CURRENCY     TYPE TABLE OF BAPIACCR09,
            WA_CURRENCY     TYPE BAPIACCR09,
            IT_VENDOR       TYPE TABLE OF BAPIACAP09,
            WA_VENDOR       TYPE BAPIACAP09,
            IT_RETURN       TYPE TABLE OF BAPIRET2,
            WA_RETURN       TYPE BAPIRET2,
            WA_CRITERIA     TYPE BAPIACKEC9,
            WA_CURRENCY_EXT TYPE P DECIMALS 2.
      DATA: KEY(19)         TYPE C.
      DATA: COMMIT_RET      TYPE BAPIRET2.

      REFRESH: IT_ACCOUNT,
               IT_CURRENCY,
               IT_RETURN.
      CLEAR:   WA_DOCHEAD,
               WA_ACCOUNT,
               WA_CURRENCY,
               WA_RETURN,
               WA_CRITERIA,
               WA_CURRENCY_EXT.
*     FILL KEY FIELD
      KEY = '0000000000'.
      KEY+11(4) = '2000'.
      KEY+15(4) = '2005'.
**************************************
      WA_DOCHEAD-USERNAME   = SY-UNAME.
      WA_DOCHEAD-OBJ_TYPE   = 'IDOC'.
      WA_DOCHEAD-OBJ_KEY    = KEY.
      WA_DOCHEAD-OBJ_SYS    = 'Z220'.
      WA_DOCHEAD-COMP_CODE  = '2000'. "SOCIEDAD
      WA_DOCHEAD-DOC_DATE   = SY-DATUM.
      WA_DOCHEAD-PSTNG_DATE = SY-DATUM.
      WA_DOCHEAD-TRANS_DATE = SY-DATUM.
      WA_DOCHEAD-DOC_TYPE   = 'KA'.
      WA_DOCHEAD-BUS_ACT    = 'RFBU'.
      CONCATENATE 'Solicitud de anticipo. Fecha:' SY-DATUM
                                          INTO WA_DOCHEAD-HEADER_TXT.
***********************************
*      WA_ACCOUNT-TAX_CODE   = 'C3'.
*      WA_ACCOUNT-ACCT_TYPE  = 'K'.
*      WA_ACCOUNT-ITEMNO_ACC = '0000000010'.
*      WA_ACCOUNT-GL_ACCOUNT = '1121501001'.
*      WA_ACCOUNT-VALUE_DATE = SY-DATUM.
*      WA_ACCOUNT-CUSTOMER   = '2000015'.
*      WA_ACCOUNT-ITEM_TEXT  = 'Posición anticipo'.
*      WA_ACCOUNT-DOC_TYPE   = 'KA'.
*      WA_ACCOUNT-COMP_CODE  = '2000'.
*      WA_ACCOUNT-PSTNG_DATE = SY-DATUM.
*      WA_ACCOUNT-COSTCENTER = SPACE.
*      WA_ACCOUNT-ALLOC_NMBR = 'Nº asignación'.
*      WA_ACCOUNT-PROFIT_CTR = SPACE.
*      WA_ACCOUNT-ORDERID    = SPACE.
*      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*           EXPORTING
*             INPUT  = WA_ACCOUNT-CUSTOMER
*           IMPORTING
*             OUTPUT = WA_ACCOUNT-CUSTOMER.
*      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*           EXPORTING
*             INPUT  = WA_ACCOUNT-GL_ACCOUNT
*           IMPORTING
*             OUTPUT = WA_ACCOUNT-GL_ACCOUNT.
*      APPEND WA_ACCOUNT TO IT_ACCOUNT.
*      CLEAR  WA_ACCOUNT.

*************************************
      WA_CURRENCY-ITEMNO_ACC   = '0000000010'.
      WA_CURRENCY-CURR_TYPE    = '00'.
      WA_CURRENCY-CURRENCY     = 'USD'.
*     WA_CURRENCY-AMT_DOCCUR   = '150000.00'.
      WA_CURRENCY-AMT_BASE     = '15000.00'.
      APPEND WA_CURRENCY TO IT_CURRENCY.
      CLEAR WA_CURRENCY.

*************************************
      WA_VENDOR-ITEMNO_ACC   = '0000000010'.
      WA_VENDOR-VENDOR_NO    = '2000015'.
      WA_VENDOR-SP_GL_IND    = 'A'.
*      WA_VENDOR-TAX_CODE     = 'C3'.
      WA_VENDOR-COMP_CODE    = '2000'.
      WA_VENDOR-GL_ACCOUNT   = '1121501001'.
      WA_VENDOR-BLINE_DATE   = '20050510'.
      WA_VENDOR-PYMT_AMT     = '150000.00'.
      WA_VENDOR-PYMT_CUR     = 'VEB'.
*      WA_VENDOR-PYMT_CUR_ISO = 'VEB'.
      WA_VENDOR-PMNTTRMS     = 'Z001'.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
           EXPORTING
             INPUT  = WA_VENDOR-GL_ACCOUNT
           IMPORTING
             OUTPUT = WA_VENDOR-GL_ACCOUNT.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
           EXPORTING
             INPUT  = WA_VENDOR-VENDOR_NO
           IMPORTING
             OUTPUT = WA_VENDOR-VENDOR_NO.
      APPEND WA_VENDOR TO IT_VENDOR.
      CLEAR WA_VENDOR.

*     PROBAMOS LA BAPI
      REFRESH IT_RETURN.
      CLEAR   WA_RETURN.
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
        EXPORTING
          DOCUMENTHEADER          = WA_DOCHEAD
*         CUSTOMERCPD             =
*         CONTRACTHEADER          =
        TABLES
*         ACCOUNTGL               =
*         ACCOUNTRECEIVABLE       =
          ACCOUNTPAYABLE          = IT_VENDOR
*         ACCOUNTTAX              =
          CURRENCYAMOUNT          = IT_CURRENCY
*         CRITERIA                =
*         VALUEFIELD              =
*         EXTENSION1              =
          RETURN                  = IT_RETURN
*         PAYMENTCARD             =
*         CONTRACTITEM            =
*         EXTENSION2              =
*         REALESTATE              =
                .
*     Se leen los resultados del posteo
*     el mensaje S RW 614 indica que el chequeo fue exitoso
      READ TABLE it_return INTO wa_return WITH KEY type    = 'S'
                                                     id      = 'RW'
                                                     number  = '614'.
      IF SY-SUBRC = 0.
         REFRESH IT_RETURN.
         CLEAR   WA_RETURN.
         CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
           EXPORTING
             DOCUMENTHEADER          =  WA_DOCHEAD
*            CUSTOMERCPD             =
*            CONTRACTHEADER          =
*          IMPORTING
*            OBJ_TYPE                =
*            OBJ_KEY                 =
*            OBJ_SYS                 =
           TABLES
*            ACCOUNTGL               =
*            ACCOUNTRECEIVABLE       =
             ACCOUNTPAYABLE          =  IT_VENDOR
*            ACCOUNTTAX              =
             CURRENCYAMOUNT          =  IT_CURRENCY
*            CRITERIA                =
*            VALUEFIELD              =
*            EXTENSION1              =
             RETURN                  =  IT_RETURN
*            PAYMENTCARD             =
*            CONTRACTITEM            =
*            EXTENSION2              =
*            REALESTATE              =
                   .
*        Se leen los resultados del posteo
*        el mensaje S RW 605 indica que el POST fue exitoso
         READ TABLE it_return INTO wa_return WITH KEY type      = 'S'
                                                        id      = 'RW'
                                                        number  = '605'.
         IF SY-SUBRC = 0.
            CLEAR COMMIT_RET.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
             EXPORTING
               WAIT          = 'X'
             IMPORTING
               RETURN        =  COMMIT_RET
                      .
         ELSE.
            MESSAGE S162(00) WITH 'Error en el Posteo'.
         ENDIF.
      ELSE.
         MESSAGE S162(00) WITH 'Error en el chequeo'.
      ENDIF.

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:24 AM

0 Kudos

<i>You may not be able to use this BAPI to post Payment requests F-47 (not down payment) as there is not financial impact from this transaction.</i>

That being said, try the following.

Try replacing


wa_vendor-gl_account = '1121501001'.
wa_vendor-bline_date = '20050510'.</b>
wa_vendor-pymt_amt = '15000.00'.
wa_vendor-pymt_cur = 'VEB'.
* WA_VENDOR-PYMT_CUR_ISO = 'VEB'.
wa_vendor-pmnttrms = 'Z001'.

with


*wa_vendor-gl_account = '1121501001'.
*wa_vendor-bline_date = '20050510'.
wa_vendor-pymt_amt = '15000.00'.
wa_vendor-pymt_cur = 'VEB'.
* WA_VENDOR-PYMT_CUR_ISO = 'VEB'.
*wa_vendor-pmnttrms = 'Z001'.

Also noticed that the header currency and amount are different.

also try


wa_vendor-sp_gl_ind = 'F'. "Payment Request

instead of


wa_vendor-sp_gl_ind = 'A'.

could not test the code here as my system is not setup for down payments.

also not sure you need 'BAPI_ACC_DOCUMENT_CHECK'. You can always use 'BAPI_TRANSACTION_ROLLBACK' to clear the buffer if required.

Rishi

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:24 AM

0 Kudos

Hi Rishi,

If you successed by doing , please share the code ..

Regards:

Sridhar.J

Former Member
0 Kudos

Posting a FI document using the structure BAPIACAP09 for payment data you will need two different currencies, in this case you use 'USD' as the document currency and 'VEB' as payment currency. Then when you gonna make the automatic payment you will have more problems. This is a document with two different currencies.

How to solve this problem?

Former Member
0 Kudos

Hi,

I've found your post during searching solution of the same problem with yours - using bapi for f-47.

I wonder you have finished your work.

It will be very helpful if you post your working code and some instructions.

Best regards,

Lee

Former Member
0 Kudos

Hello, I call to the function and it gives back a message to me saying that this all correct one, but does not record I

I use the function BAPI_ACC_DOCUMENT_POST and BAPI_TRANSACTION_COMMIT

I pass to the function the following values to him:

From these tables BKPF and BSEG position the tables that the function uses

    MOVE sy-uname           TO wa_bkpf-usnam.
    MOVE t_bkpf-bktxt       TO wa_bkpf-bktxt.
    MOVE t_bkpf-bukrs       TO wa_bkpf-bukrs.
* Convertir fecha a interno
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
         EXPORTING
              date_external = t_bkpf-bldat
         IMPORTING
              date_internal = wa_bkpf-bldat.
* Convertir fecha a interno
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
         EXPORTING
              date_external = t_bkpf-budat
         IMPORTING
              date_internal = wa_bkpf-budat.
    MOVE wa_bkpf-budat+0(4) TO wa_bkpf-gjahr.
    MOVE t_bkpf-blart       TO wa_bkpf-blart.
    MOVE t_bkpf-xblnr       TO wa_bkpf-xblnr.
    MOVE 'RFBU'             TO wa_bkpf-glvor.
    MOVE t_bkpf-waers       TO wa_bkpf-waers.
    MOVE 'BKPF'             TO wa_bkpf-awtyp.
    MOVE wa_bkpf-budat+4(2) TO wa_bkpf-monat.
    MOVE sy-mandt           TO wa_bkpf-mandt.


    MOVE t_bkpf-bukrs       TO t_bseg_aux-bukrs.
    MOVE t_bseg-bschl       TO t_bseg_aux-bschl.
    MOVE t_bseg-hkont       TO t_bseg_aux-hkont.
* Convertir fecha a interno
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
        EXPORTING
             date_external = t_bseg-valut
        IMPORTING
             date_internal = t_bseg-valut.
    MOVE t_bseg-zuonr       TO t_bseg_aux-zuonr.
    MOVE 'Finanzas'         TO t_bseg_aux-kontl.
    MOVE t_bseg-dmbtr       TO t_bseg_aux-dmbtr.
    MOVE t_bseg-prctr       TO t_bseg_aux-prctr.
    MOVE t_bseg-projk       TO t_bseg_aux-projk.
    MOVE t_bseg-vbund       TO t_bseg_aux-vbund.
    MOVE t_bseg-sgtxt       TO t_bseg_aux-sgtxt.
    MOVE 'S'                TO t_bseg_aux-koart.

Message was edited by: David MG

Former Member
0 Kudos

Even i am trying to use the same bapi but its giving me error that 1. Error in document BKPF $ devclnt300

0 Kudos

Hi,

Does anybody of you are succeeded in posting downpayment requests(F-47) through BAPI_ACC_DOCUMENT_POST?

If so pls guid me how can we achieve this.

Regards,

Nanda.

MaryM
Participant
0 Kudos

Hi everyone!

Has anybody managed to do F-47 with BAPI_ACC_DOCUMENT_POST?

What is the story with two currencies? Im getting the error that tells me to use 2 different amounts (different currencies).

If anyone has managed to solve that, I would really appreciate your solution!

Thanks in advance,

MaryM

Former Member
0 Kudos

Am having the same requirement.

When PO is created, it should trigger automatic Down payment request.

Am using BAPI_PAYMENTREQUEST_CREATE.

What the validation and logic i have to do for this requirement.

Please share ur ideas...