Skip to Content
0

PO heder note update in me22n by using script.

Apr 08 at 05:35 AM

18

avatar image

I am trying to update the PO heder note in me22n, I am able to update but the older comment what ever is there it's getting deleted and it is taking new update only, below I have mentioned my code kindly add or correct me.

Public SapGuiAuto, WScript, msgcol
Public objGui As GuiApplication
Public objConn As GuiConnection
Public objSess As GuiSession
Public objSBar As GuiStatusbar
Dim W_System
Public objSheet As Worksheet


Function Attach_Session() As Boolean
Dim il, it
Dim W_conn, W_Sess

If W_System = "" Then
Attach_Session = False
Exit Function
End If

If Not objSess Is Nothing Then
If objSess.Info.SystemName & objSess.Info.Client = W_System Then
Attach_Session = True
Exit Function
End If
End If

If objGui Is Nothing Then
Set SapGuiAuto = GetObject("SAPGUI")
Set objGui = SapGuiAuto.GetScriptingEngine
End If

For il = 0 To objGui.Children.Count - 1
Set W_conn = objGui.Children(il + 0)
For it = 0 To W_conn.Children.Count - 1
Set W_Sess = W_conn.Children(it + 0)
If W_Sess.Info.SystemName & W_Sess.Info.Client = W_System Then
Set objConn = objGui.Children(il + 0)
Set objSess = objConn.Children(it + 0)
Exit For
End If
Next
Next

If objSess Is Nothing Then
MsgBox "No active session to system " + W_System + ", or scripting is not enabled.", vbCritical + vbOKOnly
Attach_Session = False
Exit Function
End If

If IsObject(WScript) Then
WScript.ConnectObject objSess, "on"
WScript.ConnectObject objGui, "on"
End If

Set objSBar = objSess.FindById("wnd[0]/sbar")
objSess.FindById("wnd[0]").maximize
Attach_Session = True


End Function


Public Sub RunGUIScript()

Dim xclapp As Excel.Application
Dim xclwbk As Excel.Workbook
Dim xclsht As Excel.Sheets
Dim W_Ret As Boolean
Dim i As Integer
Dim j As String

W_Ret = Attach_Session
If Not W_Ret Then
Exit Sub
End If
j = 0
i = 0

Set xclapp = GetObject("excel.Application")
Set xclwbk = xclapp.Open("C:\Users\indut\Desktop")
Set xclsht = xclwbk.Sheets("Sheet1")

While Cells(12 + i, 1).Value <> ""


objSess.FindById("wnd[0]").maximize
objSess.FindById("wnd[0]/tbar[0]/okcd").Text = "me22n"
objSess.FindById("wnd[0]").sendVKey 0
objSess.FindById("wnd[0]/tbar[1]/btn[17]").Press
objSess.FindById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").Text = Cells(12 + i, 1).Value
objSess.FindById("wnd[1]").sendVKey 0
objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT3/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1230/subTEXTS:SAPLMMTE:0100/subEDITOR:SAPLMMTE:0101/cntlTEXT_EDITOR_0101/shellcont/shell").SetSelectionIndexes 0, 20 = Cells(12 + i, 3).Value
objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT3").Select
objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT3/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1230/subTEXTS:SAPLMMTE:0100/cntlTEXT_TYPES_0100/shell").SelectedNode = "F02"

objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT3/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1230/subTEXTS:SAPLMMTE:0100/subEDITOR:SAPLMMTE:0101/cntlTEXT_EDITOR_0101/shellcont/shell").Text = Cells(12 + i, 2).Value
objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT3/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1230/subTEXTS:SAPLMMTE:0100/subEDITOR:SAPLMMTE:0101/cntlTEXT_EDITOR_0101/shellcont/shell").SetSelectionIndexes 33, 33
objSess.FindById("wnd[0]/tbar[0]/btn[11]").Press
objSess.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/tabpTABHDT3/ssubTABSTRIPCONTROL2SUB:SAPLMEGUI:1230/subTEXTS:SAPLMMTE:0100/subEDITOR:SAPLMMTE:0101/cntlTEXT_EDITOR_0101/shellcont/shell").SetSelectionIndexes 0, 0
objSess.FindById("wnd[0]/tbar[0]/okcd").Text = "/n"
objSess.FindById("wnd[0]").sendVKey 0
objSess.FindById("wnd[0]/tbar[0]/okcd").Text = "/n"
objSess.FindById("wnd[0]").sendVKey 0

i = i + 1

Set xlcsht = Nothing
xclwbk.Close SaveChanges:=True
Set xclwbk = Nothing
xclapp.Quit
Set xclapp = Nothing

Wend

End Sub
Sub StartExtract()
Dim currentline As Integer

' This is the system to connect to
W_System = "BTS810"

' Run the actual GUI script
RunGUIScript
objSess.EndTransaction

End Sub

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers