on 2023 Nov 13 2:35 PM
Hello,
I have a big problem with an issue which should be very simple, I think. I cannot set session to get transaction by a number. After a lot of tests a conclusion is that my SAP does not accept the number of session which I retrieve, but assign to each session other number - depending of the order of opening the sessions. Is it possible that this is a matter of settings? Can I adjust it? Please help
Dim SessionNumber As Long
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.createSession
SessionNumber = session.info.SessionNumber
Set session = Connection.Children(CLng(SessionNumber - 1))
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nva02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").Text = Target.Offset(0, -12).Value
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 10
session.findById("wnd[0]/usr/btnBT_SUCH").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
Set session = Connection.Children(CLng(SessionNumber))
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nZOTC0207_01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_A/ssub%_SUBSCREEN_B12:ZEOTC0092_01_NEW:0200/ctxtS_MATNR2-LOW").SetFocus
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_A/ssub%_SUBSCREEN_B12:ZEOTC0092_01_NEW:0200/ctxtS_MATNR2-LOW").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_C").Select
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_C/ssub%_SUBSCREEN_B12:ZEOTC0092_01_NEW:0100/ctxtS_MATNR1-LOW").Text = Target.Offset(0, iGTINposition - 13).Value
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_C/ssub%_SUBSCREEN_B12:ZEOTC0092_01_NEW:0100/ctxtS_WERKS1-LOW").Text = Target.Offset(0, -2).Value
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_C/ssub%_SUBSCREEN_B12:ZEOTC0092_01_NEW:0100/ctxtS_WERKS1-LOW").SetFocus
session.findById("wnd[0]/usr/tabsTABSTRIP_B12/tabpPUSH_C/ssub%_SUBSCREEN_B12:ZEOTC0092_01_NEW:0100/ctxtS_WERKS1-LOW").caretPosition = 4
session.findById("wnd[0]/tbar[1]/btn[8]").press
End If
Request clarification before answering.
User | Count |
---|---|
15 | |
8 | |
7 | |
6 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.