none
Focus on SAP window using VBA RRS feed

  • Question

  • Hi Im new here.

    Can somebody help me with excel and SAP PRL/PRE through VBA?

    User receives excel file sheet as an input data to SAP, through mail. Tool Uploads data from excel sheets to SAP. Ive tried an APPACTIVATE ("microsoft")  ,send keys and mouse click events…for I cant remember the exact phase.can any one help me how can do write sendkeys upload the the data into sap system

     

    Thanks very much for your replies.

    Rammi

    Saturday, August 16, 2014 3:35 AM

Answers

  • With Sendkeys you need a lot of code to transfer data in a relative safe way.
    I know what I'm talking about, because I'm doing the same with proAlpha (similar ERP system).

    Here are a few glimpses of how to do it right:

    a) When you execute the macro means Excel is the active window, so you have to search the destination window first (the SAP window).

    Related API's: FindWindow, EnumWindows, GetWindowTextA, GetWindowTextLengthA, SendMessage

    b) When you found it, you have to determine which/where are the correct input fields. That is no so easy, because you only see the "Prompt:" on screen, but that child window is only the label. The edit field is below or at the right of the label. So you have to search for the label, then determine the next edit field in the appropiate direction.

    Related API's: EnumChildWindows, GetWindowRect, SendMessage

    c) Okay, now you have the main window (SAP window) and the child windows (edit fields), you can start with SendKeys.

    d) At first try to active the SAP window, wait until it is active, then send the key to open the record.

    Related API's: SetForegroundWindow, GetForegroundWindow

    e) Now you have to determine if the key stroke was successfull, means you can type something in the edit fields. (Otherwise following keys can lead into a real trouble, e.g. "D {ENTER}" can delete the record!)

    Related API's: Don't know, depends on the SAP window.

    f) Now active the edit field, don't use SENDKEYS for that!!! Almost any ERP window has options (choosed by combo boxes, check boxes, radio buttons) that en-/or disables some edit fields.

    Means if you press blind 9x TAB can lead into an activation of different edit fields!

    Related API's: SetForegroundWindow, GetForegroundWindow

    g) Now you can use Sendkeys and type something

    h) Check if the edit field has a value what you have send!

    i) Send the SAVE keystroke to the SAP window, your macro ends.

    Related API's: Depends on the type of the edit field

    Long talk, short end: It is possible, but it is worth the effort?

    Andreas.
    Saturday, August 16, 2014 8:05 AM