Several times call BAPI_GOODSMVT_CREATE in the user program
Here I will not write about the details of using BAPI_GOODSMVT_CREATE, has already
been written about this many times, and SCN including.
I propose to focus on one small detail, without which multiple call BAPI_GOODSMVT_CREATE will not work correctly.
Why BAPI_GOODSMVT_CREATE called repeatedly in his Z program? For example, you specify parameters for moving material,
but BAPI returned an error. You change something and press the button again, causing BAPI.
So, if the call looks CALL FUNCTION ‘BAPI_GOODSMVT_CREATE’ again you’ll get an error, despite the correct parameters.
But if you specify the addition CALL FUNCTION ‘BAPI_GOODSMVT_CREATE’ DESTINATION ‘NONE’ – the document will be created!
Thus, using DESTINATION ‘NONE’, you can be sure that the data buffer previous calls have no impact!
P.S. It is also necessary to specify DESTINATION ‘NONE’ in calling COMMIT or ROLLBACK like below
IF p_matdoc IS INITIAL .
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’ DESTINATION ‘NONE’.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’ DESTINATION ‘NONE’.
CALL FUNCTION ‘RFC_CONNECTION_CLOSE’ EXPORTING destination = ‘NONE’.