Hello,
I have set up a bunch of misc. material master records in MM02. I have a spreadsheet of 3 columns. I want SAP to call up the material number in the first column, execute the command, enter the two remaining values in two fields, and then save and repeat for the entire list. I can record a macro that does this, but it only does it for one record. I looked on a few sites and found VBA that does what I am looking for, but I can't get it to work.
The code below is what my current script looks like. I need to replace the 3 values with columns A, B, and C, and also need SAP to continue to do this until a blank cell is reached. I'd appreciate any help I could get. Thanks.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = "1117962"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP22/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2734/ctxtMLGT-LGPLA").text = "C62"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP22/ssubTABFRA1:SAPLMGMM:2000/subSUB1:SAPLMGD1:1006/txtMAKT-MAKTX").text = "SPARK PLUG,ECLIPSE,16160"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP22/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2734/ctxtMLGT-LGPLA").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP22/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2734/ctxtMLGT-LGPLA").caretPosition = 3
session.findById("wnd[0]/tbar[0]/btn[11]").press