Quantcast
Channel: SCN: Message List - Scripting Languages
Viewing all 1708 articles
Browse latest View live

Re: Check other Modus is aktually opend, and close Modus

$
0
0

Hi Emil,

 

I would solve this issue as follows:

 

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

while connection.children.count > 1
   Set asession    = connection.Children(1)
   asession.findbyid("wnd[0]").close
   on error resume next
   asession.findById("wnd[1]/usr/btnSPOP-OPTION1").press
   on error goto 0
wend

 

Regards,

ScriptMan


Re: Check other Modus is aktually opend, and close Modus

$
0
0

Hi Scriptman

 

I use Excel VBA to run the skript.

 

Application is a reserved Word in VBA

 

There is an error in the line:

Error.JPG

Regards,

Emil

Re: Check other Modus is aktually opend, and close Modus

$
0
0

Hi Emil,

 

In such cases, one can proceed as follows:

 

If Not IsObject(myApplication) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set myApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(myConnection) Then
   Set myConnection = myApplication.Children(0)
End If

while myConnection.children.count > 1
   Set mySession    = myConnection.Children(1)
   mySession.findbyid("wnd[0]").close
   on error resume next
   mySession.findById("wnd[1]/usr/btnSPOP-OPTION1").press
   on error goto 0
wend

 

Regards,

ScriptMan

Re: CC07 - Change number-> How to get node value

$
0
0

Hello.

Thanks for your reply.

Its quite difficult to understand the code for me. Its complicated. But the second link you posted might be helpful.

The selected node will be always the same. In fact all the script will be always the same. In the IBM link I found somethink like getNodeTextByKey and Path, getItemText, getFocusedNodeKey. Maybe there is some combination of those parameters with which I can copy the one line of the node. Unfortunatelly I cannot use them. I think somethink like this:

. ..
....

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").selectNode "          4"

SAP knows, what I need, so just tell it to give me given node text...Its so frustrating.

 

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").getFocusedNodeKey - now SAP knows the key of the node then:

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").getNodeTextByKey..

Is it possible? - I dont know how to use parameters of given functions.

 

 

 

Or other way for me - If you have access to trsctn CC02 or 03 - theres document flow. Here it will be very simple. But I cannot overcome one screen - its like relations in MS Access.  2i - image hosting, image upload, pictures upload, bbcode - I need doubleclick on Quality Notification, next step I know what to do. But when I record Script:

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "cc02"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/tbar[1]/btn[45]").press

session.findById("wnd[0]/usr/shell[1]").sendData "CDBCL\&\Cn\&\C1\&\Cs\&\Cd"

'Its the click on QN

session.findById("wnd[0]").sendVKey 2

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB02/ssubSUB_GROUP_10:SAPLIQS0:7235/subCUSTOM_SCREEN:SAPLIQS0:7212/subSUBSCREEN_2:SAPLIQS0:7715/cntlTEXT/shellcont/shell").setSelectionIndexes 0,0

 

Excel stops on the bold line with cannot be found by id.

 

Thanks everyone for advices.

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

$
0
0

Dear Sayuti,

 

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

I will update you the result soon.

 

Best Regards,

Husin

Re: CC07 - Change number-> How to get node value

$
0
0

Hi Miroslav,

 

You couldtry the following:

 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "cc07"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/ctxtG_CHG_NR-LOW").text = "500001684513"

session.findById("wnd[0]/usr/ctxtG_CHG_NR-LOW").caretPosition = 12

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").hierarchyHeaderWidth = 116

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").expandNode "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").topNode = "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").expandNode "          2"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").topNode = "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").selectNode "          4"

myText = session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").getNodeTextByPath ("1\1\2")

msgbox myText

 

Regards,

ScriptMan

Re: CC07 - Change number-> How to get node value

$
0
0

So NOW we getting somewhere...

It will put the change number in msgbox. Whats the hierarchy in the tree?. I trying some combinations of 1/2/4, 1/1/4... it shows change number or nothing.

When I expand all the nodes like this:

2i - image hosting, image upload, pictures upload, bbcode

Code is:

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").hierarchyHeaderWidth = 116

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").expandNode "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").topNode = "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").expandNode "          2"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").topNode = "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").expandNode "          4"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").topNode = "          1"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").expandNode "          5"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").topNode = "          1"

session.findById("wnd[0]/shellcont").dockerPixelSize = 443

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").hierarchyHeaderWidth = 250

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").selectNode "          6"

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").doubleClickNode "          6"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").unselectNode "          6"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectNode "          5"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").doubleClickNode "          5"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").unselectNode "          5"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectNode "          4"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").doubleClickNode "          4"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").unselectNode "          4"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectNode "          2"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").doubleClickNode "          2"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").unselectNode "          2"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectNode "          1"

session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").doubleClickNode "          1"

 

I expanded all the nodes, then clicking double on each from bottom. Iwould expect that last node would be like: 1/6 but obviously it isnt. Moreover All nodes have key 1 so I cannot find NodePathbykey. I feel that there is just smal step to be completed. Damn I dont understand the parameters for using the IBM functions like getNodeKeyByKey....Trying

Thanks for now.

Re: CC07 - Change number-> How to get node value

$
0
0

Got it-

session.findById("wnd[0]/shellcont/shell/shellcont[1]/shell[1]").getNodeTextByPath ("1\1\1")

 

How simple...

Thanks a lot Sir Scriptman


Script pauses when windows dialog box asks for file save location...

$
0
0

Whenever i attempt to export a report from SAP to excel using VBA the script pauses because a windows dialog box opens that prompts the user to select a file name and location...As a work around to this issue i would like to select the columns, copy and paste them into excel.  I have been successful in selecting all the columns

 

with session.    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "EBELP"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "BSART"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "WERKS"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "MATNR"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "TXZ01"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "BEDNR"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "AUFNR"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "NAME1"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "PMATN"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "AEDAT"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "ZSLFDT"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "MENGE"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "NETPR"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "STPRS"    .findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn "ZWEMNG"
end with

However, i cannot find the vkey to copy the data.  Can anybody help?

Re: Script pauses when windows dialog box asks for file save location...

$
0
0

Perhaps sendvkey 78

 

From the SAP Scripting API:

 

Possible values for the VKey parameter can be found in the table GUI_FKEY.

 

VKeyKeyboard Combination
00Enter
01F1
02F2
03F3
04F4
05F5
06F6
07F7
08F8
09F9
10F10
11Ctrl+S
12F12
13Shift+F1
14Shift+F2
15Shift+F3
16Shift+F4
17Shift+F5
18Shift+F6
19Shift+F7
20Shift+F8
21Shift+F9
22Shift+Ctrl+0
23Shift+F11
24Shift+F12
25Ctrl+F1
26Ctrl+F2
27Ctrl+F3
28Ctrl+F4
29Ctrl+F5
30Ctrl+F6
31Ctrl+F7
32Ctrl+F8
33Ctrl+F9
34Ctrl+F10
35Ctrl+F11
36Ctrl+F12
37Ctrl+Shift+F1
38Ctrl+Shift+F2
39Ctrl+Shift+F3
40Ctrl+Shift+F4
41Ctrl+Shift+F5
42Ctrl+Shift+F6
43Ctrl+Shift+F7
44Ctrl+Shift+F8
45Ctrl+Shift+F9
46Ctrl+Shift+F10
47Ctrl+Shift+F11
48Ctrl+Shift+F12
70Ctrl+E
71Ctrl+F
72Ctrl+/
73Ctrl+\
74Ctrl+N
75Ctrl+O
76Ctrl+X
77Ctrl+C
78Ctrl+V
79Ctrl+Z
80Ctrl+PageUp
81PageUp
82PageDown
83Ctrl+PageDown
84Ctrl+G
85Ctrl+R
86Ctrl+P

 

Thanks

Sayuti

Re: Check other Modus is aktually opend, and close Modus

$
0
0

Hi Emil,

 

Do you want to keep at least one session (modus) open and close the other? If that is the case then try the following:

 

Option Explicit

 

 

Sub CloseAllExceptOneSession()

    'require early binding to C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx

    Dim sapGui As SAPFEWSELib.GuiApplication

    Dim sapCon As SAPFEWSELib.GuiConnection

    Dim sapSession As SAPFEWSELib.GuiSession

 

 

   

    Set sapGui = GetObject("sapgui").GetScriptingEngine

    Set sapCon = sapGui.Children(0)

   

    If sapCon.Children.Count > 1 Then

        Dim i As Long

        For i = sapCon.Children.Count - 1 To 1 Step -1

             Set sapSession = sapCon.Children(i)

             sapSession.FindById("wnd[0]").Close

        Next i

    Else

        MsgBox "Only one session open now"

    End If

   

    Set sapSession = Nothing

    Set sapCon = Nothing

    Set sapGui = Nothing

 

 

End Sub

 

Thanks,

Sayuti

CreateObject("SAP.Functions") with existing connection

$
0
0

Hello together,

 

until today i was only working with the Objects from SAP GUI Scripting. A new problem at work forces me to learn more about SAP.Functions

 

Right now my problem is to give this object a valid connection. I tryied to assign a existing and connected sap gui connection, but this doesnt work:

 

Sub Test()

    qp.SAPGUI.SetGuiConnection "PS5", 470

 

 

    Dim oFunctions As Object

    Set oFunctions = CreateObject("SAP.Functions")

   

    'Verbindung herstellen

    oFunctions.Connection = qp.SAPGUI.GuiConnection   'ERROR IN THIS LINE

   

    'Funktion zu FUNCTIONS-Object hinzufügen

    Dim oData As Object

    Set oData = oFunctions.Add("/SIE/AD_ZPP_VERB_U_BEST_AUSG")

   

    'Funktion aufrufen

    oData.Call

End Sub

 

I cant login with a username and password, it is only allowed to use open connections. We use PKI Cards instead of usernames and passwords.

 

 

Anyone who knows a way to solve this problem?? Thanks so far!

Re: Script pauses when windows dialog box asks for file save location...

$
0
0

Well, thats awesome but it didnt help.  VBA returned, "...VKEY not enabled..." however.  I copied/pasted the data as follows

 

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").contextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectContextMenuItemByPosition "0"

Is there a good way to get an xpath reference from SAP for use in SAP GUI?

$
0
0

I am doing a fair bit of SAP GUI scripting with VBA.

 

Most of the time I record an SAP GUI script via the recorder and edit it appropriately. However, increasingly often as I am familiar with SAP GUI and begin modifying existing scripts, I want to know the x-path reference for menu items so I can incorporate them in my scripts.

 

For example, my most recent pursuit was a confirmation yes/no button which resulted with:

 

    m_Session.findById("wnd[1]/usr/btnSPOP-OPTION1").press

 

in exploring the SAP interface I've not been able to find a good way to get this path (wnd[1]/usr/btnSPOP-OPTION1) from SAP. I know I can go into m_Session on the VBA side with the properties explorer and eventually get the path in a format like - "/app/con[0]/ses[0]/wnd[1]/usr/btnSPOP-OPTION1" - which kind of works. This is a huge hassle to gothrough in many cases 4+ layers to get there though. Plus many of the SAP field names aren't exactly the most clear and it takes a while to figure out what the correct one is.

 

I'd like to be able to do something similar to the F1 (help) --> technical information query which can give some of the information I want.

 

Is this possible to get from SAP? Or should I just write a "SAP GUI scraper" in VBA which reports out ALL x-paths contained within the session object and try to get enough information to make this meaningful?

Extract data from a Shell container using VBS - S_ALR_87012168

$
0
0

Hello everyone,

 

I'm trying to automate the extraction of informations to excel in some transactions, i was able to do this but im still missing a very important part, in transaction "S_ALR_87012168", i need to find a way to get this information from column Due-Total OI, row (Doc. Type=DG), is there a way to do this??

 

Thanks in advance for your help!!


How to Logon with RFC

$
0
0

Good Day!

 

I want do do a login with RFC SAP.Logoncontrol.1. I dont want to use SSO instead of Username and password.

 

Has anybody expierience with this? i am not sure what to type in the values marked red

 

    Dim oConnection As Connection

    Set oConnection = oLogonControl.NewConnection

   

    With oConnection

        .ApplicationServer = "pkgps50d.os.fth.sbs.de"

        .Client = 470

        .SystemNumber = 46

        .System = "PS5"

        .SystemID = "PS5"

        .Language = "DE"

        .SNC = True

        .SNCQuality = 9

        .SNCName = ""

        .UseSAPLogonIni = True

        .Logon 0, False

    End With

 

 

Would be appreciated if someone can help me.

 

Max

Re: How to Logon with RFC

$
0
0

Hi Max

 

it looks to me that followings are already ok

        .ApplicationServer = "pkgps50d.os.fth.sbs.de"

        .SystemNumber = 46

        .System = "PS5"

        .SystemID = "PS5"

        .SNCQuality = 9


below something you need to change

        .SNCName = "<SNCNameOfSAPSystem>"

(e.g..SNCName = "p:CN=XXX, O=SAP-AG, C=EN")

 

 

Did you already tried to retrieve last details from sapgui?

Let me know how it goes

a


Re: How to Logon with RFC

$
0
0

Hey Andrea! First of all: thanks for you reply.

 

I must admin, that i dont have any idea what to type for SNCName. Where can i find this SNCName? Is the SNC-Function used for the SSO-Login?

 

Thank you for your help!

Re: How to Logon with RFC

$
0
0

Hi Max

 

noworries

 

looking what you wrote i assumed you have snc activated on your systems, so you can find detailed infos choosing property of the entry in your saplogon and the switching to network tab

 

SNC is not for SSO , it's the encrypted communication between sap gui and sap application

 

Let me know if you need more info

a

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

$
0
0

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

Viewing all 1708 articles
Browse latest View live


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