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

Error with RFC call BAPI 'BAPI_GOODSMVT_CREATE'

Former Member
0 Likes
2,559

Hello,

I want to call BAPI 'BAPI_GOODSMVT_CREATE' from IDES system via RFC and I get following Exception

(from SAP Netweaver Gateway)

'RFC call was not successful because of system failure 'Statement MESSAGE E is not allowed in this form.''

Can you give an advice?

Best Regards

Vladislav

12 REPLIES 12
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,133

The BAPI without enhancement should never raise a message error, but fill return table, so look for

  • customer-exits or BAdI that performs customer checks and raise such a message - CMOD, SE19
  • message (like print form or mail) in which customer driver program raise such a message, NACE

Regards,

Raymond

Read only

0 Likes
2,133

I think that the problem is because that BAPI

'BAPI_GOODSMVT_CREATE'

can not be called via RFC.

13.        Question:

        If you attempt to execute a goods movement via Business Connector

        and call the BAPI via RFC (Remote Function Call), this returns the

        material document. However, this document does not exists in the R/3

        system. What is to be done?

        Answer:
                                                                      Page 7
        The call of BAPI_GOODSMVT_CREATE via RFC does not work as an RFC
        also creates a new LUW (Logical Unit of Work). As a result, no
        Commit or rollback can take place with reference to this BAPI and
        thus the posting cannot be carried out.
        Instead of a call via RFC, a report can be written that calls the
        BAPI and then executes a Commit or a rollback dependent on the
        contents of the return table.
Read only

0 Likes
2,133

Yes you are right. I faced the same problem in BAPI_GOODSMVT_CREATE. This FM does raise hardcore messages instead of populating return table. Not sure why SAP has coded it like this. You could create a wrapper RFC for this BAPI and trap the error message via exception ERROR_MESSAGE and populate the return table of your custom wrapper RFC.

Read only

0 Likes
2,133

Do you have an example how should I write a wrapper or link in Internet?

Regards

Vladislav

Read only

0 Likes
2,133

Note 520813 - FAQ: BAPIs for goods movements, I suppose ?

So duplicate the FM BAPI_GOODSMVT_CREATE into Z_BAPI_GOODSMVT_CREATE in one of your Z_function groups (will be RFC enabled), keep only the signatuer, then in your code call the BAPI_GOODSMVT_CREATE and BAPI_TRANSACTION_COMMIT.  In the call of the BAPI manage the exception error_message = 1 and fill an error in RETURN PARAMETER.

Regards,

Raymond

Read only

0 Likes
2,133

Sample

FUNCTION z_bapi_goodsmvt_create.

*"----------------------------------------------------------------------

*"*"Interface locale :

*"  IMPORTING

*"     VALUE(GOODSMVT_HEADER) LIKE  BAPI2017_GM_HEAD_01 STRUCTURE

*"        BAPI2017_GM_HEAD_01

*"     VALUE(GOODSMVT_CODE) LIKE  BAPI2017_GM_CODE STRUCTURE

*"        BAPI2017_GM_CODE

*"     VALUE(TESTRUN) LIKE  BAPI2017_GM_GEN-TESTRUN DEFAULT SPACE

*"     VALUE(GOODSMVT_REF_EWM) LIKE  /SPE/BAPI2017_GM_REF_EWM STRUCTURE

*"        /SPE/BAPI2017_GM_REF_EWM OPTIONAL

*"  EXPORTING

*"     VALUE(GOODSMVT_HEADRET) LIKE  BAPI2017_GM_HEAD_RET STRUCTURE

*"        BAPI2017_GM_HEAD_RET

*"     VALUE(MATERIALDOCUMENT) TYPE  BAPI2017_GM_HEAD_RET-MAT_DOC

*"     VALUE(MATDOCUMENTYEAR) TYPE  BAPI2017_GM_HEAD_RET-DOC_YEAR

*"  TABLES

*"      GOODSMVT_ITEM STRUCTURE  BAPI2017_GM_ITEM_CREATE

*"      GOODSMVT_SERIALNUMBER STRUCTURE  BAPI2017_GM_SERIALNUMBER

*"       OPTIONAL

*"      RETURN STRUCTURE  BAPIRET2

*"      GOODSMVT_SERV_PART_DATA STRUCTURE

*"        /SPE/BAPI2017_SERVICEPART_DATA OPTIONAL

*"      EXTENSIONIN STRUCTURE  BAPIPAREX OPTIONAL

*"----------------------------------------------------------------------

  DATA ls_return  TYPE bapiret2.

  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

    EXPORTING

      goodsmvt_header         = goodsmvt_header

      goodsmvt_code           = goodsmvt_code

      testrun                 = testrun

      goodsmvt_ref_ewm        = goodsmvt_ref_ewm

    IMPORTING

      goodsmvt_headret        = goodsmvt_headret

      materialdocument        = materialdocument

      matdocumentyear         = matdocumentyear

    TABLES

      goodsmvt_item           = goodsmvt_item

      goodsmvt_serialnumber   = goodsmvt_serialnumber

      return                  = return

      goodsmvt_serv_part_data = goodsmvt_serv_part_data

      extensionin             = extensionin

    EXCEPTIONS

      error_message           = 1.

  CLEAR ls_return.

  IF sy-subrc EQ 0.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      IMPORTING

        return = ls_return.

  ELSE.

    CALL FUNCTION 'BALW_BAPIRETURN_GET2'

      EXPORTING

        type   = sy-msgty

        cl     = sy-msgid

        number = sy-msgno

        par1   = sy-msgv1

        par2   = sy-msgv2

        par3   = sy-msgv3

        par4   = sy-msgv4

      IMPORTING

        return = ls_return.

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  ENDIF.

ENDFUNCTION.

Read only

0 Likes
2,133

As Raymond has suggested you can proceed like that. But I don't think you need a explicit BAPI_TRANSACTION_COMMIT here SAP will commit automatically when  the RFC connection closes. If you need the commit still you can have at least an importing parameter(eg IM_COMMIT_FLAG) and issue the commit based on the flag instead of forcefully committing every time.

Read only

0 Likes
2,133

here SAP will commit automatically when  the RFC connection closes.

I'm not sure of that, read the answer nr 13 in Note 520813 - FAQ: BAPIs for goods movements

Answer:

The call of BAPI_GOODSMVT_CREATE using RFC does not work because an RFC  also creates a new LUW (Logical Unit of Work). As a result, no Commit or  rollback can take place with reference to this BAPI and therefore, the posting cannot be carried out.

You could use the "testrun" field to trigger the commit or not, but you could add a WAIT parameter similar to the one of BAPI_TRANSACTION_COMMIT.

Regards,

Raymond

Read only

0 Likes
2,133

Hello Raymond,

I implemented this function but I still get an Exception

"'Statement MESSAGE E is not allowed in this form.''", but

from this new Function.

Regards

Vladislav

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,131

Also did you manage the two specific exceptions SYSTEM_FAILURE or COMMUNICATION_FAILURE in the RFC call ?

Try to use the full extended syntax with exceptions

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'  DESTINATION dest

(...)

EXCEPTIONS

  SYSTEM_FAILURE        = 1 MESSAGE smess

  COMMUNICATION_FAILURE = 2 MESSAFE smess.

Regards,

Raymond

Read only

0 Likes
2,131

Hello Raymond,

I call the BAPI with SAP Netweaver Gateway Client,

not from ABAP Code

Regards

Vladislav

Read only

0 Likes
2,131
  • Did you successfully call other BAPI with the SAP NetWeaver Gateway ?
  • Can you test the BAPI call from an ABAP AS ?
  • Did you try to analyze error from Gateway side - /IWFND/ERROR_LOG or /IWBEP/ERROR_LOG ?
  • Did you try to analyze error from Abap side - SLG1, RZ20, ST22, ST01 ?

If the error message is triggered cause of wrong customer-exit or BADI implementation, you should get the error in a small Abap report testing the BAPI call and continue on this discussion, else you should better post in SAP NetWeaver Gateway space.

Regards,

Raymond