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

Dump when using the BAPI_ACC_DOCUMENT_POST

Former Member
2,264

Hi,

I am using BAPI_ACC_DOCUMENT_POST to create some gl entries. When saving a sales document, we have customized a message type that trigger a program creating the gl entries. The program used BAPI_ACC_DOCUMENT_POST and is trigger in update task. The problem is that we are getting a dump because the BAPI is calling the MF CALCULATE_TAX_DOCUMENT which at one point call a screen (300). The error description is POSTING_ILLEGAL_STATEMENT, CALL SCREEN is not allowed program "SAPLTAX1".

I have tried to search the OSS notes but I could not find one that describe the same problem. Moreover my SAP version does not support direct tax posting. (SAP_APPL--> SAPKH60007). I'm a bit lost as what to do to make use of the BAPI

Have one of you ever encounter the same problem and can you please advise? Thank you.

4 REPLIES 4
Read only

Former Member
0 Likes
1,323

Hi!

Please check sample program ACC_BAPI_TEST_DOCUMENT to see if it helps!

There you have a sample ob how to use this bapi.

Hope it helps.

Best regards,

Esteban

Read only

Former Member
0 Likes
1,323

In BAPI did u pass parameter as show follow?


 CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = documentheader
      TABLES
        accountgl      = accountgl
        currencyamount = currencyamount
        return         = return
        extension1     = extension1
      EXCEPTIONS
        OTHERS         = 1.
    IF sy-subrc <> 0.
      MESSAGE e999(re) WITH 'Problem occured'.
    ELSE.
      .
      LOOP AT return.
        IF NOT return IS INITIAL.
          CLEAR bapi_retn_info.
          MOVE-CORRESPONDING return TO bapi_retn_info.
          IF return-type = 'A' OR return-type = 'E'.
            error_flag = 'X'.
          ENDIF.
          APPEND bapi_retn_info.
        ENDIF.
      ENDLOOP.
      IF error_flag = 'X'.
        MESSAGE e999(re) WITH 'Problem occured'.
        ROLLBACK WORK.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = gs_wait
          IMPORTING
            return = wa_comm_return.
        WRITE :/ return-message+0(30),return-message+36(10).
      ENDIF.

    ENDIF.

Read only

Former Member
0 Likes
1,323

Did not pass values in the AWKEY

Read only

dominik-st
Participant
0 Likes
1,323

Hi!

This is obviously an old thread, but nevertheless there is a solution.

You cannot call the BAPI inside the update task because it performs a CALL SCREEN Statement.

You can call the BAPI in tRFC, this should work as follows:

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

        DESTINATION 'NONE'

         EXPORTING

           documentheader    = gs_documentheader

*         CUSTOMERCPD       =

*         CONTRACTHEADER    =

         IMPORTING

*         OBJ_TYPE          =

           obj_key           = lv_key

*         OBJ_SYS           =

         TABLES

           accountgl         = it_accountgl

*         ACCOUNTRECEIVABLE =

           accountpayable    = it_accountpayable

           accounttax        = it_accounttax

           currencyamount    = it_currencyamount

*         CRITERIA          =

*         VALUEFIELD        =

*         EXTENSION1        =

           return            = it_return

*         PAYMENTCARD       =

*         CONTRACTITEM      =

*         EXTENSION2        =

*         REALESTATE        =

*         ACCOUNTWT         =

         .

     LOOP AT it_return TRANSPORTING NO FIELDS

       WHERE type CA 'AEX'.

     ENDLOOP.

     IF  sy-subrc <> 0.

       rv_key = lv_key.

       IF iv_testmode IS INITIAL.

         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

           DESTINATION 'NONE'

           EXPORTING

             wait = 'X'.

         CALL FUNCTION 'RFC_CONNECTION_CLOSE'

           EXPORTING

             destination          = 'NONE'

           EXCEPTIONS

             destination_not_open = 1

             OTHERS               = 2.

       ENDIF.

     ENDIF.

Best regards

Dominik