Purpose With Set you can assign a value to an input field. The Set command is useful in the definition of an InputScript. In contrast to Default, the Set command ignores any previous field value. It does not make much sense to use Set in normal GuiXT scripts.

You can also use set in order to assign a value to a global variable. Be careful to use unique names for your global variables.

Example Set F[Order type] "CS"

The value "CS" is assigned to the field F[Order type].

Often the value is specified as parameter of the InputScript, or as a previously defined input field, e.g.

Parameter OType

...

Set F[Order Type] "&[OType]"

The following line sets the value of a global variable MM01_current_material:

Set V[MM01_current_material] "&[Material]"

Format
Set [Input field] "Value" Sets an input field value.
Set V[vname] "Value" Sets a global variable.
Set V[gnm*] "Value" Sets all global variables where the name starts with "gnm*".
Set V[vname](x-y) "Value" Sets a substring of a global variable. If the former length of the variable is less than x, it is filled with "Space" until position x.
Set Text[xxx] "Value" as a short form for:

Set V[y] "Value"
CopyText fromString="y" toText="xxx"

In the same way &Text[xxx] in strings will be replaced with the content of the longtext xxx.
Set list[rowno,colno] "Value"

Set list[rowno,colno,len] "Value"

To be used in ABAP lists.  The specified string is written into the list at row rowno and column colno, where the counting starts with 0 and relates to the currently displayed page. Optionally the desired length len of the string can be specified.

Please note: The system variable V[_listfirstvisiblerow]  contains the absolute line number of the first list line of the currently displayed page, starting with 1.

Options
-stringlength The length of the given string (in bytes) is put into the variable
-charCount The number of characters of the given string is put into the variable
search= The specified string is searched in the given text (ignoring upper/lower case). If the string is found, the following word is set into the variable. Example:

Set V[docno] "&V[_message]" Search="document"

Assume that the system variable  V[_message] has the value  "Document 10004003 was posted". The variable  V[docno] then gets the value  "10004003".

With if Q[ok] you can query whether the search string has been found.

-position In conjunction with search=: The position 1,2,3, ... (in bytes) of the searched string is put into the variable. If not found: 0.
-charPosition In conjunction with search=: The position 1,2,3, ... (in characters) of the searched string is put into the variable. If not found: 0.
pattern= The specified pattern is searched in the string. The pattern string can contain the "wildcard" symbols
  • '%'  any string, delimited by next matching character in pattern string
  • '_'  single character

All characters of the given string that correspond to wildcard symbols in the pattern string are put into the variable, going from left to right. If a non-matching character is found, the search ends.

With if Q[ok] you can query whether the string matches the pattern.

Examples:

Set V[x]   "02.05.2007"  pattern="__.__.____"       //  ok  V[x] = "02052007"
Set V[x]   "[abcd]"      pattern="[%]"             //  ok  V[x] ="abcd"
Set V[x]   "12"          pattern="%kg"             // not ok   V[x]= "12"  
Set
V[x]   "Document 400000087 created" pattern=
"Document % created"  // ok   V[x]= "400000087"  

regex= Specifies a regular expression (ECMAScript syntax). The substring matching the regular expression is transferred.

With if Q[ok] you can query whether the string matches the regular expression.

Examples:

Set V[x]   "478"  regex="^[0-9]{3}$"       //  ok.  V[x] = "478",  checks for exactly 3 digits
Set V[x]   "M20"    regex="^(M1|M2|V1)$"             //  not ok,  V[x] = "",  checks for M1 or M2 or V1
Set V[x]   "Document 400000087 added on 04.11.2020"    regex="[0-9]+"             //   ok,  V[x] = "400000087", checks for digit sequence

regexReplace=
regexReplaceFirst=
In conjunction with regex=: All substrings found or the first substring found is replaced by the specified string.

With if Q[ok] you can query if the string has been changed.

Example:

Set V[x]   "The number 478 occurs twice: 487"  regex="[0-9]{3}"   regexReplace="XXX"     //  ok.  V[x] = "The number XXX occurs twice: XXX"

-upperCase The value is put into upper case
-lowerCase The value is put into lower case
-alignRight The value is right-aligned in the target variable. Requires setting a length in the target variable.
-unpack A value that has been returned by a function call (e.g. a BAPI) in "packed decimal" format is converted into a series of normal digits.
-pack The value is stored in packed decimal format.
Computations 
Set allows computing with the operators +, -, *, /, using 2 operands in each case. The result is  put into a variable in edited format. Both operands can be either values  (e.g. 1 or 5830), or can be referenced by variable names ("&V[...]"). Examples:

Set V[value]            5830 / 365
Set V[value]     "&V[total]" / 365
Set V[value]     "&V[total]" / "&V[days]"
Set V[total]   "&V[amount1]" + "&V[amount2]"
Set V[index]     "&V[index]" + 1

The result is rounded to 2 decimal places. For logon language English a decimal point is used, otherwise a comma. See also the additional options and the  DecimalSeparator command. If the result is an integer value, no decimal places are shown, e.g. "12" instead of "12.00".

decimals= Specifies the number of decimals places in the result (0,1,2,3,...). Integer values are then also displayed with decimal places, e.g. "12.00".
decimalSeparator= You can specify "." or ",". The decimal separator is used both for interpreting  the operands and for  editing the result.
decimalseparator=UserDefault The default (point or comma) is taken from the user's profile, which is read when the command is executed the first time. A valid RFC user name and password are necessary for this function (GuiXT profile).
groupSeparator= You can specify "," or ".". Groups of 3 digits are separated by the specified character.
groupSeparator=UserDefault The default (point or comma) is taken from the user's profile, which is read when the command is executed the first time. A valid RFC user name and password are necessary for this function (GuiXT profile).
Example
Set V[x]   24682471 / 7   decimals=3   decimalSeparator="."   groupSeparator=","

The variable V[x] obtains the value  "3,526,067.286". The exact result is  "3526067.285714...". It is rounded to 3 decimal places, and then edited according to the specified options.

Tips
& Tricks
  • You can mark a checkbox with Set: use the values "X" or " ", or a parameter which has one of these values.
  • In a similar way you can use Set for radiobuttons. If you activate one radiobutton it is not necessary to deactivate the other radiobuttons in this group, since this is done automatically.

    For example

    Set R[Documentation] "X"

    in transaction SE38 would deactivate the other radiobuttons R[Source], R[Variants], R[Attributes], R[Text elements].

  • Please read the InputAssistant Tutorial also.
Components GuiXT (for own variables: GuiXT + InputAssistant)