2012 Dec 03 7:56 AM
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
2012 Dec 03 8:11 AM
2012 Dec 03 12:04 PM
I think that the problem is because that BAPI
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.
2012 Dec 03 12:09 PM
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.
2012 Dec 03 12:16 PM
Do you have an example how should I write a wrapper or link in Internet?
Regards
Vladislav
2012 Dec 03 12:24 PM
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
2012 Dec 03 12:39 PM
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.
2012 Dec 03 1:26 PM
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.
2012 Dec 03 1:51 PM
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
2012 Dec 10 7:35 AM
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
2012 Dec 03 12:48 PM
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
2012 Dec 10 7:36 AM
Hello Raymond,
I call the BAPI with SAP Netweaver Gateway Client,
not from ABAP Code
Regards
Vladislav
2012 Dec 10 7:51 AM
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