"-Begin-----------------------------------------------------------------
Report zGoogleTranslate.

Type-Pools OLE2.

Data:
  Text2Translate Type String Value ''.
  TranslatedText Type String Value ''.

"-Main----------------------------------------------------------------
Text2Translate = 'Ein grünes Auto fährt schnell auf der Strasse.'.
Write: Text2Translate.
Perform TranslateByGoogle Using Text2Translate 'de' 'en'
  Changing TranslatedText.
Write: / TranslatedText.

"-Function TranslateByGoogle------------------------------------------
Form TranslateByGoogle Using OriginalText Type String
  LangCodeFrom Type String LangCodeTo Type String
  Changing TranslatedText Type String.

  Constants WebSite Type String Value 'http://translate.google.com'.

  Data:
    IE Type OLE2_OBJECT,
    IEDoc Type OLE2_OBJECT,
    ResBox Type OLE2_OBJECT,
    URLTarget Type String Value ''.

  Create Object IE 'InternetExplorer.Application'.
  If IE-Handle > 0.
    Concatenate WebSite '/#' LangCodeFrom '|' LangCodeTo '|'
      OriginalText Into URLTarget.
    Call Method Of IE 'Navigate' Exporting #1 = URLTarget.
    Call Function 'AC_SYSTEM_FLUSH' Exceptions Others = 1.
    If sy-subrc = 0.
      Wait Up To 3 Seconds.
      Get Property Of IE 'Document' = IEDoc.
      If IEDoc-Handle > 0.
        Call Method Of IEDoc 'getElementById' = ResBox
          Exporting #1 = 'result_box'.
        If ResBox-Handle > 0.
          Get Property Of ResBox 'innerText' = TranslatedText.
        EndIf.
      EndIf.
    EndIf.
    Free Object IE.
  EndIf.

EndForm.

"-End-------------------------------------------------------------------