|
This is a collection of tips and tricks, both for GuiXT scripts and for InputScripts, including sample codes that you can cut&paste into your own script.
We welcome your own suggestions, in the form of solutions that you have come up with, or questions relating to particular problems. Simply send an email to tips@synactive.com.
If you have an unanswered question, our Q&A section (where you may well find the answer) is worth a visit as well.
We will test each tip before we publish it here. But please understand that we cannot guarantee that it will work in all SAP releases and for each and every transaction. If you point out a problem, we will describe it here under "Restrictions" , or perhaps we can find a better solution.
Please understand that we have to exclude any warranty or liability pertaining to "Tips & Tricks".
| Task
description
Solution |
Sample code, images | Restrictions, SAP Release, SAP GUI version, GuiXT version |
|
31 Creating a new column
with larger maximum input size than visible width When you create a new table column with the Column command, the size= parameter describes both the visible column width and the maximum input size of your new column. Additional ColumnWidth or ColumnSize commands for this column will also change both the visible width and the maximum input size. In order to create a new column with small visible size (e.g. 10) and large input size (e.g.120), use the following trick. It is based on the fact that the input size of a cell is at least the size of the value that is contained in the cell. So all you need to do is to define the column with size=10 but add enough padding space characters to each cell value. This operation is somewhat tricky, since most GuiXT commands will ignore space characters at the end of a string. There is one exception that you can use: A Set command with substring notation, e.g. Set V[x](1-20) "abc" changes the given positions 1 to 20 of V[x], inserting space characters at the end. This means that the command Set V[x](1-120) "&V[x]" enlarges the variable V[x] to a size of 120, adding space characters at the end if necessary. Now all we need to do is to apply this command to each visible cell of our new column. Let us assume that the table name is "Table" and the new column title is "Barcode". The complete script is then as follows:
//
Create the new column
//
Determine visible part of the table |
Last update:
|
InputAssistant
|
|
30 Debugging
a GuiXT script like an InputScript For InputScripts you can use a number of debugging functions (line by line processing, breakpoints, variable display); simply click the "Debug" button before you execute the InputScript. GuiXT scripts can also become quite complex, so that you may wish to use a debugger which is currently not offered by GuiXT. With the following trick you can use the InputScript debugger for GuiXT scripts as well: Create a script "debug.txt" that contains the following lines
//
debug.txt When you now want to debug a GuiXT script, add a first line include "debug.txt" in the script. It will show a toolbar button "MyScriptDebug", but will not change the script logic in any way. To debug the script, open the GuiXT debug window (GuiXT Debug button) and then click "MyScriptDebug" . Why do we use the "/O" function (session overview - be careful: it is slash oh, not slash zero !) and an additional screen command in "debug.txt" instead of simply pressing "Enter" to start the script? The reason we avoid pressing "Enter" is that a number of transactions already perform an action on "Enter", (an action that we don't want here) which, for example, would lead to a different screen or to an error message instead of re-processing our GuiXT script in debug mode. |
Last update:
|
InputAssistant
|
| 29
Displaying a pdf document as help file With the "Viewer" component you can easily display your own help in html format, either using the "help views" catalog in GuiXT profile, or with the viewhelp option of the image command, e.g. Image (toolbar) "help.gif" viewhelp="myhelp.html" Is it also possible to display pdf documents with this technique? Yes, you can embed the pdf into an "myhelp.html" file in the following way:
<html>
<embed src="myhelp.pdf"
width="100%" height="100%"></embed> When you create a .pdf help document in Adobe Acrobat, it makes sense to select the "Open in Full Screen Mode" option which opens the document without the menu bar or toolbar. |
Last update:
|
Viewer
|
| 28
Displaying company-specific help in SAP GUI for HTML In SAP GUI for Windows, the "GuiXT Viewer" component offers a convenient way to display company-specific documentation for individual transactions (see :"Help Views" directory in GuiXT profile) without the need to write a script for each screen. In SAP GUI for HTML the same approach is not possible, since the "Viewer" component is not available in this environment. You can get around this with the following method of presenting a small "help page". In the GuiXT script for the screen where you want to offer your help (e.g. transaction FB01) add a line Pushbutton (toolbar) "@0S\QOur company-specific help@Help" "/O" "Ctrl+F1" process="help_fb01.txt" This displays a "Help" button in the toolbar:
The function is automatically added to the screen context menu and can be invoked with Ctrl+F1:
When the user clicks on the button, you display a popup window with your help text:
The tip&trick is that you use the SAP standard "mode overview" popup which is shown on "/O". No html formatting is available for this kind of help display, so you have to put the text directly into the InputScript using "Text" commands. As the example shows, you can use SAP icons to improve the structure of the text. The popup window will contain scrollbars if you have longer texts. Please click on the link in the next column to get the InputScript for the help popup display. |
Last update:
|
InputAssistant
|
| 27
Checking the format of a "time" value
Your InputField is defined as follows: InputField (10,10) "Time" (10,18) size=8 name="mytime" When the user clicks a "Save" or "Check" button, you first want to check the correct format hh:mm:ss of the entered time. You also want to allow the user to enter the hour hh only, or the hour plus minutes in the form hh:mm. This can be done in your InputScript using substring notation &V[xxx](x-y) together with some computations and comparisons. Please click on the link in the next column to get the InputScript with the time format checking. |
Last update:
|
InputAssistant
|
| 26
Display a numeric keypad
For a certain user group, you want to display a numeric keypad on the SAP screen so that the material number can be entered directly on a touchmonitor. The script uses the same image for all buttons, and displays the digits (and the entered material number) with the "textstring" feature". Example:
Image
(0,0) "numbutton.gif"
Pease click on the link in the next column to get the scripts and images, if needed. The image below shows that, because of the size and clarity of the digits, the "textstring" feature can also help visually impaired people to use SAP transactions more easily.
|
Last update:
"numbutton.gif"
"whitebox.gif"
|
GuiXT version:
|
| 25
Using image maps
Image maps, which are popular in websites, enable users to perform an action by clicking on a portion of the graphic ("hotspot"). With GuiXT Viewer, you can embed an image map into an SAP screen and define separate actions for each link. For example you can design graphical menus whereby a click on an image link will start a certain transaction. Or you can provide graphical value selection (geographical regions, organizational charts).
|
Last update: |
Viewer
|
| 24
Choosing an icon
Pushbuttons and texts can start with an SAP icon. Each icon has a certain 2-character id, e.g. "8G". The notation "@8G@Push" displays the icon "8G" followed by the text "Push". Or, with an additional quickinfo "This button...", you can use the notation "@8G\QThis button...@Push". For an overview of all icons with their ids, you can use GuiXT Designer, pushbutton attributes. The Designer automatically generates the right notation.
You can also use a small GuiXT script that will show exactly what icons are defined in your system (some have been added by SAP in various releases):
Please click on the link in the next column to get the script, if needed.
|
Last update:
|
Designer InputAssistant
|
| 23
Changing the screen title during InputScript processing
If the processing time of an InputScript exceeds around 3-5 seconds, users tend to get impatient. It is a good idea to indicate clearly that the system is currently carrying out a reasonable task and that therefore no further user action is required at the moment. Use a "Title" statement in the InputScript to display a suitable message while the InputScript is running. As an example, let us assume that you have created a new button "Display sales history" that starts an InputScript; this will then need some time to read previous orders. When the user presses the button, you immediately give the feedback "Reading customer data... Please wait":
InputScript statement: Title "Reading customer data.... Please wait" If appropriate, you can change the title several times during InputScript processing to indicate several different steps. For very long running scripts (e.g. several minutes), combine the feedback with a "StatusMessage" command so that a user can see the previous messages as well. |
Last update:
|
GuiXT version: InputAssistant
|
| 22
Opening a mail message window
You want to display an icon in an SAP screen that allows the user to open a mail message window with a predefined mail address. Example:
When the user clicks on the icon, the desktop email application opens, and the email address and subject are already filled in:
Sample script:
text (8,21) "Logon problems?"
It is also possible to insert a default email body text. Example: Image ... start="mailto:service@abcd.com?subject=Logon in system&V[_database]&body=Hello"
|
Last update: March 30, 2004
|
|
| 21
Displaying dynamic internet information
When you display www pages within SAP screens (Viewer component), you can also insert variables into the URL: either SAP field values or your own entry fields or InputScript variables. For example, you can display the current shipment status, based on an external tracking number:
The following sample script demonstrates the technique:
Box (2,0) (17,84) "Display Shipping State" |
Last update: March 30, 2004 |
Viewer InputAssistant
|
| 20
Reading user parameters
In the SAP system you can set user specific values for various field types ("Parameters" in transaction SU01) :
In some cases it makes sense to use these values in a GuiXT script or InputScript. With the include-file "read_user_parameters.txt" (please click on the link in the next column) you can read all user parameters into internal variables "V[user_parameter_XXX]" where XXX is the parameter id. For example, "WRK" is the parameter id for "Plant", and the corresponding internal variable is V[user_parameter_WRK]. Sample coding: // Get user parameters (first time only)
if
not V[user_parameters_read=X] endif
if V[user_parameter_WRK=7005] Set F[Plant] "7005" NoInput F[Plant] Box (10,1) (16,50) "Cost centers plant 7005" ... endif |
Last update: January 24, 2004 |
GuiXT version: InputAssistant
|
| 19
Handling GuiXT activation in ABAP
In the SAP GUI options,
the menu item "Activate GuiXT" allows the user to activate
and to deactivate GuiXT. The option can be checked and
manipulated on the application server as well, using a desktop
interface in ABAP. Please click on the link in the next column for further details. |
Last update: October 14, 2003 |
SAP GUI 4.6d or SAP GUI 6.20
|
| 18
Finding a searchhelp name
When you define your own InputField, you can refer to SAP standard matchcode with the techname="..." parameter. How do you get the
technical field name, e.g. "MARA-IDNRA"? In some cases the search help for the InputField does not work with this field name. The reason is that, in SAPs data dictionary, some fields are not linked to a search help, and GuiXT's functionality is based on data dictionary information. You then have to define the name of the search help directly with the searchhelp="..." parameter of the InputField statement, instead of using techname="...". But how do you find the right search help? Transaction SE11 (data dictionary) lists them all, but it might be hard to find the right one. Here we describe an alternative way to get the search help, using ABAP debugging information. Please click on the link in the next column for further details. |
Last update: September 29, 2003 |
InputAssistant
|
| 17
Structured parameters in function calls
When you call function modules (e.g. BAPIs) in an InputScript, you often need to handle structured parameters, both in imported and exported parameters. GuiXT does not support data dictionary based symbolic fields; instead you have to use substring notation, e.g. Set V[department] "&V[address](530-569)" // get department from address or Set V[address](530-569) "&V[department]" // set department in address The maximum GuiXT variable length is 4000, which is enough for all existing BAPIs (GuiXT 2003 Q3 6 and upwards; in previous versions the size was restricted to 255 characters). In order to obtain the right substring notation for a given field, there are 2 possibilities:
To get necessary scripts, please click on the links on the right hand side. Note: As of GuiXT version 2004 Q1 2, data dictionary based symbolic fields are possible, see Tip 20 for an example. |
Last update: September 15, 2003 |
GuiXT version: InputAssistant
|
| 16
Displaying a drop down menu for your own input field For your own input
fields, the "drop down menu" style is not available.
Using "local value help" you can define a value list together with a text for each value, to be displayed by InputAssistant on a right mouse click in the field; you have to associate a domain name with the field text in domTextScreen, see Documentation for the details. Here we show a further possibility, using the html Viewer. It offers numerous possibilities for designing drop down menus, both for your own input fields and for existing standard fields, or for field combinations.
|
Last update: April 22, 2003 |
Viewer |
15
Processing multiple transactions in one script You want to create a
simple user interface for a certain task that, in SAP standard, requires
2 or more different transactions. For example, you implement a
"Create customer" form that fits on one screen, covering both the data
for transaction XD01 (create new customer) and for
transaction FD32 (credit control data). Problems:
To solve the first issue, use the "Retry on error" command. To solve the second one, there are 3 possibilities:
To solve the 3rd issue, you can check all data in the InputScript before you start the first transaction. But in many cases a complete check will not be possible. An alternative approach is then: display the error message, let the user correct the values, and then perform the 2nd transaction alone, skipping the first one in the InputScript. We will cover this issue separately in our "Special topics". |
Last update: April 3, 2003 |
InputAssistant |
| 14
Determine the week for a given date For a given date you want to
determine the week 1...53 and the year corresponding to this week. The
date is specified in one of the external date formats (like dd.mm.yyyy
or mm/dd/yyyy).
For example, 01.01.2003 is in week 1 of the year 2003. This sounds self-evident, but (surprisingly): 01.01.2005 is in week 53
of the year 2004 The rule is: a week is considered to be in the year that contains 4 days or more of the week. A week always starts with Monday. Solution You
can either use a function call or direct date calculations. |
Last update:
March 25, 2003 |
GuiXT version: InputAssistant |
| 13
Checking a special material number layout You created an
InputField for the material number:
InputField (12,1) "Material" (12,20) size=9 name="matnr" -numerical -required In your InputScript, you want to check that the entered value is of format dddddddd (8 digits) or dd.dddddd (with a point after 2 digits). So, for example, the values "123456789", "123456", 1.2345678", "12 345678" would all be invalid. Solution You
use substring notation and a comparison. It is a little bit tricky
(that's why it is included in Tips&Tricks). |
Last update: December 13, 2002 |
InputAssistant |
| 12
Marking a specific table line You
want to mark a line in a table control whose position id is known. A
problem is that the position id is aligned right in the
"position" column. We assume that the line you are looking for is on the currently displayed part of the table. Otherwise, additional scrolling is necessary; see Tip 9. Solution You
use a calculation (add 0) to delete leading space in the
position id. |
Last update: December 12, 2002 |
The
selected line has to be visible on the screen.
InputAssistant |
| 11
Dynamic image position and size
Depending on the data displayed on screen, you want to use images in
order to highlight some aspects. For example, if the "Old material
number" contains a hyphen "-", you want to emphasize the two
parts.
Solution
First calculate the relative positions of the images in
V[...]-variables,
using the screen data and your specific logic. In the
image commands
you then work with these values. |
Last update: October 24, 2002
|
GuiXT version: 2002 Q4 3 and upwards InputAssistant |
| 10
Mark a column in a table On
a screen with one or more tables you want to mark a column.
Solution The command mark is not available for table columns. Use the command ColumnHeader where you can specify an icon and a quickinfo.
sample coding:
//
we want to mark column "Description" |
Last update: October 17, 2002
|
No restrictions |
| 9
Scrolling through a table On
a screen with one or more tables you want to read all lines of one of
the tables, not just its visible part.
Solution Use the commands GetTableAttribute and Enter ScrollToLine=... Table=... in order to scroll through the whole table.
Example 1 The InputScript "ViewTable" downloads a table from screen to a file, scrolling through all lines. It also demonstrates how InputScripts can be written in a quite general manner. You can use it in a dynpro of your choice, specifying the table name and up to 4 column names as "using" parameters. Add more column names if needed, or your own logic for selecting a subset of the lines. For example, if you wish to download only the lines marked by the user, substitute the AppendFile statement by the following coding:
...
// Line marked? ...
Example 2 The InputScript selects some material views in MM03 (SAP Rel. 4.6C).
|
Last update: October 14, 2002 Last update: August 3, 2003
|
GuiXT version:
Example 1: 2002 Q4 1 and upwards Example 2: 2003 Q3 3 and upwards
InputAssistant |
| 8
Dynamic values in input sets You
want to offer input sets in the toolbar that enter values
automatically. Some of the values can only be determined dynamically.
Solution Use the image command. You specify (toolbar) instead of screen coordinates; the image is then displayed on the right hand side of the toolbar, like the input set symbols. The "Input=..." string can be defined dynamically using GuiXT variables. Finally, if you want to use the same symbols like GuiXT uses for input sets, you can work with "a.res",... "Z.res" instead of painting your own image files (.bmp, .gif, .jpg).
// Sample coding
if V[choice=1] Set V[plant] "1000" else Set V[mat] "M-02" Set V[plant] "1600" endif
Image (toolbar)
"M.res" Input="Material:&V[mat];Plant:&V[plant]" |
Last update: July 3, 2002
|
No
restrictions
InputAssistant |
| 7
Improve performance and decrease
net traffic The
guixt.ini file contains a command "replication Yes" and its
application makes a copy of each script in the directory C:\Program files\sappc\sapgui\r3db\guixt cache\sapwr\P01 which is fine for one session. But when the user opens a new SAP window, GuiXT again downloads scripts it has already read in the first window, increasing the net traffic. Can this be avoided, i.e. can performance be improved?
Solution Yes,
fortunately, it can (in GuiXT 2001 Q3 06 and upwards). Here's how: In
your logon script (e.g. Flogon.txt), you specify a version number with
the VersionNumber command, e.g. |
Last update: November 15, 2001
|
GuiXT version: 2001 Q3 6 and upwards |
| 6
Date comparison: before and after You
want to compare the current date with a certain fixed date
Solution Let
us assume that
you want to distinguish between the time before
November 7, 2001, and after. GuiXT only knows how to compare a
variable with a value: The value can also be the content of a 2nd variable: if V[variable=&[variable2]] It is necessary to use the date format "year month day", since GuiXT converts each string into a number before comparing it with "<" or ">". So you can use the command if
V[variable>&[today_ymd]] // Sample
coding If the date field has a different format, e.g. "d.m.y" like 22.04.2002, you can use string functions in order to obtain the right format: // F[Date] contains a date in format d.m.y
set V[NewDate] "&F[Date](7-10)&F[Date](4-5)&F[Date](1-2)"
Note: As of GuiXT version 2003 Q1 9, direct date comparisons and calculations are possible, see Tip 14 for an example. |
Last update: August 2, 2002
|
No
restrictions
InputAssistant |
| 5
Foreground
display
of a transaction started in alternative mode You
have created a new pushbutton that starts a transaction in alternative
mode, using the "/O..." notation. This opens a new window,
but the window is shown in the background, i.e. behind the window with the pushbutton.
It would be better to have the new window displayed in the foreground so that the user can
work with
it
immediately.
Solution There isn't a way to achieve this in GuiXT, since it is an issue of SAP GUI and the Windows standard behaviour in WIn98 and Win2000. Even when the user himself starts a new session by entering a /O command, the new window is hidden behind the previous SAP GUI window. There is a parameter in the windows registry that controls this behaviour. If you set it to 0 the new window is shown on top of the old one: [HKEY_CURRENT_USER\Control Panel\Desktop] "ForegroundLockTimeout"=dword:00000000 The change will be in effect with the next Windows start. |
Last update: September 4, 2001
|
Problem exists only in Windows 98 and Windows 2000 |
|
4 Displaying additional information You need to display in an SAP screen additional information that is not contained in the standard SAP transaction. It would not be a problem for you to read this information directly from the database, using a Call Statement in your GuiXT Script and a 1-line select statement in ABAP. But you don't know the name of the table in which the information is stored. Solution You probably know a standard transaction in SAP where you can display the field. Put the cursor on the field; press F1 and then select "Technical information". In most cases SAP now shows the right database table name and the field name you are looking for.. Use transaction SE17 (General table display) to verify that you have found the right table. In some cases SAP will give you only an intermediate program table, but not the database table name that you need for your select Statement. Now you have a little bit more work. Go to transaction ST05 and activate the SQL trace with the button "Trace on for user". Perform the SAP transaction again until you see your field. Display the SQL trace (transaction ST05) and try to find the right table. Since all key data are shown in the trace, you have a good chance to find the table name. Verify that it is the right one using SE17. In addition, we suggest that you make sure that the Select statement in your function call does not lead to a full table scan, which can be pretty fast in your test system and pretty slow in production. Use the tools of the ABAP workbench: SE11 to show the secondary indices of the table, ST05 to explain an SQL request. |
Last update: August 18, 2001
|
InputAssistant needed for Call statement |
|
3 Entering screen element names in GuiXT scripts You want to perform this operation quickly and easily.
Solution Click on the element in the "Screen elements" window. This copies the name of the screen element to the Windows Clipboard, and now you can paste it into your script. |
Last update: August 17, 2001
|
No restrictions |
| 2
Display product images on request You
want to display product images for all products that a user marked
during order entry. The user marks several table lines and then presses a
pushbutton "Product image".
Solution You combine the technique described in Tip 1with the View command |
Last update: August 15, 2001 |
The
selected line has to be visible on the screen.
GuiXT version: 2001 Q3 2 and upwards InputAssistant, Viewer |
| 1
Reading a marked table line You
want to add a new function in a screen containing a table
control. The user marks a table line and then presses a
pushbutton that invokes an InputScript.
The problem is how you can get the cell values of the marked line in your InputScript. Solution You loop through all table lines on the screen. When you find the marked line, you store the cell values into your own variables. Special care has to be taken if no line or more than one line has been marked. |
Last update: August 15, 2001 |
The
selected line has to be visible on the screen.
GuiXT version: 2001 Q3 2 and upwards InputAssistant |