Need 2 advanced things in Excel VBA for SAP Scripting. Experts only please :)
(1) Need to be able to set a configurable duration Timeout, when calling an SAP GUI scripting method with Excel VBA. Sometimes the Client freezes during SAP scripting events, and Excel is typically "locked" in an OLE call. The only way to unlock it is to End Task of all open SAP Sessions and then after that, also End Task of the SAP Logon window. Then Excel immediately unlocks and gives the standard End/Debug window. I need to automate this whole process with a Timeout so I can simply "start over fresh" when these freezes occur. They occur normally in 3 situations: (a) when pasting into SAP, (b) when exporting SAP to a spreadsheet, (c) when waiting for results of an Execute call.
The challenge is that during an OLE activity, Excel doesn't continue processing code. So it may have to be some type of external program or Library or something which is launched before the script call, that Windows OS can run and handle the timeout and end tasks if we dont sent a Kill command after SAP successfully executes the transaction. I am thinking that inserting this Timeout function in 3 specific "problem spots" in the code will suffice. Unless there is a way to unlock excel while waiting for SAP. I'm not sure it's possible.
I already have code written to handle the "start over" portion and resuming where I left off.
(2) Need to be able to logon to SAP from scratch. This means launching the SAP Logon file, then choosing a production environment from the list (top default one) and launching a session. This will be needed on initial launch of the script, as well as after the situation described in (1) above occurs. There will also be a window that pops up sometimes saying "you must choose to end current session, or start a second session". We need to detect and handle this window as well.