Purpose Create dependent drop down lists: the value selected in one dropdown changes the value list of other dropdowns. In addition, the value selection in one dropdown automatically selects a value in another dropdown if only one possible choice remains. |
Solution
We use a dropdown for each entry field: SAP customizing tables define the valid combinations of these values. For example, the sales office selection depends on the sales organization. Without selecting a particular sales organization a large list of sales offices is available: When the user first selects a sales organization, for example "Sales Eastern", only the two Eastern offices are shown in the drop down list: Similarly if he chooses "Sales Western": A user does not need to start with the first dropdown. For example, he can start by selecting "Mr Ruud" in the last drop down, "Sales Group":
Remark Disadvantages: The user has to select a value in each drop down. The selected value combination might be rejected by the system. (b)
Cascading dropdowns Disadvantages: The user needs to select values in the right sequence (top to bottom). No efficient data input if subordinated values as known without the upper levels being known. (c)
Interdependent dropdowns Disadvantages: A "Reset" button is needed, otherwise the user can lock himself with a wrong selection. Relatively ambitious implementation. For this example we use approach (c).
Implementation
For database access we use the function module /guixt/dbselect.
Performance
GuiXT Script // read all vkorg, vtweg, spart, vkbur, vkgrp include "read_organizational_data.txt" // filter data according to user input Enter process="filter_organizational_data.txt" Stop endif Offset (5,100)Box (0,0) (8,62) "Organizational Data"Text (1,1) "Sales Organization" size=20 -label DropDownList (1,22) "vkorglist" width=40 refer="V[vkorg]" _ process="filter_organizational_data.txt" Text (2,1) "Distribution Channel" size=20 -label DropDownList (2,22) "vtweglist" width=40 refer="V[vtweg]" _ process="filter_organizational_data.txt" Text (3,1) "Division" size=20 -labelDropDownList (3,22) "spartlist" width=40 refer="V[spart]" _ process="filter_organizational_data.txt" Text (4,1) "Sales Office" size=20 -labelDropDownList (4,22) "vkburlist" width=40 refer="V[vkbur]" _ process="filter_organizational_data.txt" Text (5,1) "Sales Group" size=20 -labelDropDownList (5,22) "vkgrplist" width=40 refer="V[vkgrp]" _ process="filter_organizational_data.txt" Pushbutton (7,48) "@TS@Clear input" process="clear_organizational_data.txt"Include "read_organizational_data.txt" // read "vkorg" values (sales organizations) Call /GuiXT/dbselect _ in.table="TVKOT" _ in.fields="VKORG,VTEXT" _ in.condition="SPRAS = '&V[_language]'" _ table.values="r" Set V[k] 0label read_vkorg Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvkorg" line="&V[k]" if Q[ok] Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvtext" line="&V[k]" Set V[dropdownitem_vkorg_&V[myvkorg]] "&V[myvkorg]=&V[myvkorg] &V[myvtext]" goto read_vkorg endif // read "vtweg" values (distribution channels) Call /GuiXT/dbselect _ in.table="TVTWT" _ in.fields="VTWEG,VTEXT" _ in.condition="SPRAS = '&V[_language]'" _ table.values="r" Set V[k] 0label read_vtweg Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvtweg" line="&V[k]" if Q[ok] Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvtext" line="&V[k]" Set V[dropdownitem_vtweg_&V[myvtweg]] "&V[myvtweg]=&V[myvtweg] &V[myvtext]" goto read_vtweg endif // read "spart" values (divisions) Call /GuiXT/dbselect _ in.table="TSPAT" _ in.fields="SPART,VTEXT" _ in.condition="SPRAS = '&V[_language]'" _ table.values="r" Set V[k] 0label read_spart Set V[k] &V[k] + 1 CopyText fromText="r" toString="myspart" line="&V[k]" if Q[ok] Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvtext" line="&V[k]" Set V[dropdownitem_spart_&V[myspart]] "&V[myspart]=&V[myspart] &V[myvtext]" goto read_spart endif // read "vkbur" values (sales offices) Call /GuiXT/dbselect _ in.table="TVKBT" _ in.fields="VKBUR,BEZEI" _ in.condition="SPRAS = '&V[_language]'" _ table.values="r" Set V[k] 0label read_vkbur Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvkbur" line="&V[k]" if Q[ok] Set V[k] &V[k] + 1 CopyText fromText="r" toString="mybezei" line="&V[k]" Set V[dropdownitem_vkbur_&V[myvkbur]] "&V[myvkbur]=&V[myvkbur] &V[mybezei]" goto read_vkbur endif // read "vkgrp" values (sales groups) Clear text[r] Call /GuiXT/dbselect _ in.table="TVGRT" _ in.fields="VKGRP,BEZEI" _ in.condition="SPRAS = '&V[_language]'" _ table.values="r" Set V[k] 0label read_vkgrp Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvkgrp" line="&V[k]" if Q[ok] Set V[k] &V[k] + 1 CopyText fromText="r" toString="mybezei" line="&V[k]" Set V[dropdownitem_vkgrp_&V[myvkgrp]] "&V[myvkgrp]=&V[myvkgrp] &V[mybezei]" goto read_vkgrp endif // indicate: organizational data read InputScript "filter_organizational_data.txt" // filter all dropdown lists according to user input // if a unique value is set automatically
we need to repeat the selection // build up condition for vkorg if V[vtweg] Set V[condition] "TVKBZ~VTWEG = '&V[vtweg]' AND &V[condition]" endif if V[spart] Set V[condition] "TVKBZ~SPART = '&V[spart]' AND &V[condition] endif if V[vkbur]Set V[condition] "TVKBZ~VKBUR = '&V[vkbur]' AND &V[condition]" endif if V[vkgrp]Set V[condition] "TVBVK~VKGRP = '&V[vkgrp]' AND &V[condition]" endif // determine the filtered "vkorg" values Clear text[r] Call /GuiXT/dbselect _ in.table="TVKBZ join TVBVK on TVKBZ~VKBUR = TVBVK~VKBUR" _ in.fields="TVKBZ~VKORG" _ in.distinct="X" _ in.condition="&V[condition]" _ table.values="r" Set V[k] 0label filter_vkorg Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvkorg" line="&V[k]" if Q[ok] if V[dropdownitem_vkorg_&V[myvkorg]] CopyText fromString="dropdownitem_vkorg_&V[myvkorg]" _ toText="vkorglist" -appendLine Set V[save_vkorg] "&V[myvkorg]" endif goto filter_vkorg endif // build up condition for vtweg if V[vkorg] Set V[condition] "TVKBZ~VKORG = '&V[vkorg]' AND &V[condition]" endif if V[spart]Set V[condition] "TVKBZ~SPART = '&V[spart]' AND &V[condition]" endif if V[vkbur]Set V[condition] "TVKBZ~VKBUR = '&V[vkbur]' AND &V[condition]" endif if V[vkgrp]Set V[condition] "TVBVK~VKGRP = '&V[vkgrp]' AND &V[condition]" endif // determine the filtered "vtweg" values Clear text[r] Call /GuiXT/dbselect _in.table="TVKBZ join TVBVK on TVKBZ~VKBUR = TVBVK~VKBUR" _ in.fields="TVKBZ~VTWEG" _ in.distinct="X" _ in.condition="&V[condition]" _ table.values="r" Set V[k] 0label filter_vtweg Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvtweg" line="&V[k]" if Q[ok] if V[dropdownitem_vtweg_&V[myvtweg]] CopyText fromString="dropdownitem_vtweg_&V[myvtweg]" _ toText="vtweglist" -appendLine Set V[save_vtweg] "&V[myvtweg]" endif goto filter_vtweg endif // build up condition for spart if V[vkorg] Set V[condition] "TVKBZ~VKORG = '&V[vkorg]' AND &V[condition]" endif if V[vtweg]Set V[condition] "TVKBZ~VTWEG = '&V[vtweg]' AND &V[condition]" endif if V[vkbur]Set V[condition] "TVKBZ~VKBUR = '&V[vkbur]' AND &V[condition]" endif if V[vkgrp]Set V[condition] "TVBVK~VKGRP = '&V[vkgrp]' AND &V[condition]" endif // determine the filtered "spart" values Clear text[r] Call /GuiXT/dbselect _ in.table="TVKBZ join TVBVK on TVKBZ~VKBUR = TVBVK~VKBUR" _ in.fields="TVKBZ~SPART" _ in.distinct="X" _ in.condition="&V[condition]" _ table.values="r" Set V[k] 0label filter_spart Set V[k] &V[k] + 1 CopyText fromText="r" toString="myspart" line="&V[k]" if Q[ok] if V[dropdownitem_spart_&V[myspart]] CopyText fromString="dropdownitem_spart_&V[myspart]" _ toText="spartlist" -appendLine Set V[save_spart] "&V[myspart]" endif goto filter_spart endif // build up condition for vkbur if V[vkorg] Set V[condition] "TVKBZ~VKORG = '&V[vkorg]' AND &V[condition]" endif if V[vtweg]Set V[condition] "TVKBZ~VTWEG = '&V[vtweg]' AND &V[condition] endif if V[spart]Set V[condition] "TVKBZ~SPART = '&V[spart]' AND &V[condition]" endif if V[vkgrp]Set V[condition] "TVBVK~VKGRP = '&V[vkgrp]' AND &V[condition]" endif // determine the filtered "vkbur" values Clear text[r] Call /GuiXT/dbselect _in.table="TVKBZ join TVBVK on TVKBZ~VKBUR = TVBVK~VKBUR" _ in.fields="TVKBZ~VKBUR" _ in.distinct="X" _ in.condition="&V[condition]" _ table.values="r" Set V[k] 0label filter_vkbur Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvkbur" line="&V[k]" if Q[ok] if V[dropdownitem_vkbur_&V[myvkbur]] CopyText fromString="dropdownitem_vkbur_&V[myvkbur]" _ toText="vkburlist" -appendLine Set V[save_vkbur] "&V[myvkbur]" endif goto filter_vkbur endif
// build up condition for vkgrp if V[vkorg] Set V[condition] "TVKBZ~VKORG = '&V[vkorg]' AND &V[condition]" endif if V[vtweg]Set V[condition] "TVKBZ~VTWEG = '&V[vtweg]' AND &V[condition]" endif if V[spart]Set V[condition] "TVKBZ~SPART = '&V[spart]' AND &V[condition]" endif if V[vkbur]Set V[condition] "TVKBZ~VKBUR = '&V[vkbur]' AND &V[condition]" endif // determine the filtered "vkgrp" values Clear text[r] Call /GuiXT/dbselect _ in.table="TVKBZ join TVBVK on TVKBZ~VKBUR = TVBVK~VKBUR" _ in.fields="TVBVK~VKGRP" _ in.distinct="X" _ in.condition="&V[condition]" _ table.values="r" Set V[k] 0label filter_vkgrp Set V[k] &V[k] + 1 CopyText fromText="r" toString="myvkgrp" line="&V[k]" if Q[ok] if V[dropdownitem_vkgrp_&V[myvkgrp]] CopyText fromString="dropdownitem_vkgrp_&V[myvkgrp]" _ toText="vkgrplist" -appendLine Set V[save_vkgrp] "&V[myvkgrp]" endif goto filter_vkgrp endif Clear V[repeat]// vkorg now unique? CopyText fromText="vkorglist" toString="s" line=2 if not Q[ok] Set V[vkorg] "&V[save_vkorg]" Set V[repeat] "X" endif endif // vtweg now unique? CopyText fromText="vtweglist" toString="s" line=2 if not Q[ok] Set V[vtweg] "&V[save_vtweg]" Set V[repeat] "X" endif endif // spart now unique? CopyText fromText="spartlist" toString="s" line=2 if not Q[ok] Set V[spart] "&V[save_spart]" Set V[repeat] "X" endif endif // vkbur now unique? CopyText fromText="vkburlist" toString="s" line=2 if not Q[ok] Set V[vkbur] "&V[save_vkbur]" Set V[repeat] "X" endif endif // vkgrp now unique? CopyText fromText="vkgrplist" toString="s" line=2 if not Q[ok] Set V[vkgrp] "&V[save_vkgrp]" Set V[repeat] "X" endif endif // repeat selection due to new unique values? goto repeat_selection endif Return InputScript "clear_organizational_data.txt" // clear input (organizational data) Clear V[vkorg] Clear V[vtweg] Clear V[spart] Clear V[vkbur] Clear V[vkgrp] include "filter_organizational_data.txt"
|
Components |