Purpose |
The function module
/guixt/select
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:
Please note: There is a newer function /guixt/dbselect which allows you to specify an arbitrary number of returned columns. For large result sets this function is faster than /guixt/select. |
Import of the function module |
If you prefer to create the function module directly in transaction SE37 without using the SAP transport system you can use the file source code /guixt/select. |
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 with ). 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
autorization 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. |
Parameters |
Following parameters are
available:
|
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. |
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= |
Optionally a 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". If you use the parameters out.V1= out.V2= ... or out.V1Table= out.V2Table= ... a field list is required; the given fields are read and put into the specified variables. In case of "work area mode", i.e. out.Result= or table.Resulttable= the whole table row record is returned, but only the fields given in the field list are actually filled. |
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.Distinct= | With "X" the DISTINCT clause of the Select command is used |
out.Found= | Returns "X" if at least one record returned, "" otherwise. |
out.Reccount= | Returned record count |
out.Result= |
The first row returned is put
into the given variable, or "" in case of empty result table. If
in.Fields
is specified, only the given fields are filled. Example: // Account number (test) Call /guixt/select in.table="KNA1" in.fields="NAME1,ORT01" in.condition="KUNNR = '&V[mykunnr]'" out.result="kwa"// Test output |
out.V1= out.V2= ... out.V10= |
In conjunction with
in.Fields.
The fields given in the field list are put into the corresponding
variables. Example: // Account number (test) Call /guixt/select in.table="KNA1" in.fields="NAME1,ORT01" in.condition="KUNNR = '&V[mykunnr]'" out.V1="name" out.v2="city"// Test output
|
table.Resulttable= |
Returns all table rows that
fulfil the search condition. If
in.Fields
is specified, only the given fields will be filled. Example: We read all customers with city "HEIDELBERG": Call /guixt/select in.table="KNA1" in.fields="KUNNR,NAME1" in.condition="ORT01 = 'HEIDELBERG'" table.resulttable="r"// Test output label next CopyText fromText="r" toString="kwa" line="&V[i]"if Q[ok] Message "&V[kwa](KNA1-KUNNR) &V[kwa](KNA1-NAME1)" Set V[i] &V[i] + 1 goto next endif
|
table.V1table= table.V2table= ... table.V10table= |
In conjunction with
in.Fields.
The fields given in the field list are put into the corresponding long
text variables, one line for each returned row. Example: We read all customers with city "HEIDELBERG": Call /guixt/select in.table="KNA1" in.fields="KUNNR,NAME1" in.condition="ORT01 = 'HEIDELBERG'" table.v1table="r1" table.v2table="r2"// Test output label next CopyText fromText="r1" toString="account" line="&V[i]"if Q[ok] CopyText fromText="r2" toString="name" line="&V[i]" Message "&V[account] &V[name]" Set V[i] &V[i] + 1 goto next endif
|
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: Set text[ctab] ""Set V[i] 1 label nextCopyText fromText="kns" toString="kn" line="&V[i]" if Q[ok] if V[i=1] Set V[condline] "KUNNR = '&V[kn]'" else Set V[condline] "OR KUNNR = '&V[kn]'" endif CopyText fromString="condline" toText="ctab" -appendLine Set V[i] &V[i] + 1 goto next endif Call /guixt/select in.table="KNA1" in.fields="KUNNR,NAME1,ORT01" table.conditiontable="ctab" ... |
Components | GuiXT + InputAssistant |