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.