For some
of your input fields it can make sense to display an additional text.
This is possible by means of GuiXT; you call up a function module that
reads the appropriate SAP table. You can use a general function module /guixt/select
for reading all tables;
see Function module /guixt/select
for a description of the function module. Alternatively, SAP-BAPIs or
self programmed function modules can be used.
Let us assume that you have an
input field "Customer" where the user enters a customer number:
No database access if
the customer number is not specified
We automatically add leading zeros
to the given customer number
Error message if no
customer with this number exists
In this case the
input cursor should be positioned into the "Customer" entry field.
We can use the command "SetCursor V[varname]" to
position the cursor into the input field for a variable V[varname].
For performance
reasons it often makes sense to use the "cache=transaction" option
in the Call command in order to minimize the RFC access, if
master data and customizing data that are not altered by
the transaction are read.
With these enhancements our
script looks as follows:
GuiXT
Set V[kunnr.description] ""
if V[kunnr]
// Add leading zeros
Set V[k10](1-10) "0000000000&V[kunnr]" -alignRight
// Read table KNA1
Call "/guixt/select" cache="transaction" in.TABLE="KNA1" in.CONDITION="KUNNR = '&V[k10]'" in.FIELDS="NAME1,ORT01" out.FOUND="found" out.V1="name" out.V2="city"
if V[found]
Set V[kunnr.description] "&V[name], &V[city]"
else
SetCursor V[kunnr]
Message "E: Customer '&V[kunnr]' does not exist" -statusline
endif
endif
InputField (10,1) "Customer" (10,20) size=10 name="kunnr" techName="KNA1-KUNNR"
Text (10,33) "&V[kunnr.description]"
If you start an InputScript
for some user actions, for example
On
"/11"
process="save.txt"
then the customer number
should be checked at the beginning of the InputScript:
InputScript "save.txt":
GuiXT
// Customer number entered?
if not V[kunnr]
SetCursor V[kunnr]
Return "E: Please enter the customer number" -statusline
endif
// Add leading zeros
Set V[k10](1-10) "0000000000&V[kunnr]" -alignRight
// Valid customer number?
Call "/guixt/select" cache="transaction" in.TABLE="KNA1" in.CONDITION="KUNNR = '&V[k10]'" out.FOUND="found"
if not V[found]
SetCursor V[kunnr]
Return "E: Customer '&V[kunnr]' does not exist" -statusline
endif
// Start "Save"
Enter ...