‎2013 Jul 08 3:30 PM
Hi Everyone-
My requirement is to automatically do a 261 and 262 movement from my program. The way I am achieving this is by using the SAP BAPI "BAPI_GOODSMVT_CREATE". I have to post both these movements only if both are successful. So I am executing the BAPI for the 261 first without the COMMIT and then for the 262 without the COMMIT. I am storing the returns I get from both these BAPI's and only if there is no error message in the return I am executing both these BAPI's again with the COMMIT statement. This approach worked for non-serialized materials but when I try to do it for a serialized material I am getting an error "Stock data of serial number XXX not suitable for movement" on my second attempt of the BAPI. Is there some kind of refresh I need to perform after my first call?
Below is the flow of my code:
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "with the 261 movement.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "with the 262 movement.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
if gt_return IS INITIAL.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "with the 261 movement.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' "with the 262 movement.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
‎2013 Jul 08 4:05 PM
Hi,
Use the Destination 'NONE' Statement and also use RFC_CONNECTION_CLOSE.
Find the below code :
if gt_return IS INITIAL.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' DESTINATION 'NONE'. "with the 261 movement.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE'.
* Close RFC connection
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = 'NONE'.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' DESTINATION 'NONE'. "with the 262 movement.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE'..
* Close RFC connection
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = 'NONE'.
ENDIF.
Message was edited by: Aeda N
‎2013 Jul 08 5:53 PM
First try to post data manually using MIGO with same data that you are using in your program to ensure that this error is not due to incorrect data or some customizing setting. Then,please make sure to clear the structures and internal tables first and then populating them again before each bapi call, specially check the TABLES parameter: i_gm_serialnumber.
Following link might be helpful to you:
http://scn.sap.com/thread/3269123
http://scn.sap.com/thread/57228
Regards