Purpose Using complex selection criteria (UI and dabase selection) |
Solution
Example
If the user wants to add another account number interval, he presses the button to the right of the interval input fields and enters the new interval in the SAP standard dialog:
The "multiple selection" then changes to "active" and the new interval is selected when the user presses the "Start" button:
GuiXT Script // create table variables if not V[customers] CreateTable V[customers] kunnr name1 ort01 landx Clear V[customer.stat.*]
// range tables for account number and country code CreateStructure V[rangeline] sign option low high CreateTable V[range_kunnr] include=V[rangeline] CreateTable V[range_land1] include=V[rangeline] endif // multiple selection active for account number? if V[range_kunnr.rowcount>0] Set V[icon_kunnr] "1E" Set V[readonly_kunnr] "-readonly" else Set V[icon_kunnr] "1F" Set V[readonly_kunnr] "" endif // multiple selection active for country? if V[range_land1.rowcount>0] Set V[icon_land1] "1E" Set V[readonly_land1] "-readonly" else Set V[icon_land1] "1F" Set V[readonly_land1] "" endif // selections Box (10,67) (16,158) "Select customers"
InputField (12,70) "Account from" (12,86) size=10 name="kunnr_low" InputField (12,103) "to" (12,107) size=10 name="kunnr_high" -upperCase searchhelp="DEBIA" &V[readonly_kunnr] Pushbutton (12,125) "@&V[icon_kunnr]\QMultiple selection of account@" process="multiple_selection_kunnr.txt" using nextfocus = (12,125)
InputField (13,70) "Country" (13,86) size=3 name="land1_low" searchhelp="H_T005" &V[readonly_land1] Pushbutton (13,125) "@&V[icon_land1]\QMultiple selection of country@" process="multiple_selection_land1.txt" using nextfocus = (13,125)
Pushbutton (15,70) "@15@Start" process="select_customers.txt" size=(1,19) // customer table Table (17,67) (33,159) title="&V[customers.rowcount] customers selected" -rowSelection name="customers" fixedcolumns=4 Column "Account" -readOnly size=10 name="kunnr" Column "Name" -readOnly size=30 name="name1" Column "City" -readOnly size=30 name="ort01" Column "Country" -readOnly size=15 name="landx"
InputScript "select_customers.txt" // select customers from database Set V[tabname] "KNA1 left outer join T005T on T005T~LAND1 = KNA1~LAND1" Set V[fields] "kna1~kunnr,kna1~name1,kna1~ort01,t005t~landx" Set V[orderby] "kna1~kunnr"
// build up where-condition for database select Clear V[condition]
// kunnr selection if V[range_kunnr.rowcount>0] Set V[condition] "kna1~kunnr in @range1 and" else if V[kunnr_low] or V[kunnr_high]
// add leading zeros if numeric process V[kunnr_low_int] = convert_kunnr_input "&V[kunnr_low]" process V[kunnr_high_int] = convert_kunnr_input "&V[kunnr_high]"
if V[kunnr_high]
Set V[condition] "kna1~kunnr between '&V[kunnr_low_int]' else Set V[condition] "kna1~kunnr = '&V[kunnr_low_int]' and" endif endif endif
// land1 selection if V[range_land1.rowcount>0] Set V[condition] "&V[condition] kna1~land1 in @range2 and" else if V[land1_low] Set V[condition] "&V[condition] kna1~land1 = '&V[land1_low]' and" endif endif
// add language selection for country name Set V[condition] "&V[condition] t005t~spras = '&V[_language]'"
// select from database Call /guixt/dbselect _ export.table="tabname" _ export.fields="fields" _ export.orderBy="orderby" _ export.condition="condition" _ export.range1="range_kunnr" _ export.range2="range_land1" _ import.values="customers"
// scroll to first row Set V[customers.stat.firstvisiblerow] 1
Return
InputScript "multiple_selection_kunnr.txt" Parameter nextfocus // focus when returning from dialog
CreateStructure V[tabfield] tablename fieldname
Set V[tabfield.tablename] "KNA1" Set V[tabfield.fieldname] "KUNNR" Set V[title] "Select customers by number" Set V[search_help] "DEBIA"
// empty range table? then add first interval if V[range_kunnr.rowcount=0]
if V[kunnr_low] or V[kunnr_high]
if V[kunnr_high] Set V[rangeline.sign] "I" Set V[rangeline.option] "BT"
// add leading zeros if numeric process kunnr_low_int = convert_kunnr_input "&V[kunnr_low]" process kunnr_high_int = convert_kunnr_input "&V[kunnr_high]"
Set V[rangeline.low] "&V[kunnr_low_int]" Set V[rangeline.high] "&V[kunnr_high_int]"
else Set V[rangeline.sign] "I" Set V[rangeline.option] "EQ"
// add leading zeros if numeric process kunnr_low_int = convert_kunnr_input "&V[kunnr_low]" Set V[rangeline.low] "&V[kunnr_low_int]"
endif
// append first selection AppendRow V[rangeline] table=V[range_kunnr]
endif
// indicate: multiple selection active Set V[kunnr_low] "*" Set V[kunnr_high] "*"
endif
Call "COMPLEX_SELECTIONS_DIALOG" -try -dialog _ export.tab_and_field="tabfield" _ export.title="title" _ export.search_help="search_help" _ export.range(RANGE_C35)="range_kunnr" _ import.range(RANGE_C35)="range_kunnr"
// empty range table? then clear first interval if V[range_kunnr.rowcount=0] Clear V[kunnr_low] Clear V[kunnr_high] endif
// set focus if U[nextfocus] SetCursor "&U[nextfocus]" endif
return
InputScript "multiple_selection_land1.txt" Parameter nextfocus // focus when returning from dialog
CreateStructure V[tabfield] tablename fieldname
Set V[tabfield.tablename] "KNA1" Set V[tabfield.fieldname] "LAND1" Set V[title] "Select country" Set V[search_help] "H_T005"
// empty range table? then add first value if V[range_land1.rowCount=0]
if V[land1_low]
Set V[rangeline.sign] "I" Set V[rangeline.option] "EQ" Set V[rangeline.low] "&V[land1_low]"
endif
// append first selection AppendRow V[rangeline] table=V[range_land1]
// indicate: multiple selection active Set V[land1_low] "*"
endif
Call "COMPLEX_SELECTIONS_DIALOG" -try -dialog _ export.tab_and_field="tabfield" _ export.title="title" _ export.search_help="search_help" _ export.range(RANGE_C35)="range_land1" _ import.range(RANGE_C35)="range_land1"
// empty range table? then clear first interval if V[range_land1.rowCount=0] Clear V[land1_low] Clear V[land1_high] endif
// set focus if U[nextfocus] SetCursor "&U[nextfocus]" endif return InputScript "process_convert_kunnr_input.txt"
// SAP alpha conversion to internal format Parameter kunnr
// empty ? if not V[kunnr] return "" endif
// add leading zeros, length 10 Set V[x](1-10) "0000000000&V[kunnr]" -alignright
// use GuiXT calculation to check whether numeric Set V[y] &V[kunnr] + 0 Set V[y](1-10) "0000000000&V[y]" -alignright
// numeric? then return with leading zeros If V[x=&V[y]] Return "&V[x]" else return "&V[kunnr]" endif |
Components InputAssistant |