on 09-07-2018 3:04 PM
Hi,
I'm trying to automate some SAP actions with Excel.
I Recorded some Script from SAP an most is working just fine, I only have a problem selecting the active row in CS02 after positioning the right RowID.
Recording results in:
session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").getAbsoluteRow(39).selected = true
But I can't select a row with the AbsoluteRow number since I don't know that number.
Any ideas how to select the entire line so it can be deleted?
Thanks.
Hi Daniel,
I tried that but I didn't work 😞
However, in the meantime I tried some other possible tactics and finally got it to work as I wanted.
objSess.FindById("wnd[0]/mbar/menu[1]/menu[10]").Select
objSess.FindById("wnd[1]/usr/subPOS_SETP:SAPLCSDI:0710/txtRC29P-SELPO").Text = <searchValue>
objSess.FindById("wnd[1]/tbar[0]/btn[0]").press
numrRow = objSess.FindById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").VerticalScrollbar.Position
objSess.FindById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").VerticalScrollbar.Position = numrRow + 1
objSess.FindById("wnd[0]").sendVKey 9
objSess.FindById("wnd[0]/tbar[1]/btn[14]").press
objSess.FindById("wnd[0]").sendVKey 0
objSess.FindById("wnd[1]/usr/btnSPOP-OPTION1").press
first 3 lines is positioning to the line I wanted to find.
then get the Vertical scrollbar position.
add 1 to that value (ie. scroll down one line so the line to be selected is just outside the visible window
then press F9 to select the line (for some reasons the line that get selected is the line which is outside the visible window, above the top visible line)
and then 3 lines to delete the selected line as I wanted to do.
Issue is solved with this solution.
Thanks to everybody who tried to help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
glad you got it working the way you wanted. Still, I tested Stefans suggestion in CS02
For i = 0 To session.FindById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").VisibleRowCount - 1
If session.FindById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/txtRC29P-POSNR[0," & CStr(i) & "]").text = test Then
session.FindById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").GetAbsoluteRow(i).Selected = True
End If
Next
which works as expected. Only additional logic would be if you don't find it within the visible rows & have to page down.
Obviously replace txtRC29P-POSNR with the cell of your choice.
Hi Stefan
I searched a long time how select an item in CS02.
The problem with 'getAbsoluteRow().selected = true' and 'VisibleRowCount' is that it does not work proprely and I had to use 'on error resume next'. Now I could find the row number after use menu 'edit\Position'.
You can find the position on field RC29P-ENTAC, example select pos. 305
session.findById("wnd[0]/tbar[0]/okcd").text = "/ncs02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRC29N-MATNR").text = "material number"
session.findById("wnd[0]/usr/ctxtRC29N-WERKS").text = "plant"
session.findById("wnd[0]/usr/ctxtRC29N-STLAN").text = "1"
session.findById("wnd[0]/tbar[1]/btn[5]").press
session.findById("wnd[0]/mbar/menu[1]/menu[11]").select
session.findById("wnd[1]/usr/subPOS_SETP:SAPLCSDI:0710/txtRC29P-SELPO").text = "0305"
session.findById("wnd[1]/tbar[0]/btn[0]").press
Pos_nb = (session.findById("wnd[0]/usr/txtRC29P-ENTAC").text)
session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").getAbsoluteRow(Pos_nb - 1).selected = True
Best regards
Jean-Luc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan,
Thank you for your help, but this isn't what I'm looking for.
CS02 is the Bill of Materials.
I use the scripting to select the right "Pos." code and then I want to select the entire row.
Manually you can highlight (select) the entire row by clicking on the grey square in front of it. I want to do this so I can delete the line.
Any other thoughts?
Thanks,
Wim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think Stefan has a reliable solution for your problem statement.
In your script, you have tblSAPLCSDITCMAT. Stefan has given a snippet referencing tblSAPMBIBSTC537
Based on the tests you want to perform, you would loop as Stefan has, & once you find the row that meets your test criteria, you could select absolute row i.
You simply need to map your test, to Stefan's pattern.
Hello Wim,
welcome in the SAP Community.
I am not sure that I understand your question correctly. I would to loop over the table control to get the correct entry via its description and select it.
For i = 0 To session.findById("wnd[0]/usr/tblSAPMBIBSTC537").VisibleRowCount - 1
If session.findById("wnd[0]/usr/tblSAPMBIBSTC537/txtLOOP410-TEXT[0," & CStr(i) & "]").Text = "Familie" Then
session.findById("wnd[0]/usr/tblSAPMBIBSTC537").getAbsoluteRow(i).selected = true
End If
Next
Let us know your results.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.