Hi,
I am new to SAPGUI scripting. Am tring to access a table get some data of it. Am using SAPFEWSE.ocx
i used SAPFEWSELib and so far i was able to Login and navigate to the table. But I cant extracte specific data from them. Here is my code so far.
Can anyone help me on how to get a value from a table. Am getting error at the redline. PLease help me.
Private Sub loginInfo() sapSession = sapCon.Children(0) With sapSession ' MsgBox(.FindById("wnd[0]/usr/txtRSYST-MANDT").Text) ' .FindById("wnd[0]/usr/txtRSYST-MANDT").Text = "200" ' MsgBox(.FindById("wnd[0]/usr/txtRSYST-MANDT").Text) .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) End With End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try ' sapID = TextBox1.Text 'sapPassword = TextBox2.Text sap = CreateObject("SAPGUI.Scriptingctrl.1") sapCon = sap.OpenConnectionByConnectionString(sapServer, True) Create_File() loginInfo() prcss_data Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub prcss_data() With sapSession .FindById("wnd[0]/tbar[0]/okcd").text = "se16" .FindById("wnd[0]").sendvKey(0) .FindById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "zu1cd_fkkvkp" .FindById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").caretPosition = 12 .FindById("wnd[0]").sendVKey(0) '.FindById("wnd[0]/usr/ctxtI1-LOW").text = "W573121387" '.FindById("wnd[0]").sendVKey(8) '.FindById("wnd[0]/usr/ctxtI1-LOW").text = "" .FindById("wnd[0]/usr/ctxtI1-LOW").caretPosition = 0 .FindById("wnd[0]").sendVKey(8) .FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").setCurrentCell(-1, "GPART") .FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectColumn("GPART") .FindById("wnd[0]/tbar[1]/btn[40]").press Dim stt As String For i = 1 To 10 stt = .FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").setCurrentCell(1, 3) .FindById("wnd[0]/usr/txtI2-LOW").caretPosition = 10 .FindById("wnd[0]/usr/txtI2-LOW").setFocus Write_log(stt) Next .FindById("wnd[0]").sendVKey(3) .FindById("wnd[0]/usr/ctxtI1-LOW").text = "0200000882" .FindById("wnd[0]/usr/txtI2-LOW").setFocus .FindById("wnd[0]/usr/txtI2-LOW").caretPosition = 10 .FindById("wnd[0]").sendVKey(8) .FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellColumn = "OFFCYCLE" .FindById("wnd[0]/usr/cntlGRID1/shellcont/shell").firstVisibleColumn = "BUSINITCODE" End With End Sub Dim fs As Object Dim fs_file As Object Dim fname As String Private Sub Write_log(ByVal linestr As String) fs_file.writeline(linestr) End Sub Private Sub Create_File() fs = CreateObject("Scripting.FileSystemObject") fname = My.Application.Info.DirectoryPath + "\Log" + Date.Now.ToString("yyyyMMddHHmmss") & ".csv" fs_file = fs.CreateTextFile(fname, True) End Sub