I am trying to write some code to extract data from sap, and then put it into an Excel table. Right now, I have the GUI getting into the right itemnumber
. Here, I have been trying to get some useful code, using the GUI recorder. I have tried to select the data, and open details and selected data here. The trouble I am having is that the code generated by GUI does not give me .value
or .setfocus
or something like this. So I do not know how to approach this. The code from GUI can be seen below:
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nymm_pricelist"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtS_MATNR-LOW").Text = Cells(currentline, 1).Value
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").Text = Cells(currentline, 2).Value
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtS_VKORG-LOW").caretPosition = 4
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").CurrentCellColumn = "LOCALSALES_KBETR"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectedRows = "0"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").ContextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectContextMenuItem "&DETAIL"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").setCurrentCell 4, "VALUE"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").selectedRows = "4"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").ContextMenu
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").CurrentCellRow = 8
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").selectedRows = "8"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").ContextMenu
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").CurrentCellRow = 10
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").selectedRows = "10"
session.findById("wnd[1]/usr/cntlGRID/shellcont/shell").ContextMenu
session.findById("wnd[1]/tbar[0]/btn[0]").press
Any ideas of how to do this?
You could try the following:
. . .
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").ContextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectContextMenuItem "&DETAIL"
set myGrid = session.findById("wnd[1]/usr/cntlGRID/shellcont/shell")
myText_4 = myGrid.getcellvalue (4,"VALUE")
myText_8 = myGrid.getcellvalue (8,"VALUE")
myText_10 = myGrid.getcellvalue (10,"VALUE")
session.findById("wnd[1]/tbar[0]/btn[0]").press
Regards, ScriptMan