Example of code using cl_spfl_profile_parameter=>change_value
, which works well on ABAP 7.40 SP 23 (NB: sapgui/user_scripting
is a dynamic parameter i.e., it can be changed at runtime).
Note that it works along with the function module TH_SERVER_LIST
, in case the SAP instance runs with several application servers (for load distribution):
REPORT z_activate_sap_gui_scripting.
TYPES tt_server TYPE STANDARD TABLE OF msxxlist WITH EMPTY KEY.
DATA(lt_server) = VALUE tt_server( ).
CALL FUNCTION 'TH_SERVER_LIST' TABLES list = lt_server.
LOOP AT lt_server REFERENCE INTO DATA(ls_server).
cl_spfl_profile_parameter=>change_value(
EXPORTING
name = 'sapgui/user_scripting'
value = 'TRUE'
server_name = CONV #( ls_server->name )
IMPORTING
msg = DATA(msg)
RECEIVING
rc = DATA(rc) ).
WRITE : / ls_server->name, rc, msg.
ENDLOOP.
The effect of dynamic switching can be seen via the transaction code RZ11
:

NB: not related to the topic, only specific to sapgui/user_scripting
, the effect can be also seen by logoff and logon again > SAP GUI options > Script Recording and Playback is activated:
