Purpose
Allow the user to choose a value in a table cell from a list instead of entering the value manually.
Solution
There is no "drop-down list" column attribute, but we can implement our own solution:
  • Make the column readonly
  • Add a pushbutton column right of the readonly column
  • When the user clicks the button, display a popup with the selectable values
  • When the user selects a value in the popup, fill the corresponding cell variable and close the popup

For the popup we use a standard SAP popup (help settings) and remove the existing elements.


Remark
Depending on the kind of drop-down list, the standard SAP searchhelp can be an alternative and is easily defined by techName= or  searchHelp=  in the Column command, for example
 

Column
"Plant" size=24 name="plant" techName="MARC-WERKS"


On the other hand, the popup solution described here is fast and can be adapted to the users' needs.


Example
Our starting point is the following table:

Table (1,10) (12,90) title="Water consumption per plant" name="mytable" rows="10"
 
Column "Plant" size=24 name="plant"
 
Column "Column 2" size=16 name="col2"
 
Column "Column 3" size=18 name="col3"
 
Column "Column 4" size=18 name="col4"
 
Column "Column 5" size=18 name="col5"
 
Column "Column 6" size=18 name="col6"

We make the "Plant" column readonly and add a pushbutton column:

Table (1,10) (12,90) title="Water consumption per plant" name="mytable" rows="10"
 
Column "Plant" size=24 name="plant" -readOnly
 
Column " " -pushButton size=2 name="sel" process="dropdown_plant.txt" label="@0H@"
 
Column "Column 2" size=16 name="col2"
 
Column "Column 3" size=18 name="col3"
 
Column "Column 4" size=18 name="col4"
 
Column "Column 5" size=18 name="col5"
 
Column "Column 6" size=18 name="col6"


When the user clicks the drop-down icon, a popup appears with the list of all plants:




The user can scoll through the table and selected a plant:


The selected plant is set into the "plant" cell  and the popup is closed:

InputScript "dropdown_plant.txt"

// indicate: plant selection active
Set V[plant_selection_active] "X"

// Set window position for popup
Set V[wndrow] 6
Set V[wndcol] 48

// clear table data (plant selection)
Clear V[myplants.stat.*] ""
Clear V[myplants.cell.*] ""

// read plants from SAP database
// (in other cases, a fixed list of values can also make sense)
Clear text[r]
Call "/GUIXT/DBSELECT" cache="session" _
 
in.table="T001W" _
 
in.Fields="WERKS,NAME1,ORT01" _
 
in.Condition="NAME1 NE SPACE" _
 
in.orderBy="WERKS" _
 
table.Values="r"

Set V[k] 1
Set V[n] 1

label next_value
CopyText fromText="r" toString="myplants.cell.werks.&V[n]" line="&V[k]"

if Q[ok]
  Set V[k] &V[k] + 1
 
CopyText fromText="r" toString="myplants.cell.name1.&V[n]" line="&V[k]"
 
Set V[k] &V[k] + 1
 
 
CopyText fromText="r" toString="myplants.cell.ort01.&V[n]" line="&V[k]"
 
Set V[k] &V[k] + 1

  Set V[n] &V[n] + 1
 
goto next_value

endif

// set total number of plants
Set V[plantcount] &V[n] - 1

// Set target field name
Set V[target_field] "mytable.cell.plant.&V[_tabrowabs]"

// use help settings screen
Enter "?HF1C"


GuiXT script "SAPLSR13.0102" (help settings screen)

if
V[plant_selection_active]

  // resize popup window
  // not too small, otherwise scrollbars will appear
  WindowSize (12,68)

   // use window position determined by caller
 
WindowPosition (&V[wndrow],&V[wndcol])

   // remove existing tabstrip
  del S[USR_VALS] -withBox

   // set a new title
  Title "Plant selection"

   Table (0,0) (14,64) name="myplants" rows="&V[plantcount]" fixedColumns=3
  
Column "Plant" -pushButton size=8 name="werks" process="select_plant.txt"
   Column "Name" -readOnly size=30 name="name1"
   Column "City" -readOnly size=30 name="ort01"

  On "Enter" process="leave_plant_selection.txt"
  On "/12" process="leave_plant_selection.txt"

endif

 

InputScript "select_plant.txt"

Set V[&V[target_field]] _
 
"&V[myplants.cell.werks.&V[_tabrowabs]] &V[myplants.cell.name1.&V[_tabrowabs]]"

// reset plant selection indicator
Clear V[plant_selection_active]

// leave popup
Enter "/12"

InputScript "leave_plant_selection.txt"

// reset plant selection indicator
Clear V[plant_selection_active]

// leave popup
Enter "/12"

 

Components
InputAssistant