Solution : https://service.sap.com/sap/support/notes/369518 (SAP Service marketplace login required)
Summary : 
      When posting a goods issue and goods receipt for a stock transfer using inventory management interfaces such as IDoc or BAPI, the system might generate an error message M7022 due to the current roll area buffer not being refreshed. This error occurs because the stock is initially read from the database for goods issues and from the buffer for goods receipts, which can reflect outdated data if a corresponding goods issue has occurred. To resolve this, ensure to refresh the buffer by changing the roll area. This can be done by logging off and back in, or using the `CALL FUNCTION` command with `DESTINATION 'NONE'` to initiate buffer refresh by opening a new roll area. Implement these steps within a function module and finalize the process using `RFC_CONNECTION_CLOSE` to effectively manage the correct session state and buffer data integrity.
Key words : 
command           call function func destination ', command call function func destination ', system generates message m7022, abap keyword call function, call function func1 destination ', implement function module rfc_connection_close, call function rfc_connection_close, call function 'bapi_transaction_commit', call function 'bapi_transaction_rollback', inventory management interface
Related Notes : 
       
| 738673 | GR: Error during multiple posting of stock transfer docs | 
| 520813 | FAQ: BAPIs for goods movements | 
| 457499 | No material document generated for BAPI BAPI_GOODSMVT_CREATE |