|
Purpose
Examples and explanations |
The function module
/guixt/dbselect
offers you a comfortable way to read the SAP database in a GuiXT script. You execute the function with the Call statement. Both single and multiple records can be returned by the function. Prerequisites:
|
|
Import of the function module |
|
| Authorizations |
You can either execute the
Call with the RFC user specified in the GuiXT profile or with the user
that is currently logged on (option -currentUser
in Call command). Following authorizations are needed:
Function group authorization
for /GUIXT/DB01: Here XXXX is the SAP authorization group of the table that you want to read (internally stored in table TDDAT). Note: The table display
authorization S_TABU_DIS is checked in the same way in the SAP transactions
SE16 and SM30 and in the standard function module RFC_READ_TABLE. |
| Notation |
You can call the function module using the standard Call notation:
Example using the standard Call notation
Instead, we recommend using the OpenCall notation:
Example using the Open Call notation
In the following sections, we use standard notation. You can find detailed examples in OpenCall notation in the Examples and Explanations section. |
| in.table= |
Table or table view to be
read. Example: ... in.table="T001" In addition to normal tables you may use the search help views M_..., e.g. M_MAT11 and views that join several tables. For example, the view "VBAKUK" for a customer order returns both general information from table VBAK and status information from table VBUK.
Joining tables The table authority is checked for all joined tables. |
| in.Condition= |
Search condition in the format
of the ABAP "Select" command. Example: ... in.Condition="BUKRS = '1000' ". Note that ABAP strings are enclosed with inverted commas.
As usual the content of a
script variable is addressed by &V[varname]: If you want to compare one column with the value in another column, use the notation table~column, e.g.: ... in.Condition="PARVW = 'RE' AND KUNNR <> KNVP~KUNN2" For further details see the ABAP "Select" documentation. A search condition is always required, specified either with in.Condition= or with table.Conditiontable=. The
in.Condition=
parameter is restricted to a total length of 4000 bytes. If you need to
pass many keys, e.g. 1000 customer numbers, use the
table.Conditiontable=
parameter which allows any number of lines, each with a
maximum length of 4000 bytes. |
| in.Fields= |
List of field
names, separated by commas. Only the given fields are read from the
database. Example: ... in.Fields="KUNNR,NAME1,NAME2,ORT01,STRAS,PSTLZ,LAND1". The field values are returned in external format. You may put a * before the file name in order to prevent the formatting of the value. In this case, date values are returned in format YYYYMMDD and numbers with '.' as decimal separator. Account number, material numbers etc. are returned with leading zeros e.g. 0000002000 instead of 2000. This is useful if you want to use the value in subsequent database calls. It is also possible to specify a field name twice, with and without *, in order to obtain both value formats. Example: ... in.Fields="KUNNR,*KUNNR,NAME1,NAME2,ORT01,STRAS,PSTLZ,LAND1". If no field list is specified, the number of records that fulfill the specified condition is returned in the statement parameter Reccount. Field names and Join In case of a "join" operation for several tables, use the notation TABLENAME~FIELDNAME, e.g. ... in.Fields="KNA1~KUNNR,KNA1~NAME1,T005T~LANDX". For database columns in the format P (decimal packed), I (integer), D (date) or T (time) the type needs to be specified explicitely. You may add the option "type P", "type I", "type D", "type T", e.g. ... in.fields="KNA1~KUNNR,S001~UMNETWR type P,S001~STWAE" or you use the option
"as x", where x is P1,...P30 for packed decimal, I1,...I30 for
integer, D1,...D30 for date, T1,...T30 for time. |
| in.Orderby= |
Optionally a list of field
names, separated by comma. The result table is ordered ascending by the
given fields. Example: ... in.Orderby="ORT01,NAME1".
After each field name you may
specifiy "DESCENDING" for descending ordering. Example: |
| in.GroupBy= | Optionally a list of field names, separated by comma. The result table is grouped according to the given fields; this is needed if you use aggregation functions such as SUM( ). See also Example 6 (below). |
| in.Having= | Group conditions |
| in.Distinct= | With "X" the DISTINCT clause of the Select command is used |
| in.UseGroupSeparator= | With value “X,” groups of thousands are separated by a separator in the output of numbers according to user settings. |
| in.NoDecimals= | With value “X”, no decimal places are displayed in the output of numbers. |
| in.Username= | Specifies a user whose formatting parameters (decimal separator and date format) are used for the values. If nothing is specified, the RFC user is used. In most cases, ... in.Username=“&V[user]” is useful, i.e., the currently logged-in user. |
| out.Found= | Returns "X" if at least one record returned, "" otherwise. |
| out.Reccount= | Returned record count |
| table.Values= | Name of a longtext variable which will contain all values returned. Each text line contains one value for the fields specified with in.Fields. If more than one table row is returned, the text lines are repeated for each row. |
|
table. Conditiontable= |
Search condition in ABAP
"Select" format. In contrast to
in.Condition=
you pass a
long text variable that can contain any number of lines.
Example: We assume that a long text variable "kns" contains a list of account numbers. We want to use the account numbers in order to build up the search condition, using an "OR" clause for each account number: GuiXT
|
|
Example Further examples and explanations |
We read all customers
with city "HEIDELBERG": GuiXT
|
| Components | GuiXT + InputAssistant |