
User Modification SAP GUI Script
Notice: A non well formed numeric value encountered in /home/t00mlabs/blog.t00mlabs.net/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/t00mlabs/blog.t00mlabs.net/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/t00mlabs/blog.t00mlabs.net/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/t00mlabs/blog.t00mlabs.net/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Simple SAP GUI Script for modifying users’ email massively. It takes data from a text file where each line has an user and email separated by ‘;’ All the work is done in SU01 transaction. Check the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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]/tbar[0]/okcd").text = "/nSU01" session.findById("wnd[0]").sendVKey 0 Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForReading = 1 Set objFile = objFSO.OpenTextFile ("users.csv", ForReading) Do Until objFile.AtEndOfStream On Error Resume Next strNextLine = objFile.Readline If strNextLine <> "" Then sep = InStrRev( strNextLine , ";") If sep > 0 Then usuario = Mid(strNextLine, sep + 1) email = Left(strNextLine, sep - 1) 'WScript.StdOut.Write( usuario & " - " & email & VbCrLf) session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = usuario session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").caretPosition = 8 session.findById("wnd[0]/tbar[1]/btn[18]").press session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSUID_MAINTENANCE:1900/txtSUID_ST_NODE_COMM_DATA-SMTP_ADDR").text = email session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSUID_MAINTENANCE:1900/txtSUID_ST_NODE_COMM_DATA-SMTP_ADDR").caretPosition = 16 session.findById("wnd[0]/tbar[0]/btn[11]").press End If End If Loop objFile.Close |