33

FM/BAPI to post Physical Inventory

 2 years ago
source link: https://blogs.sap.com/2022/03/10/fm-bapi-to-post-physical-inventory/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
March 10, 2022 1 minute read

FM/BAPI to post Physical Inventory

I found this issue in many requirements related to physical inventory so i thought to share with you all with easy option to resolve this. Other than using BDC, which I personally don’t prefer unless there is no other way available.

There are standard way’s to create MI01/MI04/MI07 using below Function modules,

BAPI_MATPHYSINV_CREATE_MULT -- Create Physical Inventory Doc MI01
BAPI_MATPHYSINV_COUNT --- Add Count MI04
BAPI_MATPHYSINV_POSTDIFF --- Post Difference

You need to call these BAPI’s in sequence and you must use commit work after each BAPI call.

This is will work perfect with happy scenario but there will be issue if 2nd or 3rd bapi fails by some reason. It is difficult to reverse or revert back the created physical inventory document.

To solve this you need to call below Function module to delete the document created.

MB_PHYSICAL_INVENTORY

You need to call this FM 2 times and then commit work.

Step1:

MB_PHYSICAL_INVENTORY 
with 
SIIKF - which you can fill from IIKF table - pass DSTAT=LSTAT=ZSTAT = 'X'
Inv action - 1
ctcod - 'MI02'
t_iiseg - which you can fill from IISEG table - PASS XLOEK = 'X'

Step 2: Same as Step1 but just change in Inv Action

MB_PHYSICAL_INVENTORY 
with 
SIIKF - which you can fill from IIKF table - pass DSTAT=LSTAT=ZSTAT = 'X'
Inv action - 2
ctcod - 'MI02'
t_iiseg - which you can fill from IISEG table - PASS XLOEK = 'X'

Step 3: Commit Work

This will help in delete or changing anything from physical inventory document.

There are some more functions which you can explore with this FM as it allows you to create/count/post directly with MI10.

Hope this helps.

Thank you.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK