Purpose With the Process statement, you can call a script from another script or an InputScript.

This allows reusable functions to be implemented, tested separately and used in other scripts.
 Example Process address = customeraddress "&V[kunnr]"

The script file "process_customeraddress.txt" is loaded and executed. The return value is placed in the variable V[address].

Format 1 Process funcname par1 par2 par2 ...

The script "process_funcname.txt" is loaded and executed. The specified parameters par1, par2,... can be either strings, e.g. "X" or "&V[kunnr]", or variables, e.g. V[name1], V[name2]. For details, see the section "Parameter transfer".

Format 2 Process varname = funcname par1 par2 par2

In addition, the value returned in the called script with  Return is placed in the variable V[varname].

Script file name A ".txt" is added to the name specified for Process, e.g. "customeraddress", and "process_" is added in front of it, in the example "process_customeraddress.txt". This script is then searched for in the script directories stored in the GuiXT profile according to the same rules as for other script files.
Local namespace In the called script, all variables V[xxx] are defined locally; the variables from the namespace of the calling script cannot be addressed directly. When the called script is exited, all locally used variables are released.

Structured variables, table variables and long texts text[xxx] are also only created during the processing of the called script.

Exception:
Variables that begin with an underscore, e.g. V[_language], are always taken from the global context, so that all GuiXT system fields remain addressable.
Parameter passing In the called script, the possible parameters are defined with the keyword  Parameter, for example:
 
Parameter ordernumber
Parameter schedule_lines   "N"

Parameters are also local variables that can be addressed with V[ordernumber], V[schedule_lines]. The assignment from the call is done by the position of the parameter. Parameters not specified in the call are given the default value specified as the initial value.
Example :

Set V[vbeln] "0000001234"
Process
myorder = read_customerorder "&V[vbeln]"

At the start of the called script, V[ordernumber] has the value "0000001234" and V[schedule_lines] has the value "N".
Input/Output parameters If variables are given in the call in the format V[xxx], then they are assigned the current value of the parameter when they return from the script.

Example:
 

Parameter serialnumber

Set V[serialnumber] "78923804-89"
Return

Call:

Clear
V[sernr]
Process get_serialnumber V[sernr]

Afterwards, V[sernr] has the value "78923804-89".

In contrast, with the call

Clear V[sernr]
Process get_serialnumber "&V[sernr]"

the variable V[sernr] would remain empty, since its current value is passed to the parameter V[serialnumber], but no retransmission from V[serialnumber] to V[sernr] takes place.
Return value With the format

Process varname = funcname par1 par2 par2

the value "xxx" given at   Return "xxx" is placed in the variable V[varname]. If no value is specified with Return
, V[varname] is filled with the empty string "".
Structure and table variables Structure and table variables can be passed in the format V[xxx] for the current parameters. They are always passed by reference, i.e. changes to the contents are not only reset on return from the called script, but are immediately executed in the structure or table variables.

The called script can then work with the structure or table without its own  CreateStructure or CreateTable, e.g. add table rows with  AppendRow.


Another useful option is to pass variables without a structure and turn them into structure or table variables in the called script with  CreateStructure or CreateTable. The variables can then be used directly with the specified structure after returning from the call.

This also applies to the return value, which is then returned as a structure or table with  Return V[xxx].

Especially when implementing scripts that read in SAP objects such as customer, order, notification,... it is practical to define the entire structure in the called script, e.g. to create the read fields from the order header as well as the order lines as structure and table.

The following call is an example:

Set V[kunnr] "16380"
Process adr = customeraddress "&V[kunnr]"
Message "&V[adr.name1], &V[adr.landx]"

The called script reads the customer address and returns a structure in which the caller can directly address the individual address fields.

// Read customer address
Parameter customernumber
 
CreateStructure V[address] kunnr name1 name2 ort01 pstlz land1 landx
CreateTable V[addresstable] include=V[address]
 
// Build join
Set V[join] "KNA1 left outer join T005T "
Set V[join] "&V[join] on T005T~LAND1 = KNA1~LAND1 "
Set V[join] "&V[join] and T005T~SPRAS = '&V[_language]' "
 
Set V[fields] "KNA1~KUNNR,KNA1~NAME1,KNA1~NAME2,
                      KNA1~ORT01,KNA1~PSTLZ,KNA1~LAND1,T005T~LANDX"

Set V[condition] "KNA1~KUNNR = @KUNNR"
Set V[domname1] "KUNNR"
Set V[domvalue1] "&V[customernumber]"
 
// Select from database
Call /guixt/dbselect  cache="transaction" _
  export.table="join" _
  export.fields="fields" _
  export.condition="condition" _
  export.domname1="domname1" _
  export.domvalue1="domvalue1" _
  import.values="addresstable"
 
ReadRow V[address] table=V[addresstable] index=1
 
Return  V[address]
Long text variables With the notation

Parameter
text[xxx]

a long text parameter is defined in the called script. In the call, a long text variable text[...], a variable V[...] or any string can be specified. The content is always made available in the called script as the content of the long text variable text[xxx].

When text[...] or V[...] is passed to the text parameter, the current content of the long text parameter is copied to the specified text variable or normal variable on return. Example:

Process  wrap_lines text[notification_headertext]  80

Likewise, the return value can be specified by

Return text[xxx]

The content of the long text variable can be returned, either to a normal variable or with the notation

Process text[xyz] = funcname par1 par2 par2


to a long text, here text[xyz].
Nested calls Nested and recursive calls by Process are possible up to a nesting depth of approx. 100. Here, too, each call, even of the same script, has its own set of local variables. 
Details on the procedure The first time a script is executed with Process, the script is loaded into memory and remains there per SAP GUI mode. This eliminates the loading process for repeated calls.

Please note the following during development:
 "Activate Script" in Script Editor Pro removes the script from memory and reloads it the next time it is called. If you only press "Save", a script change only takes effect after opening a new SAP GUI mode.
Debugging In the GuiXT debugger, the local variables are displayed within a script called with Process.
Restrictions You cannot use a screen instruction within a script called with Process. On the other hand, the call via Process is possible without restriction in every screen block of an InputScript.
Performance For 1000 process calls you can expect about 0.03 sec (measured on a PC with 2Ghz CPU). The processing within the called script is somewhat faster than with other scripts, since some optimisations are carried out when loading the script.
Comparison with "include" In principle, reusable functions can also be implemented by "include". In contrast, the process technique offers the following advantages:

- Due to its own variable namespace, there are no side effects from overwriting variables.
- There is no physical loading of scripts after the first call.
- The interface is clearly described
- Smaller functions such as special test routines, formatting, date and time calculations, table processing can also be clearly represented by Process.
- When integrating your own web pages (WebView statement) into SAP GUI, you can execute the same scripts from JavaScript with guixt.process()
Components GuiXT + InputAssistant