Set

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. 

Options
-stringlength The length of the given string (in bytes) 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.

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“  

-uppercase The value is put into upper case
-lowercase The value is put into lower case
-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.
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 Input Assistant Tutorial also.

Set