I used BAPI_GOODSMVT_CREATE to cancel good receipt (GMCODE 01 for purchase order and 02 for production order) with MVT=101 AND XSTOB='X'. I didn't use BAPI_GOODSMVT_CANCEL because since I need to set movement reason and also pass serial numbers in some case.
After executing the BAPI, the stock is successfully reversed however the inspection lot created during goods receipt were still exist. How do I removed the inspection lot?
Another thing I noticed is that in MSEG table, Goods Recipt that are cancelled through MIGO has the field SMBLN (material document) populated but via BAPI this field is not populated.