Report zVBScript2.

    "-Type pools--------------------------------------------------------
      Type-Pools OLE2.

      Constants CrLf(2) Type c Value %_CR_LF.

      Data ScriptCtrl Type OLE2_OBJECT.
      Data Command Type String Value ''.
      Data Line Type String Value ''.
      Data Module Type String Value ''.
      Data Result Type Integer.

      Define AddLine.
        Concatenate Module &1 CrLf Into Module.

      Create Object ScriptCtrl 'MSScriptControl.ScriptControl'.

      If sy-subrc = 0.

        "-Allow to display UI elements----------------------------------
          Set Property Of ScriptCtrl 'AllowUI' = 1.

        "-Intialize the VBScript language-------------------------------
          Set Property Of ScriptCtrl 'Language' = 'VBScript'.

        "- Execution of VBScript functions with parameters
          AddLine 'Function plus(val1, val2)'.
          AddLine '  plus = val1 + val2'.
          AddLine 'End Function'.

          AddLine 'Function minus(val1, val2)'.
          AddLine '  minus = val1 - val2'.
          AddLine 'End Function'.

          AddLine 'Function plusminus(val1, val2, val3)'.
          AddLine '  Dim res'.
          AddLine '  res = plus(val1, val2)'.
          AddLine '  plusminus = minus(res, val3)'.
          AddLine 'End Function'.

          Call Method Of ScriptCtrl 'AddCode' Exporting #1 = Module.

          If sy-subrc = 0.
            Call Method Of ScriptCtrl 'Eval' = Result
              Exporting #1 = 'plusminus(32, 16, 8)'.
            Write: / Result. "Result = 40

        "-Free the object-----------------------------------------------
          Free Object ScriptCtrl.