Quantcast
Channel: SCN : Discussion List - Scripting Languages
Viewing all articles
Browse latest Browse all 325

Can't figure out what is the code

$
0
0

Hi


I got following macro that will help me to run certain transaction.

I just can't figure out where comments ends and where code starts so I was unable to run it for like 3 hours now.


In other words


I am trying to use Excel Macro that will get to active transaction in SAP and do waht I have recorded.



'SAPGUI Macro for updating SAP from Excel data'Prerequisites:'1. Script Recording and Playback from the SAPGui must be enabled by admin'2. The Excel list must be set up from top left corner of a worksheet'3. The worksheet with data must be the active sheet'4. There is no error handling. Build it yourself!'5. The script will update the active (current) SAP transaction'Instructions for use'Record a macro of your update actions.'Paste the session.findById stuff between the <== and ==> markers'Edit the literal values and replace with Trim(CStr(objSheet.Cells(x, y).Value))'where x and y are the row and column counters'Open up your Excel sheet with data (row 1 is ignored here)'Fire the macro!'===========BEGIN BOILERPLATE===================REMSet up connection to the SAP screen: IfNotIsObject(application) ThenSet SapGuiAuto = GetObject("SAPGUI") Set application = SapGuiAuto.GetScriptingEngine EndIfIfNotIsObject(connection) ThenSet connection = application.Children(0) EndIfIfNotIsObject(session) ThenSetsession = connection.Children(0) EndIfIfIsObject(WScript) Then WScript.ConnectObject session, "on" WScript.ConnectObject application, "on"EndIfREMSet up connection to the Excel data to be keyed into SAP: Dim objExcel Dim objSheet, intRow, i Set objExcel = GetObject(,"Excel.Application") Set objSheet = objExcel.ActiveWorkbook.ActiveSheet session.findById("wnd[0]").maximize

'===========END BOILERPLATE=====================


'REM Example: Mark material for deletion in Plant using MM06For i = 2to objSheet.UsedRange.Rows.Count     'Assuming there is a header rowREM Find a cell and put its value in: REM Note: The section of the Script shown below can be recorded ' and edited to pick data from the Excel sheetstrCN = Trim(CStr(objSheet.Cells(i, 1).Value)) strWerks = Trim(CStr(objSheet.Cells(i, 2).Value)) '<== session.findById("wnd[0]/usr/ctxtRM03G-MATNR").text = strCN session.findById("wnd[0]/usr/ctxtRM03G-WERKS").text = strWerks session.findById("wnd[0]/tbar[0]/btn[0]").press session.findById("wnd[0]/usr/chkRM03G-LVOMA").selected = false session.findById("wnd[0]/usr/chkRM03G-LVOWK").selected = truesession.findById("wnd[0]/tbar[0]/btn[11]").press 'session.findById("wnd[0]/tbar[0]/btn[0]").press'==>Next

Viewing all articles
Browse latest Browse all 325

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>