E: Field changed, Dropdown

Example for Field change in the item master data window

custom_artikel_edit

 

In this example

- we will insert a Dropdown in the DIN Field and will check and convert to upper case

- check the match code for unique

- handle field names, which has different names in MSSQL and HANA

 

Used event: form_loaded, dw_1_item_xx_itemchanged sql messagebox

 

beasscript-logo-small

global function form_loaded
// we create the dropdown and read the information if user click on dropdown icon
dw_1."ITEM"."U_beas_din"."DROPDOWN".select "U_beas_din" from "OITM" Group by "U_beas_din" order by "U_beas_din"
end event
 
global function dw_1_item_u_din_itemchanged
// Convert u_din automatically to upper case
// example: insert "abc", converted autoamtically to "ABC"
dw_1.item.u_din.value=<dw_1.item.u_din.value,upper>
end global
 
global function dw_1_item_u_match_itemchanged
// Match code changed. System check, if this matchcode is in use (but not in own itemcode)
// The field "U_beas_match" exists only in HANA. In MSSQL the name is "U_match"
// but in SQL statements the system convert it always in correct format
// we use "select ... into :variable to read the result
// Note: use always "<..,dbstring> for convert string in correct SQL format.
select count(*) into :ll_count from "OITM" where "U_beas_match" =<dw_1.item.u_match.value,dbstring> and "ItemCode" <> <str_parm.s_parm1,dbstring> 
if <ll_count> n> 0 then
  // if entry found: search for first entry with item name
  select top 1 "ItemCode","ItemName" into :ls_itemcode,:ls_itemname from "OITM" where "U_beas_match" =<dw_1.item.u_match.value,dbstring> and "ItemCode" <> <str_parm.s_parm1,dbstring> 
  messagebox=error$**$The match code "<dw_1.item.u_match.value> is current in use. First item with this match code: "<ls_itemcode>" "<ls_itemname>"
  dw_1.item.u_match.value=""
end if
 
global function dw_1_item_u_znr_itemchanged
// third letter must be always a "-"
// if user insert "abc", the system convert it automtacally to "ab-c"
if  <dw_1.item.u_znr.value,mid 3 1> <> "-" then
  dw_1.item.u_znr.value=<dw_1.item.u_znr.value,left 2>-<dw_1.item.u_znr.value,mid 3>
end if
end global

 

help-hinweis Example Notes