0

I have a SAP gui script that works for me and does what i want to, so no problem with this. The thing is, with my coworkers, which are supposed to use my code too, my SAP gui script does not work. For example My script on SAP 750:

Session.FindById("wnd[2]/usr/cntlOPTION_CONTAINER/shellcont/shell").CurrentCellColumn = "TEXT"

Clicks on the right button for me, but a completely different one for them. I think it has something to do with SAP GUI versions. Is there a way to do SAP requests that fits any gui?

Edit: I tried scripting on my coworkers computer, here is the line that is different for them Coworker's script on sap 730:

Session.FindById("wnd[2]/usr/cntlOPTION_CONTAINER/shellcont[0]/shell").CurrentCellRow = 0
Session.FindById("wnd[2]/usr/cntlOPTION_CONTAINER/shellcont[0]/shell").SelectedRows = "0"

This is working on SAP gui 750 for me, my coworkers are on SAP 730 and cannot use the newest version. Moreover, I would like my code to be durable (and that i would not need to change it for every new version)

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Samuel
  • 59
  • 9
  • 1
    Hi Samuel and welcome to Stack Overflow! Have you tried to record the macro on their PC then see what differences you get? – Brownish Monster Apr 26 '19 at 09:15
  • Hi @BrownishMonster! Yes, I did. But if i put their macro insted of mine, then it doesn't work anymore on my computer. And since there is a lot of different versions (almost one for each of my coworkers...) it would be too long to make a programm for each one of them. – Samuel Apr 26 '19 at 09:17
  • 1
    What difference is there between your line of code and theirs? They might have `wnd[2]` or something. You might be able to loop through each `btn` and see the label? Sorry I can't be of much help because I no longer have access to SAP at my new workplace. – Brownish Monster Apr 26 '19 at 09:38
  • @BrownishMonster I cant share much of my code on websites because of my company's policy, but the two changing lines are: on my code: ```Session.FindById("wnd[2]/usr/cntlOPTION_CONTAINER/shellcont/shell").CurrentCellColumn = "TEXT" ``` and on theirs: ```Session.FindById("wnd[2]/usr/cntlOPTION_CONTAINER/shellcont[0]/shell").CurrentCellRow = 0 Session.FindById("wnd[2]/usr/cntlOPTION_CONTAINER/shellcont[0]/shell").SelectedRows = "0" ``` – Samuel Apr 26 '19 at 09:52
  • 1
    The two lines look like they are doing different things. In the OP it is pressing a button and in the comment it looks like it's selecting a column of a grid. They are also in different windows. What happens if you run their code in your session? – Brownish Monster Apr 26 '19 at 10:03
  • @brownishMonster i don't get why these two lines are in different windows? They both are (wnd[2])? If i run their code in my session, i get an "Id not found" error showing in excel. – Samuel Apr 26 '19 at 10:41
  • 1
    Sorry, I didn't see both lines, you are correct they are in the same windows. And my sincerest apologies, I don't think I can be of much help. My only suggestion is to debug and add a watch for `wnd[2]/usr/cntlOPTION_CONTAINER`. See if there is any `Children` property or `GetChildren()` method. Alternatively check if `wnd[2]/usr/cntlOPTION_CONTAINER/shellcont` gives an error, if so then use `wnd[2]/usr/cntlOPTION_CONTAINER/shellcont[0]`. Once again, sorry. – Brownish Monster Apr 26 '19 at 10:53
  • That's alright @BrownishMonster! I might have found a solution by using a variant, so the data shared in SAP are the same! I might not express myself correcly. So, i'm going to post this as an answer and will close this question in 48hours, to archive it if someone else needs it in the future. – Samuel Apr 26 '19 at 11:29

1 Answers1

1

So, I've finally found the solution!

To adress the subject, just use a variant of your transaction in SAP. Then, if others use it, it's alright and you share the same data.

Thanks to @BrownishMonster for his help

to take a look at variants and how they work, follow this link: https://help.sap.com/viewer/61155ee7ed304ae8b66b7526555a6a07/6.18.11/en-US

Samuel
  • 59
  • 9