I have some methods already that I'm using for connecting to SAP GUI Scripting Engine using Java & JACOB library - I'm somehow unable to make one more method I'd like to use.
I am using "PoojaGugu" https://github.com/PoojaGugu/SAP-GuiClient-Automation/blob/master/Java/library/src/main/java/com/library/generic/SAPGeneric.java for studying the case.
I already tried copying some methods with editing some places in it, although it did not work. I can't provide you with examples.
So let me get to the actual problem here. I've got quite a lot of VBA code right now. I've been messing around with Java - just to get to know something else than making a macros in Excel. I'm using VB for connecting to SAP scripting engine, just to automate some work I've got. I can't make a proper method using Java&Jacob to do specifically this:
Set grid = session.FindById("wnd[0]/usr/cntlWC_INSP_CHAR/shellcont/shell")
grid.pressToolbarButton "&SORT_DSC"
That is how it looks like in my Excel macro, that one works. To simplify it:
session.FindById("wnd[0]/usr/cntlWC_INSP_CHAR/shellcont/shell").pressToolbarButton "&SORT_DSC"
It is pushing a button with id &SORT_DSC on SapGrid object. But using examples mentioned earlier I can provide you with a method that works on the very same display (transaction) on a very same "grid" scope:
*/SAPGuiGridSelectOrDeselectColumn
* Objective - to select or deselect the column in the grid
* parameter : partial id string , column name , SelectOrDeselect - Pass true to select column and false to Deselect the column
* created by Venkata Siva kumar
*/
public void SAPGuiGridSelectOrDeselectColumn(String idstr, String column, boolean SelectOrDeselect) throws Exception
{
String id = getSAPObjectIDHelperMethod(getSession(), "ID", idstr, "", "");
session = new ActiveXComponent(getSession().invoke("FindById",id).toDispatch());
if (SelectOrDeselect)
Dispatch.call(session, "selectColumn", column);
else
Dispatch.call(session, "deselectColumn", column);
}
/*SAPGuiGridSelectOrDeselectColumn
This one is selecting columns from the table on that same page. To give you an image on how I do it in VBA:
grid.selectColumn "VARIANCE"
where a "grid" is previously mentioned path/object adress. It selects a column named "VARIANCE" withing the same SapGuiGrid scope that I want to press the %SORT button. That method works.
I wanted to make my method based on this one to click the button I mentioned earlier with no success (not only that method to be honest). How can I proceed?
This is what I came up with:
ActiveXComponent guiShellObject= new ActiveXComponent(Session.invoke("findById", "wnd[0]/usr/cntlWC_INSP_CHAR/shellcont/shell").toDispatch());
guiShellObject.invoke("pressToolbarButton", "&SORT_DSC");
That would replace:
session.FindById("wnd[0]/usr/cntlWC_INSP_CHAR/shellcont/shell").pressToolbarButton "&SORT_DSC"
Above example is self-explaining enough. I did not know how to do that untill I learned that I can pass on additional parameters with invoke method than only one.