I'm having some issues with my code that I wasn't able to find anywhere.
Issue: While debugging my code, running it line by line with F8 in Excel, at some specific points Excel does not wait for the application with which it's interacting to finish and proceeds to execute the rest of the code.
What is the macro: It's an a macro to automatically input information on SAP ERP transaction code, in this case VA02
. I do believe that this question is more VBA related than SAP related thus I'm posting here and not on SCN.
Where the problem occurs: The issue only happens when I'm changing the partners numbers in the Partner tab(either header or line item level). I've also saw this happens whenever I was trying to add something on the Conditions tab.
What error does it cause?: None, that's the odd part. While debugging, after I execute the line to change the Bill to Party for example (only change the number, no Enter or any other key is sent), the code keeps running and execute the next lines. The even more off thing is that SAP seems to still be processing some of the changes but the VBA code keeps running without errors, meaning that SAP is not on the screen it's showing.
So, if there's no errors what you want?: Well, while in regular run mode it work flawlessly, this issue really makes it very hard to debug, forcing me to put a breakpoint in every... single...code...line...
What have you tried?: I've looked into Async and forced sync, no avail. Also looked in something related to Background Refresh but I guess that's only for query connections, I tried it with SAP GUI connection but also it didn't work.
Hope anyone can shed some light on this subject, maybe saw this previously. I will try to test on a peers computes but didn't had the chance yet, will post my findings after.
Thank you for reading and maybe replying =)
This is just a piece of the code as it's huge, I've noticed the problem is different parts, always the part that's inputting info on SAP GUI. My peer write similar codes, that do the same thing on the same fields and he never got this error so I think it might be related to Excel somehow.
'Bill site
Connection.findById("ses[" & Sesn & "]/wnd[0]/usr/" & ref & "/subSUBSCREEN_PARTNER_OVERVIEW:SAPLV09C:1000/tblSAPLV09CGV_TC_PARTNER_OVERVIEW/ctxtGVS_TC_DATA-REC-PARTNER[1,1]").Text = Dwks.Cells(2, "N")
For this program the error usually starts on this line, but on other ones I've seen it starts on different ones. There's nothing special about this code line, I've used it many times. What comes before it is also pretty standard, just the SAP GUI connection. I'm avoiding post the code here because I'm sure that this is not the cause of the problem, is the same syntax I've always used, with the same elements. This is something Excel related.