Loading Material Masters with LSMW Direct Input method

By Willem Hoek INTRODUCTION It is a lot easier and quicker to load material masters using the Standard Direct Input object in LSMW rather than with a recording of transaction mm01 or mm02. (To learn more about loading data using recording, see this post) One input file can be used to create all the views of the material master. For all the material types. Even if different views and fields are used for the different materials. Steps to take • • Create text file with data to be loaded Set up and run LSMW

All steps are discussed in this post. A sample data file and LSMW Project can also be found in attachment. (see end of this post). Please take note that my project and input file will need slight modification to work fully on your SAP system. You will have different material types, number ranges, field selections, etc. To get going, use my LSMW Project and data file and make changes as required to get a simple dataset loaded. The most difficult bit in loading materials is getting the input file correct. I suggest you create the file from a database (SQL) or programmatically. Excel does work but it sometimes convert numbers / strings (example 0100 becomes 100). More notes about this at the end of this post. Let's first go through LSMW steps -; then look at the input file. LSMW You can either create the LSMW project manually or load my project (in attachment at end of post). Import Project Download project as attachment from end of this post to your PC. Go to LSMW -; transaction LSMW Menu: Extras > Import Projects

select file LSMW_Z2_MM01.txt

Press 'Import' (or 'Import Under Another Name').

Select Project / Subproject / Object and press 'Execute' Step 1: Maintain Object Attributes With first option selected -; press 'Execute' Press 'Display <> Change' to select Object

As a rule. For simplicity. keep the field names the same as in SAP. make field size bigger than required. What fields can be included? See next step for that . This way mapping can be done automatically. in this case mostly 40.Step 2: Maintain Source Structures Step 3: Maintain Source Fields Define here all the fields that will be in your input file (text file with data). The order of the fields is not important.

.Step 4: Maintain Structure Relations Here you map the one input file to structures that was selected in step one (direct input objects).

click on the structure. Example for BMMH1 .To get an idea what material master field can be loaded -.

BMMH2 (or other).You will see BMM00 is to select the Views and BMMH1 contains bulk of the material fields. Step 5: Maintain Field Mapping and Conversion Rules Map field in input file to fields in SAP Material master. The fields can also be viewed via ABAP Dictionary (se11 /se12) and display the database table BGR00. then you can map them automatically by selecting Menu: Extras > Auto-Field Mapping . If your fieldnames in file is same as in SAP. BMMH1. BMM00.

Translations. User-Defined Routines Not used for this project . Don't worry to much about the warning that 'Source field is longer than target file' just make sure your input data is correct. Example material type must be 4 characters. only those that you are loading (as defined in input file). Step 6: Maintain Fixed Values.Not all fields need to be mapped.

. Also indicate how your input file will look.Step 7: Specify Files Specify source file (on your PC) and what the files will be called on the SAP server. Example. TAB delimited and Field names in first row.

Step 8: Assign Files Step 9: Read Data .

More about the input file later. . Step 10: Display Read Data The input file is now on the SAP server and can be displayed. For big files -. You may want to use sample file attached to this post as a start. This was done is step above. Note you don't need to specify path / filename. many thousand of records this might take a while.At this point your input file must be ready.

Click on line to see the details .

.Step 11: Convert Data We now need to convert the data to format so that SAP can process.

Step 12: Display Converted Data You can display converted data to ensure that all is ok so far before creating the materials. And select the structure to see details .

do not update' option .Step 13: Start Direct Input Program If all is OK -. First run it in test mode (not creating material) by selecting the 'Check data. let's run them in.

You might get a view messages -. . In my case I got NO errors. just press OK.

same as above but 'untick' the 'Check data. do not update' option .I now run it without the test option.

At this point you may still have errors. get a decent text editor. Either your input data is incorrect. Some suggestions are: UltraEdit or Crimson Editor (if you want a good free one). This is how my input file looks (via Crimson Editor). My editor is set up to show TAB characters. different material types. . etc.Materials were successfully created. TIP: if you will be working with LSMW files a lot. The funny '>>' fields are TAB's. etc. you may have fields as mandatory that was not in your input fields. INPUT FILE In step 7 above we have indicated that we are using TAB delimited files.

Or in Excel (importing the tab delimited file) .

'/'.'Y'.Note that the material number field (MATNR) is blank for first line and 0 (zero) for subsequent lines. .'0100'. This sample file used in this post was created directly from the database program.'/'.'500'.'X'. SELECT 'MATLD'.'/'. see notes in SAP Help file. In my file. In my case I generated the tab delimited file directly from database program. every line is unique material / plant / sloc. That way a sql script can be created that implement all the conversion rules.'X'.'MAT DESCRIP'. spreadsheet or other program.'MM01'.'/'.mat_type. And 0 (zero) indicates that material being created will be extended.'X'. The header (field names) was added in another step. LAST NOTE ON PREPARING THE DATA (OPTIONAL) I find the easiest way is to prepare the material master data is using a SQL database.'/'.'/'. For more about format of file.'/'. Below is the SQL statement (used in MySQL) that created the final data file.'X'. '0'. sloc.'SAP123'. plant. Fields to be ignored are marked with "/".'B'. '/'.base_uom.'/'. I used MySQL [mysql.com]. The input file can be prepared using database.'/'. This is the way to specify that internal numbering will be used.

1.'02'. price.'/'.'/'.'/'.profit_centre INTO OUTFILE 'c:/data/sap123.0.'F'.'/'.'00010'. price_control.'/'. plant.1.1. old_matnr.com] Cross Application Components > CA Data Transfer > Data Transfer Objects > LO logistics General > Material Master This post was prepared using SAP R/3 Enterprise (and LSMW version 4.sap.'HB'. Don't stress. sloc ORDER BY mat_type. For SAP Help files. plant.'/'. sloc.'/'.com/ [help. I hope you are in a position to load your own materials.sap.100.'/'.14.com/lsmw_direct/lsmw_directinput.'/'.'/'.1. (But I do suggest you buddy up with someone who knows SQL :) ).'001'.'A'.'/'.0) With this sample and reading the SAP Help files.1. .'/'. goto http://help.'/'.'01'.txt' FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' FROM main_table GROUP BY mat_number.'ND'.'BIN '. GETTING HELP FROM SAP Very detail help is available in SAP Help Files.'/'. old_matnr. val_class.'/'. If above code is meaningless to you. you don't need to use any of this in LSMW.

Sign up to vote on this title
UsefulNot useful