Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8430

Re: How to Create Script Mass User Login & Doing Transaction

$
0
0

Dear Husin,

 

Using Excel VBA:

 

Populate the usernames and respective password in a worksheet with codename "Sheet1" (default for the 1st worksheet on a new Workbook) without header. Example:

 

ScreenHunter_58 Jan. 08 13.03.jpg

 

Perform early binding to the SAP GUI Scripting API:

 

Open the VBA Editor. Tools > Reference... > Browse... > Locate sapfewse.ocx (usually in folder C:\Program Files\SAP\FrontEnd\Sapgui).

 

Insert a standard VBA module and put the following codes (change the parameters according to your requirement accordingly):

 

'//--- start of codes

Option Explicit

 

Sub LoginConcurrent()

    Dim sapgui As SAPFEWSELib.GuiApplication

    Dim sapcon As SAPFEWSELib.GuiConnection

    Dim sapsession As SAPFEWSELib.GuiSession

   

    Dim i As Long

    Dim totalId As Long

    Dim sapID

    Dim sapPassword

   

    Set sapgui = GetObject("sapgui").GetScriptingEngine

    totalId = Sheet1.Range("A1").End(xlDown).Row

   

    For i = 1 To totalId

        Set sapcon = sapgui.OpenConnectionByConnectionString("your.sap.server.address", True)

        Set sapsession = sapcon.Children(0)

 

        sapID = Sheet1.Cells(i, 1)

        sapPassword = Sheet1.Cells(i, 2)

 

        With sapsession

            .FindById("wnd[0]/usr/txtRSYST-MANDT").Text = "200"

            .FindById("wnd[0]/usr/txtRSYST-BNAME").Text = sapID

            .FindById("wnd[0]/usr/pwdRSYST-BCODE").Text = sapPassword

            .FindById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"

            .FindById("wnd[0]").SendVKey 0

            .StartTransaction "IW33" '//transaction to test

            '//---other codes to test here----//

        End With

 

    Next i

   

    Set sapsession = Nothing

    Set sapcon = Nothing

    Set sapgui = Nothing   

End Sub

 

'//--- end of codes

 

 

Thanks,

Sayuti


Viewing all articles
Browse latest Browse all 8430

Trending Articles



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