Monthly Archives: April 2013

Dropdown Menu

Creating a dropdown list from the contents of a field is not as hard as you would think. I recommend just trying this, whether you understand everything in it or not. Following the log and seeing it work, helped me understand why it worked!

Dropdown_Script1 -Intial script that runs others and calls dialog box
 **************************************
com** Open a file that lists your dropdown items once. In this case, 
it is a summarized inventory file. So that each inventory type is 
listed only one time.
OPEN ItemDetail
SUMMARIZE on Type_Description_c to T_SORT2 PRESORT

com**Identify the number of records and initialize variables
OPEN T_SORT2
COUNTctr=1
FGDropDown_List=' '

com**Initiate script that creates the dropdown list with seperators.
DO A01_FG_DropDown2 while Ctr<=COUNT1
Ctr=1
St_pos=1

com**Initiate script that ensure the length of the dropdown list is not 
over 255 characters.
DO A01_FG_DropDown3 while Ctr<=3

com** Dialog box that contains the dropdown list that is created above and 
assigns the items selected to variables.  
DIALOG (DIALOG TITLE "Finished Goods" 
WIDTH 670 HEIGHT 293 ) (BUTTONSET TITLE "&OK;&Cancel" AT 564 192 DEFAULT 1)
(TEXT TITLE "The sales analysis should only be performed on Finished Goods.
Identify the inventory type that represents these items. Select from the dropdown." 
AT 12 16 WIDTH 633 HEIGHT 32 ) (DROPDOWN TITLE "%FG_LIST1%%FG_list2%%FG_List3%" 
TO "v_TFGtype1" AT 24 72 WIDTH 130 ) 

com** v_TFGtype1 is now the variable that represents finished goods!
A01_FG_DropDown2 - creates the dropdown list with seperators
**************************************
com** define variable for dropdown
LOCATE Record ctr
ADJDropDown_list=Alltrim(Movement_Type_Code_c)+';'+ADJDropDown_List
ctr=ctr+1
A01_FG_DropDown3 - ensure the length of the dropdown list is not over 255 characters
 **************************************
DD_List%Ctr% = Substr(ADJDropDown_List,St_Pos,255)
Ctr=Ctr+1
St_Pos=St_Pos+255