abapsap-gui

Can SAP GUI scripts be executed from an ABAP program?


I created a SAP GUI script here and can play it back without any problems: Record and Playback Window

Is there a way to play it back from my own ABAP program?

*&---------------------------------------------------------------------*
*& Report z_monitor_gui_script
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_monitor_gui_script.
" execute C:\Users\test\SAP\sap-gui-scripts\Monitor.vbs ...

I tried to experiment with SM69 + and the SXPG_COMMAND_EXECUTE function call so far, but nothing has worked.
I don't really know what I'm doing though, so unsure if that's the right direction or not.


Solution

  • If the file is located on the user's laptop, the user may run the ABAP program below via SAP GUI for Windows, and it will run the script via his own application SAP GUI for Windows (for information, the VBS script may implement a logic to run on another SAP GUI session than the current one, where the ABAP program runs):

      REPORT z_demo.
      DATA(vbs_path) = `C:\Users\test\SAP\sap-gui-scripts\Monitor.vbs`.
    
      DATA(application) = `%windir%\syswow64\wscript`.
      DATA(parameter) = `"` && vbs_path && `"`.
      cl_gui_frontend_services=>execute(
          EXPORTING
            application = application
            parameter   = parameter
            synchronous = ' '
          EXCEPTIONS
            others      = 1 ).