You are on page 1of 14

SAP123

Articles

LoadingMaterialMasterswithLSMWDirectInputmethod
ByWillemHoek
INTRODUCTION
ItisaloteasierandquickertoloadmaterialmastersusingtheStandardDirectInputobjectinLSMWratherthanwitharecordingoftransaction
mm01ormm02.(Tolearnmoreaboutloadingdatausingrecording,seethispost)
Oneinputfilecanbeusedtocreatealltheviewsofthematerialmaster.Forallthematerialtypes.Evenifdifferentviewsandfieldsareusedforthe
differentmaterials.
Stepstotake
Createtextfilewithdatatobeloaded
SetupandrunLSMW
Allstepsarediscussedinthispost.AsampledatafileandLSMWProjectcanalsobefoundinattachment.(seeendofthispost).
PleasetakenotethatmyprojectandinputfilewillneedslightmodificationtoworkfullyonyourSAPsystem.Youwillhavedifferentmaterialtypes,
numberranges,fieldselections,etc.Togetgoing,usemyLSMWProjectanddatafileandmakechangesasrequiredtogetasimpledataset
loaded.
Themostdifficultbitinloadingmaterialsisgettingtheinputfilecorrect.Isuggestyoucreatethefilefromadatabase(SQL)orprogrammatically.
Exceldoesworkbutitsometimesconvertnumbers/strings(example0100becomes100).Morenotesaboutthisattheendofthispost.
Let'sfirstgothroughLSMWstepsthenlookattheinputfile.
LSMW
YoucaneithercreatetheLSMWprojectmanuallyorloadmyproject(inattachmentatendofpost).
ImportProject
DownloadprojectasattachmentfromendofthisposttoyourPC.
GotoLSMWtransactionLSMW
Menu:Extras>ImportProjects

selectfileLSMW_Z2_MM01.txt

Press'Import'(or'ImportUnderAnotherName').

SelectProject/Subproject/Objectandpress'Execute'
Step1:MaintainObjectAttributes
Withfirstoptionselectedpress'Execute'
Press'Display<>Change'toselectObject

Step2:MaintainSourceStructures

Step3:MaintainSourceFields
Definehereallthefieldsthatwillbeinyourinputfile(textfilewithdata).Asarule,keepthefieldnamesthesameasinSAP.Thiswaymappingcan
bedoneautomatically.
Theorderofthefieldsisnotimportant.Forsimplicity,makefieldsizebiggerthanrequired,inthiscasemostly40.
Whatfieldscanbeincluded?Seenextstepforthat

Step4:MaintainStructureRelations
Hereyoumaptheoneinputfiletostructuresthatwasselectedinstepone(directinputobjects).

Togetanideawhatmaterialmasterfieldcanbeloadedclickonthestructure.ExampleforBMMH1

YouwillseeBMM00istoselecttheViewsandBMMH1containsbulkofthematerialfields.
ThefieldscanalsobeviewedviaABAPDictionary(se11/se12)anddisplaythedatabasetableBGR00,BMM00,BMMH1,BMMH2(orother).
Step5:MaintainFieldMappingandConversionRules
MapfieldininputfiletofieldsinSAPMaterialmaster.IfyourfieldnamesinfileissameasinSAP,thenyoucanmapthemautomaticallybyselecting
Menu:Extras>AutoFieldMapping

Notallfieldsneedtobemapped,onlythosethatyouareloading(asdefinedininputfile).Don'tworrytomuchaboutthewarningthat'Sourcefieldis
longerthantargetfile'justmakesureyourinputdataiscorrect.Examplematerialtypemustbe4characters.
Step6:MaintainFixedValues,Translations,UserDefinedRoutines

Notusedforthisproject

Step7:SpecifyFiles
Specifysourcefile(onyourPC)andwhatthefileswillbecalledontheSAPserver.

Alsoindicatehowyourinputfilewilllook.Example,TABdelimitedandFieldnamesinfirstrow.

Step8:AssignFiles

Step9:ReadData
Atthispointyourinputfilemustbeready.Moreabouttheinputfilelater.Youmaywanttousesamplefileattachedtothispostasastart.
Noteyoudon'tneedtospecifypath/filename.Thiswasdoneisstepabove.

Forbigfilesmanythousandofrecordsthismighttakeawhile.
Step10:DisplayReadData
TheinputfileisnowontheSAPserverandcanbedisplayed.

Clickonlinetoseethedetails

Step11:ConvertData
WenowneedtoconvertthedatatoformatsothatSAPcanprocess.

Step12:DisplayConvertedData
Youcandisplayconverteddatatoensurethatallisoksofarbeforecreatingthematerials.

Andselectthestructuretoseedetails

Step13:StartDirectInputProgram
IfallisOKlet'srunthemin.

Firstrunitintestmode(notcreatingmaterial)byselectingthe'Checkdata,donotupdate'option

YoumightgetaviewmessagesjustpressOK.InmycaseIgotNOerrors.

Inowrunitwithoutthetestoption.sameasabovebut'untick'the'Checkdata,donotupdate'option

Materialsweresuccessfullycreated.
Atthispointyoumaystillhaveerrors.Eitheryourinputdataisincorrect,youmayhavefieldsasmandatorythatwasnotinyourinputfields,different
materialtypes,etc.etc.

INPUTFILE
Instep7abovewehaveindicatedthatweareusingTABdelimitedfiles.

TIP:ifyouwillbeworkingwithLSMWfilesalot,getadecenttexteditor.Somesuggestionsare:UltraEditorCrimsonEditor(ifyouwantagoodfree
one).
Thisishowmyinputfilelooks(viaCrimsonEditor).Thefunny'>>'fieldsareTAB's.MyeditorissetuptoshowTABcharacters.

OrinExcel(importingthetabdelimitedfile)

Notethatthematerialnumberfield(MATNR)isblankforfirstlineand0(zero)forsubsequentlines.Thisisthewaytospecifythatinternalnumbering
willbeused.And0(zero)indicatesthatmaterialbeingcreatedwillbeextended.Fieldstobeignoredaremarkedwith"/".Formoreaboutformatof
file,seenotesinSAPHelpfile.

Inmyfile,everylineisuniquematerial/plant/sloc.Theinputfilecanbepreparedusingdatabase,spreadsheetorotherprogram.InmycaseI

generatedthetabdelimitedfiledirectlyfromdatabaseprogram.

LASTNOTEONPREPARINGTHEDATA(OPTIONAL)
IfindtheeasiestwayistopreparethematerialmasterdataisusingaSQLdatabase.IusedMySQL[mysql.com].Thatwayasqlscriptcanbe
createdthatimplementalltheconversionrules.
Thissamplefileusedinthispostwascreateddirectlyfromthedatabaseprogram.BelowistheSQLstatement(usedinMySQL)thatcreatedthe
finaldatafile.Theheader(fieldnames)wasaddedinanotherstep.

SELECT'MATLD','500','SAP123','Y','/','MM01','0','B',mat_type,plant,sloc,
'/','/','/','X','/','/','X','/','X','X','/','/','/',base_uom,'MATDESCRIP','0100',
'/','/','/','/',1,'/',1,'/','F','ND','001',1,1,'HB',1,100,'A','02','BIN','/',
price_control,price,val_class,'/',14,'/','/','/','/','/','/','/',
old_matnr,'01','00010',profit_centre

INTOOUTFILE'c:/data/sap123.com/lsmw_direct/lsmw_directinput.txt'
FIELDSTERMINATEDBY' '
LINESTERMINATEDBY'
'
FROMmain_table
GROUPBYmat_number,plant,sloc
ORDERBYmat_type,old_matnr,plant,sloc;

Ifabovecodeismeaninglesstoyou.Don'tstress,youdon'tneedtouseanyofthisinLSMW.(ButIdosuggestyoubuddyupwithsomeonewho
knowsSQL:)).

GETTINGHELPFROMSAP
VerydetailhelpisavailableinSAPHelpFiles.ForSAPHelpfiles,gotohttp://help.sap.com/[help.sap.com]
CrossApplicationComponents>CADataTransfer>DataTransferObjects>LOlogisticsGeneral>MaterialMaster

ThispostwaspreparedusingSAPR/3Enterprise(andLSMWversion4.0.0)
WiththissampleandreadingtheSAPHelpfiles,Ihopeyouareinapositiontoloadyourownmaterials.

Attachment:lsmw_materials_directinput.zip

Getmyblogpostsinyourinbox!
emailaddress
Subscribe

POPULARPOSTS
SAPSDTables
SplitValuation
SAPMMTables
VerybasicsofSAPExternalServiceManagement
ChangeSAPdocumentstablesCDHDRandCDPOS
SAPFinanceTables
SettingupsimpleReleaseProcedureforPurchaseRequisitions

commentspoweredbyDisqus

WebsitebuiltbyWillemHoek
SAPisaregisteredtrademarkofSAPAGThiswebsiteisnotaffiliatedtoSAPAGoranyofitssubsidiaries

You might also like