cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create Script Mass User Login & Doing Transaction

Former Member
0 Kudos

Hi SAP Experts,

I have a activity to do performance test with 100 concurrent users.

But unfortunately i have no supplement PT software for this activity (Like Rational PT or Loadrunner).

So i think i will do it with sapgui script.

Is it possible to create vb script (SAP GUI Scripting) to fulfill my requirement to do this activity. If yes how to create this script.

Thanks & Best Regards,

Husin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear All,

The problem is solved now,

i just pass the parameter value of user id to the script and run the script simultaneously.

Thanks & best regards,

Husin

Answers (1)

Answers (1)

former_member213011
Participant

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:

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

Former Member
0 Kudos

Dear Sayuti,

Thanks for your response, i will try your code in my system.

I will update you the result soon.

Best Regards,

Husin

Former Member
0 Kudos

Hi Sayuti,

I have tried your code, and the result is user ids login sequencially not concurrently.

i think we cannot use looping for this case, we need use thread to make user login dan concurrently.

but unfortunately there is no thread in standard excel vba.

Is there any clue for make this happened?

Thanks & Best Regards,

Husin

former_member213011
Participant
0 Kudos

Dear Husin,

I'm not sure whether that is possible... perhaps you can refer this discussion: http://scn.sap.com/thread/3467700

Thanks,

Sayuti

Former Member
0 Kudos

Hi Sayuti,

I can run the script concurrently, but i found the other problem there.

I'm using c# to call vbs script (macro) in excel concurrently using backgroundworker component. I can call it concurrently until display logon form in sap gui. but the new problem is when entering below part, the script was executed sequencely per user.

        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

            -=== guiscript code ===-

        End With

So my assumption is with sapsession ... end with  cannot be executed concurrently. there is something behavior that make sapsession scope is not concurrently.

Is there anyone experienced with this?

Please give suggestion on this.

Thanks & Regards,

Husin

former_member213011
Participant
0 Kudos

Dear Husin,

I believe SAPGUI does not support multi-threading, hence it cannot execute Sessions concurrently.

Do post if you could find a workaround.

Thanks,

Sayuti

Former Member
0 Kudos

Dear Sayuti,

OK, i'm still search how make that happen. Sure, i will post it in this discussion if i find the way.

Thanks & Best Regards,

Husin