InputAssistant Tutorial General topics 1 2 3  Parameters and input fields  4 5 6 continue

You can enhance our  InputScript from Tutorial 1 in various ways, using additional user interface elements. 

As a first example, let’s offer two pushbuttons instead of one, allowing the user to display the material list for two different plants. Since we want to work with the same InputScript, we define a parameter PLANT. The first pushbutton then starts the InputScript for Plant “1000″ (London), and the second one for plant “3000″ (Stockholm). In the InputScript, the notation “&U[PLANT]” refers to the parameter value.

Sap Guixt image.ia.7.01 Parameters and input fields

// GuiXT Script
Box (0,1) (5,26) “Materials”
Image (0.7,1) (4.4,15) “materials.jpg” 
Pushbutton (1,16) “London” “/NSA38″ process=”matlist1.txt” size=(2,10)
using PLANT = “1000″

Pushbutton (3,16) “Stockholm” “/NSA38″ process=”matlist1.txt” size=(2,10)
using PLANT  = “3000″

// InputScript “matlist1.txt”
Parameter PLANT 

// ABAP Editor: Initial Screen 
Screen SAPLWBABAP.0100
Set F[Program] “RMMVRZ00″
Enter “/8″

// Materials List 
Screen RMMVRZ00.1000
Set F[Material] “M-*”
Set F[Plant] “&U[PLANT]“
Enter “/8″

Comparing the script with the version in Tutorial 1 you see that it is further simplified. The first function code “/NSA38″ is already  defined in the pushbutton definition, so that we get rid of the first “Screen” command in the script. This saves one Screen-Enter cycle when the script is executed.

Instead of defining several pushbuttons, you can also work with radiobuttons and a single pushbutton. In the following example, we start transaction VA01 (order entry) for different order types.

Sap Guixt image.ia.7.02 Parameters and input fields

// GuiXT Script
Box (0,0) (8,36) “Customer order”
Image (0.7,0.3) (7.2,14.6) “controlling.jpg” “-plain” 

// Set default order type
if not V[VA01_Ordertype]
  Set V[VA01_Ordertype] “CS”
endif

// Select order type
RadioButton (1,16) “Cash sale” Name=”VA01_Ordertype” value=”CS”
RadioButton (2,16) “Rush order” Name=”VA01_Ordertype” value=”RO”
RadioButton (3,16) “Internet order” Name=”VA01_Ordertype” value=”IO”
RadioButton (4,16) “Returns” Name=”VA01_Ordertype” value=”RE”

Pushbutton (6,16) “Create order” “/NVA01″ Process=”startva01.txt” “size=2″

// InputScript “startva01.txt”
Screen SAPMV45A.0101

// Set parameter U[ORDERTYPE] into field F[Order type]
Set F[Order type] “&V[
VA01_Ordertype]“ 

Set F[Sales organization] “1000″
Set F[Distribution channel] “10″
Set F[Sales office] “1000″ 

Enter

Here we did not use parameter passing; instead we worked with the global variable V[VA01_Ordertype]. If  you prefer to start transaction VA01 in alternative mode using the command “/OVA01″ instead of “/NVA01″, this is no longer possible, since each SAP session has its own set of InputScript variables. You then have to pass the order type as parameter:

// GuiXT Script
Box (0,0) (8,36) “Customer order”
Image (0.7,0.3) (7.2,14.6) “controlling.jpg” “-plain” 

// Set default order type
if not V[VA01_Ordertype]
  Set V[VA01_Ordertype] “CS”
endif

// Select order type
RadioButton (1,16) “Cash sale” Name=”VA01_Ordertype” value=”CS”
RadioButton (2,16) “Rush order” Name=”VA01_Ordertype” value=”RO”
RadioButton (3,16) “Internet order” Name=”VA01_Ordertype” value=”IO”
RadioButton (4,16) “Returns” Name=”VA01_Ordertype” value=”RE”

Pushbutton (6,16) “Create order” “/OVA01″ Process=”startva01.txt” “size=2″
  
using ORDERTYPE = [VA01_ORDERTYPE]

// InputScript “startva01.txt”
Parameter ORDERTYPE

Screen SAPMV45A.0101

// Set parameter U[ORDERTYPE] into field F[Order type]
Set F[Order type]
“&U[ORDERTYPE]“ 

Set F[Sales organization] “1000″
Set F[Distribution channel] “10″
Set F[Sales office] “1000″ 

Enter

Input fields can be defined in the same way as radiobuttons. Each input field (command  “Inputfield”) refers to exactly one GuiXT variable:  the value of the variable is shown in the input field, and the value that a user entered in the field updates the variable value. 

In the following example, the user can display the availability of a material in three plants.  We use an SAP BAPI for calculating the quantity.

Sap Guixt image.ia.7.04 Parameters and input fields

The material number can be entered directly or via SAP matchcode.

Sap Guixt image.ia.7.03 Parameters and input fields

The three quantities are displayed.

Sap Guixt image.ia.7.05 Parameters and input fields

For wrong material numbers, we display an error message.

// GuiXT Script
Box (0,0) (8,36) “Availability”

InputField (1,1) “Material” (1,16) name=”AV_Material” size=18 techname=”MARA-MATNR” -uppercase
Text (2,1) “&V[AV_Materialtext](1-34)” -proportional -intensified 

Text (3,2) “London” 
Text (3,12) “&V[AV_Materialquantity1]” -border size=8
Text (3,22) “&V[AV_Materialunit]“ 

Text (4,2) “Stockholm” 
Text (4,12) “&V[AV_Materialquantity2]” -border size=8
Text (4,22) “&V[AV_Materialunit]“ 

Text (5,2) “Vienna” 
Text (5,12) “&V[AV_Materialquantity3]” -border size=8
Text (5,22) “&V[AV_Materialunit]“ 

Pushbutton (7,2) “Show availability” Process=”availability.txt” size=(1,32)
using MATNR = [AV_Material]

// InputScript “availability.txt”
// reset variables
Set V[AV_Materialtext]
Set V[AV_Materialunit]
Set V[AV_Materialquantity*]

// Read short text and unit
Call “BAPI_MATERIAL_GET_DETAIL” in.MATERIAL=”&V[AV_Material]” out.MATERIAL_GENERAL_DATA=”AV_materialdata”

// Use offsets, see Tips&Tricks No. 17
Set V[AV_Materialtext] “&V[AV_materialdata](1-41)”
Set V[AV_Materialunit] “&V[AV_materialdata](156-158)”

// Material exists?
if not V[AV_Materialtext]
  return “E: The material &V[AV_Material] does not exist” -statusline
endif

// Read available quantity
Call “BAPI_MATERIAL_AVAILABILITY” in.MATERIAL=”&V[AV_Material]” in.PLANT=”1000″ in.UNIT=”&V[AV_Materialunit]” out.AV_QTY_PLT=”AV_Materialquantity1″ 
Call “BAPI_MATERIAL_AVAILABILITY” in.MATERIAL=”&V[AV_Material]” in.PLANT=”2000″ in.UNIT=”&V[AV_Materialunit]” out.AV_QTY_PLT=”AV_Materialquantity2″ 
Call “BAPI_MATERIAL_AVAILABILITY” in.MATERIAL=”&V[AV_Material]” in.PLANT=”3000″ in.UNIT=”&V[AV_Materialunit]” out.AV_QTY_PLT=”AV_Materialquantity3″ 

// 3 decimals places in quantity
Set V[AV_Materialquantity1] &V[AV_Materialquantity1] / 1000 
Set V[AV_Materialquantity2] &V[AV_Materialquantity2] / 1000 
Set V[AV_Materialquantity3] &V[AV_Materialquantity3] / 1000 

// Message + redisplay screen
Return “S: Available quantities calculated” -statusline

 

Sap Guixt weiter Parameters and input fields

Parameters and input fields