Notation A script variable is denoted by V[varname] where varname is the name (or identifier) of the variable.
Tip: Observe a consistent name convention. For example, only lower case letters and the underscore as delimiter, such as V[previous_account]. Or with upper case and lower case letters, without underscore: V[PreviousAccount]. It often makes sense to let all variable names start with a common identifier denoting the transaction or transaction group, e.g. V[VA01_PreviousAccount] or [VA_PreviousAccount]. Value System variables
For a detailed list of all system variables please see the section system variables. Scope If you need to pass values from one session to another you can use the "toSharedText" and "fromSharedText" options of the CopyText command. If you start an InputScript that runs in a new session, using a "/O..." function code, the parameters are automatically passed to the new mode. To return parameters from the called session to the calling session, use the "ReturnValues" statement. Setting valuesTo set a value, use the format Set V[varname] "value" Example: Set V[MM_init] "X" Use the "&V[...]" notation if the new string value is to be taken from another variable. Example: Set V[MM_nr2] "&V[MM_nr1]" Please avoid a notation without quotation marks, e.g. Set V[MM_nr2] &V[MM_nr1] // not recommended !! since this will not work as desired if the variable value contains blank characters: The statement is executed after replacing the variables and this results in using the first word of the given string without the rest, which GuiXT interprets as additional options of the Set command. The only case where quotation marks are not needed is when you work with numbers (represented as string values). Example: Set V[i] 1 Querying
a variable value
Please observe: The comparison does not distinguish between upper case and lower case, and it does not distinguish between "0", "00", and an empty string. The reason for this behaviour is that SAP entry fields are often automatically converted to upper case, and a value entered as "0" is often shown as Space. If GuiXT distinguished between upper and lower case values here, it would be difficult to determine if an account number changed. You can use the option "-strict" after a comparison if you really want to compare the values exactly as they are. Example:
The if-expression may contain the operators "and", "not", "or", "(" and ")". Example: It is also possible to use the operators "<" and ">". Please observe that in this case the variable is always considered to be a number. There is no string comparison with "<" or ">". Example: if
V[k<100] Short notation
to ensure that a variable is not empty if V[varname]
Comparing
two variables if V[account1=&V[account2]] Please observe: two ending brackets and no inverted commas Generic
reset of numerous variables if not V[_transactionid=&V[MM_transactionid]] Set
V[MM_*] "" endif Concatenating
variables Set V[MM01_text] "&V[M01_text1]&V[MM01_text2]" Constant strings can be interspersed. Example: Set V[id] "&V[a]-&V[b]-&V[c]" Partial
strings Set V[x] "00113100" No V[y] has the value "31". Similarly with comma: Set V[x] "00113100" There is a difference in meaning between the two notations that is only significant in Unicode systems. Internally GuiXT uses the UTF-8 character code and some characters (e.g. Umlauts such as ä,ö) are stored in two bytes, not in one byte as in ANSI. With the hyphen notation e.g. (4-6) you will obtain bytes 4 to 6, whereas you obtain the characters 4 to 6 with the comma notation (4,6). Example: Set V[x] "München" Now V[y] has the value "nch". Whereas Set V[x] "München" sets y to the value "che". Since variables can contain structures with binary or decimal packed components, GuiXT cannot generally use the character semantics in Unicode systems. Length of
a string in bytes or characters Set V[leng] "München" -stringLength Set V[count] "München" -charCount V[leng] is 7 in a non-Unicode system and 8 in a Unicode system, since 'ü' needs two bytes in UTF-8. The value of V[count] on the other hand is 7 for all systems. Tip: Use -stringLength in conjunction with the hyphen substring notation (i-k) and -charCount with the comma notation (i,k); see also the example in the next section. Partial
strings with variable positions The string V[in] is searched for a dot, one character after the other, and simultaneously we build up the output string V[out]. // for testing
purposes Extracting
components of SAP structures Call "BAPI_CUSTOMER_GETDETAIL2"
in.CUSTOMERNO="0000002000" out.CUSTOMERADDRESS="addr" Explanation: The function module "BAPI_CUSTOMER_GETDETAIL2" defines an export parameter "CUSTOMERADDRESS" that we receive in our variable V[addr]. As defined in the SAP function library the parameter possesses the structure "BAPICUSTOMER_04" where the city is stored in component "CITY". Often function modules return table parameters where each row is a SAP dictionary structure that we can handle with this symbolic notation. If you use VersionNumber the text will be stored in the GuiXT cache (local files) and taken from there instead of relative complex reading of the text from the SAP Repository unless VersionNumber changed. Setting
components in SAP structures Set V[line](BAPICUSTOMER_IDRANGE-SIGN)
"I" The format
is as follows: GuiXT uses double precision floating point numbers for all calculations. Example: Set V[x] 2 / 3 decimals=5 Result: 0,66667 Date calculationsWhen GuiXT converts strings into numbers, it recognizes the normal standard date formats such as "01.06.2014" and calculates the days since a fixed date. In this way you can subtract dates from each other, or add and subtract a number of days from a given date. In this latter case the result is returned as date as well, using the same format as the input date. Example 1: Set V[x] "01.06.2014" - 1 Result: "31.05.2014" Example 2: Set V[x] "01.06.2014" - "01.01.2014" Result: "151" Example 3: We use a couple of date calculations in order to decide whether a given date "V[date]" falls on a Sunday. For this purpose, we subtract a fixed Sunday, e.g. the 31.12.2000, from the given date and then check whether the result is a multiple of 7: Set V[x] "&V[date]"
- "31.12.2000" It is possible to use variable values within a variable name. Example:
Set V[name] "x" Now V[x] has the value "10". This feature is often used for indexed variables, as shown in the following example. We read the "Material" column of all currently displayed rows in table "All items" and set the variables VA_material_1, VA_material_2, ...: Set V[i] 1
Field texts from the SAP Data Dictionary
"&ddic[BSEG-BSCHL]" Buchungsschlüssel If you use VersionNumber the text will be stored in the GuiXT cache (local files) and taken from there instead of relative complex reading of the text from the SAP Repository unless VersionNumber changed. Environment variables
(Windows) For example, if you want to create a temporary file, you can use the TEMP variable to get the right folder:
|