Inventory count entry by Batch-Input Method with Transaction MI34, MI38, MI39, MI40
Inventory count entry by Batch-Input Method with Transaction MI34, MI38, MI39, MI40
Before you start using Batch-Input method for inventory count entry you should be familiar with the usual transactions for manual entry of physical inventory counts and posting.
Test the manual transactions, note down the entries, as you need to provide the same info in a batch-input.
Use F1 field help, followed by click on technical field help to obtain the table names.
SAP provides batch-input transactions that reference an existing physical inventory document as well as transactions to count without reference.
MI34 Physical Inventory Count with Reference to the Document – manual transaction MI04
MI38 Enter Count with Reference to Document, Post Differences – manual transaction MI08
MI39 Enter Count Without Reference to Document – manual transaction MI09
MI40 Enter Count Without Reference to Document, Post Differences – manual transaction MI10
If you want to use MI34 or MI38, then you have to create the physical inventory document with MI31 first. It can as well be created with MI01, but using MI01 does not make much sense if you are going to automate things, as it is a pure manual creation and probably needs factor 10 time than entering a count using the manual MI04 transaction.
The selection screen of all 4 Batch-input transactions looks equal. Only the defaulted Name of Logical file is different. It is MMIM_PHYSICAL_INVENTORY_DOCUMENTS for MI34 and MI38; MMIM_PHYSICAL_INVENTORY_NO_DOCUMENTS for MI39 and MI40
To setup the batch input method you should read the documentation behind the blue i Icon on top of the selection screen. (and this blog now)
As the Logical file name is already defined by SAP we do not really need to bother about setting one up for ourselves, we can just use the given one, it worked right away in all systems I have tested these transactions in preparation for this blog.
With customizing transaction FILE you can view how it is defined.
Double click the folder Logical File Name Definition on the left, find the file name (that can be seen in e.g. MI34) then go into the detail.
Alternative you can use SM30 with view V_FILENAME to get the same info.
Here you see that SAP expects a physical file called phyinv34_38 for the MI34 and MI38 transaction
(for MI39 and MI40 transaction the file name is phyinv39_40)
And it expects it to be in directory: /usr/sap/trans/data (this is in Unix file system)
Further you can see that this file is expected in ASCII data format.
Now we know that we have to transfer an Text file called phyinv39_40 into directory /usr/sap/trans/data
Let us continue with the content of this file.
SAP explains in the documentation that you can create a test file, this should help you to know what is needed.
Start with MB52 to list the stock of one location in your plant. Then create a physical inventory document with just one or two materials using Mi31 or Mi01.
So you know the plant, location, material number, batch number, unit of measure, quantity, stock type, the inventory document number, the inventory date and the count date.
SAP help explains that you need to maintain table T159i to create a batch input with test data.
You do this in SE16. Enter table name T159i, then click the create icon. Do this in your Development System, you probably do not have the authority for table maintenance with SE16 in production system.
You will then get this table screen and, and according to the SAP help you have to enter the report ID RM07II34 and the transaction code MI04 to create test data for MI34 transaction (RM07II39 with MI09 to create test data for MI39 transaction. Please obtain the relevant report ID for the transaction from SAP documentation in the selection screen)
The other fields have to be maintained with the data from your physical inventory document, off course with the actual count and not with the book inventory from MB52 list.
Remember, to create a zero count, it is not sufficient to enter 0 in ERFMG field; you have to set the indicator for zero count in field XNULL too.
Now you can proceed in MI34 transaction.
You activate the box in front of test data and execute.
SAP issues a warning message: Sequential file /usr/sap/trans/data/phyinv34_38
overwritten with test data
Please double click the message and read its long text.
This is a warning only, it tells you that this listed file will be overwritten. Just think about what content this file has. If it has just test data from a test made by yourself then there is no harm to continue with Enter and have SAP overwrite the content of this file. But it could have productive data. Could it really? Probably not in a development system., but it could be test data from a colleague of you.
If you want to check what content it has, then execute AL11 transaction. Browse through the directory to /usr/sap/trans/data/ and then double click the file phyinv34_38
You will then get a file similar to that one (this is from MI39)
If you get a message like Sequential file & cannot be opened, then it can be a authorization issue, it could as well be that you have the wrong report ID maintained in T159i table. Or you do not even have any record in T159I
After you had successfully written data do the file using the test data flag SAP gives you the following screen with information from the Batch Input session that was created. And you can process this session now from here clicking Process session, or you go into SM35 to process the batch input session.
But before we actually execute the batch input session we should verify if it has the data in the right fields. This is less important for correct maintained test data from T159i table than later when you try with your own external data.
When you are in SM35, then find your batch input session in the NEW tab using either your user ID or the session name which was listed in the screen shot before (based on your entry made in T159i)
Select the session, then click the analysis button. Now go to the tab Screens and click the button Display Field list. Now check if the content is at the right fields. This is as well a screen shot for MI39 transaction, but for MI34 you will see almost the same. The main purpose is to check if the content is in the right fields.
If you are satisfied with the content, then you can execute the batch-input session.
SAP recommends doing it in Error mode. I personally prefer to do it in foreground in the first test.
Until here it was basically the technic how to execute the batch input with test data from table T159i. But more important is a test with own external data.
Table T159i could already give you an idea how the data has to be. SAP says in the documentation that your file shall be based on table structure BISEG.
Execute SE80, select Repository Information System, drill down Objects > Abap Objects > Fields > Structure fields. Then enter BISEG as Structure name and click execute. SAP will give you a list with the field names, from there you can as well go into the details and see the field definitions.
Alternative, just use SE11, enter BISEG as table and click display.
This structure has all possible fields that could be needed in physical inventory process. Many of them are used for special stocks inventory. If you are familiar with all inventory types and with manual execution, then you should not be worried about those fields.
But very important is to know how to prepare this file.
This batch input process is in general used when the physical inventory is done in a legacy system.
So you create this file with a program in your legacy system.
Excel is not a legacy system.
You must not have field names in the beginning of the file, there is no option to omit this info in the transactions.
SAP expects the data in a sequential flat file respecting the field length of the BISEG structure.
As the BISEG structure is like a mask that is put over your data in this file and then the program uses character 1 to 12 and moves the content to the field MAPPE (session), then it takes character 13 to 32 and moves the content to the field TCODE (transaction) and so on.
Excel has columns, but it does not respect the field length.
If you save Excel as text file, then you have tabs as delimiter, but all content is just concatenated
See this example:
Content coming from Excel saved as Text file:
If the program then moves the characters 1 to 12 to the session name field, then it will have MY_MI39#MI09 as content, and the transaction code field would have ####1300#0001#MS
This is just garbage from plant number, storage location and material number, and cannot be loaded.
How to get this external file into your SAP directory?
You can use the standard transaction CG3Z for this purpose.
It gives you option to search for your source file in your local PC via F4 .
And the target directory and file name needs to be entered manually.
Remember that you need ASC as format and activate the check box to Overwrite an existing file.
Here you will not get any warning like it is in the MI34 transaction.
After the file is loaded you receive a success message
Then you continue in the batch input transaction. Now you must not enter the Test flag.
SAP will then read the data from your loaded file and create a batch input session.
Which you finally process in SM35 (or directly from the transaction, if possible)
The Transaction without document references have a field for number of items. It is defaulted with 20, which means that SAP only takes 20 records into one inventory document, then another inventory document is created until all your items are processed. This field must not have a value bigger than 333.
You cannot have more than 333 inventory items in one inventory document. There is no difference in mass processing with batch input method compered to the manual transactions.
Please read SAP Note 1655631 – MI31 / MI34 Maximum number of line items per Physical Inventory Document
Can you please tell me the format for the MI34 upload phyinv34_38?
This is what I uploaded
5/22/2013 2013 21 1 2
5/23/2013 2013 21 2 2
5/24/2013 2013 21 3 2
5/25/2013 2013 21 4 2
but in the unix it shows like this
I added it to excel and did a Save as text.
I had already explained that Excel is not the medium for this.
you need spaces between the numbers. Excel does not give you spaces, it only gives you delimiters.
What you theoretically could do in Excel is :
go to a new tab
format the page to use font FIXEDSYS
then add a formula for concatenate
concatenate all your separate fields per row from the other tab into one field.
of course you have to concatenate some spaces , so that it finally looks like expected.
e.g. if a field length is 10 in structure BISEG and you have only 8 characters in your source, then you have to add 2 spaces before you concatenate the next field content.
I did as you said when I upload the file to /usr/sap/trans/data it looks like this now.
TESTTESTMi34 MI04 05222013 2013 0000000021 002 00000000000000003
TESTTESTMi35 MI04 05222013 2013 0000000021 003 00000000000000006
TESTTESTMi36 MI04 05222013 2013 0000000021 004 00000000000000009
But when I execute the MI34 it says no list generated.
I created the count sheets through MI31 the count sheet is 21
I tested the process through the T159I table, which works fine.
I checked the transaction FILE. In Logical file name definition, Cross-Client -->MMIM_PHYSICAL_INVENTORY_DOCUMENTS the data format is ASC. I used the same format when I uploaded the file through CG3Z.
still get the same error.
Appreciate your help. Thanks.
Compare your file with my screenshots from above. does it look equal?
This: TESTTESTMi34 MI04 05222013 2013 0000000021 002 00000000000000003
does not tell me much, I can just see 1 space between the fields. but if a field is 20 long and you have just MI04 in that field, then you need 16 more spaces.
Based on your given example I cannot validate if it is in the correct layout, I actually doubt.
I used Access instead of Excel where you can setup a table with field length.
When you export this to txt-file you receive exactly what you need.
You only have to remove counter in front of your lines.
I had another closer look to your structure:
TESTTESTMi34 MI04 05222013 2013 0000000021 002 00000000000000003
where is the plant?
where is the material number?
At least the plant number should show up between the transaction MI34 and the counting date. Look at the BISEG structure with SE11.
In our system the physical file has no directory in transaction FILE
fich. log. MMIM_PHYSICAL_INVENTORY_DOCUMENTS
Désignation Interface traitements des documents d'inventaire
fich. phys. phyinv34_38
What is the default directory used ?
PS. when I load the file with CG3Z,
to : phyinv34_38
Then MI34, tells me that the file does not exist.
the second screen shot shows path and file name for the physical file
you just have to : phyinv34_38 in your CGZ3, you need to change the target to match the physical file path and name
The default directory is DIR_SAPUSERS.
go to that directory using AL11 transaction and filter by last change date.
you will see the file.
I would like to point out that transaction FILE and the view V_FILENAME are not the same. Logical filenames can be configured as client-independent (Table FILENAMECI, Transaction FILE) or client-dependent (Table FILENAME, Transaction SF01, View V_FILENAME). The system/lookup function module will check the client-dependent setting first.
I adjusted the logical filename in transaction FILE and the program kept looking somewhere else and I couldn't figure out why...
Thank you for this valuable comment.
Dear Jürgen L,
I have tried loading based on excel structure, but it shows me the empty spaces; Is there a possibility that you can share me an example of the correct excel file structure??
thanks for your help!
When I run MI39 with the test data checkbox flagged (after I have maintained T159l) I do get a batch input session but the screens do not contain all the data I have put in that table. Basically screen 0700 is ok, but 0731 is blank.
Post a question in MM forum and insert screenshots of your T159I table and from the batch input screens.
I have entered data on table T159i in order to enter a count with MI39, but when i select test run it says that "sequential file cannot be opened". I have full authorization and all data are maintained correctly. Do you have any clue?
message M7 850 is issued in 2 program parts:
in both it happens directly after the command open dataset
And for this you usually need to have extra authorization beside of the standard authorization for MI39.
Unfortunately SAP has not captured any details in this message.
If you look into this ABAP docu: ABAP Keyword Documentation
then you can see that this keyword could have several exceptions.
Those are the things that you have to check.
Thanx Jurgen, i resolved it. The directory /usr/sap/trans/data was wrong, i had to change it. Then it worked. Thanx again
Struggling with the "concatenate" part. I get all the fields from BISEG into my spreadsheet and fill up the necessary cells with the missing spaces (compared to the field lengths). Then I concatenate all the fields into one cell and run CG3Z to check the result. Finally it looks like this.
Then I run MI40 and get this error message.
BDC_OPEN_GROUP, group . sessionmi40. is invalid
Message no. 00334
Error creating a batch input session.
Contact the person in charge.
Can you see what's missing with my data?
Compare with my file I certainly see some differences.
- you used lower case letters
- sessionmi40 looks like it does not start at the most left place in that field
- transaction code mi10 is as well in lower case and at a much different position than the transaction code in my example
Just see yourself:
Ok then apart from the lower case issue I think I'm doing something wrong with the fields also. Basically I'm just copying all the fields from BISEG into Excel and give values to the fields I need and leave the rest blank. Then I fill the spaces and concatenate them. Maybe I should not have followed exactly the same field sequence from BISEG? But how do I know the right fields and sequence...
One of the most important things I mentioned in the blog was: Excel is not a legacy system
Excel does not have fixed field length, and I do not know how you filled the field an Excel cell with a certain number of spaces. Important is what you finally get when you save the spreadsheet as txt file.
A text file using a monospaced font then it will take the same space for any character, so it is easily possible to count the number or spaces needed between two values.
In the text file you just see the numbers or characters. Now imagine a put a mask over the numbers. this mask has the fields with the correct length from table BISEG.
If had somewhere a space too much or to less then the value does not go into the right field and it looks scrambled, which finally leads to the fact that this cannot be interpreted by SAP.
Exactly as you said. Now I have the correct spaces added after field values and it's working. Thanks!
I've created the sequential data file and uploaded it to the default directory DIR_SAPUSERS\phyinv34_38. If I run MI34 I get the meassage "no list generated".
If I run MI34 with ticked test data flag file phyinv34_38 will be overwritten with test data from T159i and batch input session is created.
Any idea why MI34 not crete the bi session?
look a few comments above at the comment from May 5 and compare your file with mine, I see yours is looking different, look at transaction MI04 and plant 1200 where it is positioned in your file and where in my file. There are even more differences looking further right in the file.
I am trying to do MI34 but for some reason when I process the batch input, the fields are blank and my data from the text file is not entered in the fields. I saw this by processing the batch input in the foreground. I am trying to do MI34 for 2 line items only. I have created a physical inv. document already and entered it in my text file as well following the BISEG structure. I am getting the warning message "Sequential file..." when trying to do a test upload in MI34. I am not sure why the data is not picked up when I made sure that my text file is correct in terms of the structure. Below is a screenshot of my batch processing in the foreground. Hope you can share your expertise and point out where/what I am doing wrong. Thank you.
Please post the complete warning message, and post a screenshot of the batch input session field list.
Here they are:
Looks like the session analysis is empty.
yes, your T159I has as well not much data, just session name, transaction and plant
Not enough to post a count.
I think your fields in the source file did not match the expected structure and could not be loaded to the right target fields.
Thank you for the reply. I have checked it twice and the source file follows the expected structure. I am not sure why the program is not picking the data up and putting it into the fields. Any other thing that I can do? Am I missing something else?
if you don't mind then attach your source file here, then I will if I find an option to test
I am not sure if this is how you want the file since I cannot attach a file. Please let me know if you want me to email it directly to you instead. Thank you.
CC_MI34 MI04 2114 140720151407201514072015140720152015100003880 1000 EA 21 115177
CC_MI34 MI04 2114 140720151407201514072015140720152015100003880 1000 EA 31 115188
I have the same issue, I think so that the main problem is the layout structure of Excel ..
do you have any sample of the right excel structure file?
Good Post... Thanks for info... 🙂
I try to use MI39 for my inventory and i have the similar problem as Werner:
Log Datei. MMIM_PHYSICAL_INVENTORY_NO_DOCUMENTS
Phys. Datei phyinv39_40
When I navigate to transaction AL11 to the folder DIR_SAPUSERS, i can find the phyinv39_40 file, however, it is marked as not usable.
Has the file to be usable? How can I change the status of this file?
Moreover, I have a second problem
Using transaction SE16, Table T159I, to get testdata into the system, I get the error "MO429, No table entries found for specified key".
What I'm doing wrong?
Thank you for your help
When a file has a length of zero then it is not usable in AL11 as SAP is not able to display nothing.
You can't change this status, you need to load a file which has content.
if that many entry in SE16 do not find an entry then you should remove as much as possible from the selection screen to see if you have data.
Also you have to enter a record prior to selecting it.
I wrote: You do this in SE16. Enter table name T159i, then click the create icon
the selection screen is already a step to far.
Thanks for your help
Thanks, very useful !!!
Thankx for such a good explanation.
But i got the below error while executing MI34
Background processing not possible for material with serial number reqmt
Message No. M7419
We need a batch upload programme for Serial number also
Please guide how to do that
serial number management requires to enter serial numbers along with the count, the batch input is not able to do that. Just a technical limitation of a very old program.
Can we develop a new Z programme to upload Serialized physical inventory count, because it is not practical enter counts for thousands of material
there is much too less information in that statement.
I entered the counts for some years myself and shared my experience in 2 blogs starting here: https://blogs.sap.com/2013/06/17/physical-inventory-is-more-than-just-sap/
In short the materials need to be counted which is a manual effort, the counts need to be entered, which is also a manual effort in Excel, in SAP, or in any custom program unless you do the count with scanners.
I mean to say that user will count the Item inventory manually, and maintain the excel.
Now i need to upload that excel in sap, so i was facing error in uploading inventory of serialized items.
Can i use any standard method to upload the count using excel
Can i create Z Programme to upload Physical Inventory Count excel in SAP, if STD process not available
And what I wanted to say is that maintaining the count in Excel is adding work instead of making things quicker, a) you have to prepare the Excel sheet with the items to be counted, and b) it has to be maintained manually and c) you need an extra program to upload it.
In SAP part a and c is not at all needed and part b is not a second more effort
You are right but maintaining Excel is easier then maintaining directly in SAP from end user perspective.
If we can provide an excel upload for serialized inventory it would be beneficial for them.
Can you suggest for serialized inventory excel upload programme
hello Jürgen L
what about WM count ?
in 2010 someone wrote he had use the function module L_INV_COUNT_EXT
Your blog is very useful, but I'm facing problem while creating test file.
First , I have created PID 100000045, though TCODE MI31.
the content of PID as follow :
Second, I have created test file in table T159i.
the content of test file as follow :
Thirdly, I execute MI34 with test file above
my logical file name : MMIM_PHYSICAL_INVENTORY_DOCUMENTS
I give a tick mark for Test Data and I encountered problem after executing session ini SM35.
The error message as follow :
Am I doing it wrongly ? where is my mistake..?
can you show a screenshot from the screen data like this one
this is the screen shoot :
I just tested it and my batch input looks different, it has just 2 screens (0701 and 0731)
I know for sure that in case I had the 0731 screen twice in a batch input like yours, then the second occurrence would usually be protected, speak it has no input fields.
Kindly run the batch input in forground in SM35 to see what it does in each of the 4 screens
Assuming this is all standard I can only recommend to check for OSS notes directly from your performance assistant screen like explained in here: https://blogs.sap.com/2014/11/28/got-an-error-message-the-new-tool-panks-is-here-to-help-you/
Thank you for your help…
I think I know the cause of my mistake. I did not entry the line number in PID in my previous attempt. As you suggest me to do it foreground, I fill the line number in the process.
Here is my result :
Am I correct..?
probably yes, as the message says it was posted. just check in MI06
This is excellent information!!!
But unfortunately insufficient for my purpose.
Nevertheless, maybe you people can help me anwering this question.
Does anyone know if there is a standard method to take physical inventory count with serialized materials via batch input?
I don't see any field in BISEG structure in which I can enter the counted serial numbers. So I think this method doesn't work for me.
see OSS note 1807798 - MI35: Error message M7 419 for serial no. managed materials
I have followed steps in your blog,
I created PID through MI31.
I entered count result to Microsoft Access and created text file through Microsoft Access ( the field length is same with BISEG table )
I executed CG3Z and in SAP directory .Path : /usr/sap/trans/data/phyinv34_38
the content as follow :
and the content of text file as follow :
I run MI34 without tick Test Data and tick Log result.
But, my session TESHARRIS3 is not created
where is my mistake in these steps ?
It looks like you are not reading from the uploaded file, so check the setup for file and paths and compare the found values with the directory and file name of your upload.
When I try to run MI39 in background mode, the batch input session is terminating right after it encounters the first erroneous input record. Error could be related to material not existing or physical inventory record already being active, etc. Is it possible to make MI39 process the entire input file skipping the erroneous data records, and show all those error messages in the session log? I would like to correct all those erroneous records and reprocess them with MI39 in a second session.
Thank you in advance,
Click the info button in the MI39 selection screen, based on the docu there it should behalf as any other batch input session when it comes to an error situation.
Do you see something in the log or do you get a short dump?
It is hard to imagine where exactly your MI39 terminates.
Do you see the session in SM35?
Here is my MI39 Batch Input session log from SM35; it shows that it encountered error on the first input record and after that the session ended even though there are 9 more records in my input file.
HI, Jürgen Lins,
I prepared the txt format file with exact the same as BISEG structure and load via CG3Z like below
BIMI34 MI04 9022 SW14_MI34 14052019140520191405201920190100268467001 RM 00000000000005000 000000000020180057
BIMI34 MI04 9022 SW14_MI34 14052019140520191405201920190100268467002 RM 00000000000001000 000000000020181104
I hit error it says “BDC_OPEN_GROUP group XXXXX is invalid”.
It is highly appreciated if you could help me out for this issue.
best regards and Thanks,
Please note that CG3Z is NOT a standard transaction and should not be used in this context , i.e. inventory files .
It is reserved to import and export files for the specification, phrase, report, single-object report, report template, source, and property tree import and export process within the EH&S module!
Read more in note 1949906 - Download and upload of files
I have increased the max item number to 300, but the program still would not split as defined. Any idea why?
Nevermind, I found out myself that the user's source data have multiple combination of plant and sloc, That is why the program split the document automatically.
Jürgen L is the best!
Is there a way to perform ph. inventory for serialized materials through batch input files coming from an external system in S4 Hana 1909? Would appending BISEG and of course, the respective program of MI39 makes sense?