﻿if not V[mm01_lgnum=&V[mm01_lgnum_lgtyp]]
  Set V[mm01_lgnum_lgtyp] "&V[mm01_lgnum]"  
  
  // Create a GuiXT table variable for the dropdownlist
  CreateTable V[ddltab_mm01_lgtyp] key text
  
  // Prepare parameters for reading the text table
  
  // we join the check table "T301" and the text table "T301T"
  Set V[table] "T301 left outer join T301T on T301T~LGTYP = T301~LGTYP and T301T~SPRAS = '&V[_language]' AND T301~LGNUM = T301T~LGNUM"
  Set V[condition] "T301~LGNUM = '&V[mm01_lgnum]'"
  
  // we use an outer join together with the "coalesce" function
  // in order to replace non-existing texts with the key value
  Set V[fields] "T301~LGTYP, COALESCE( T301T~LTYPT | T301~LGTYP ) as F2"
  
  // Read table via RFC call
  Call /guixt/dbselect  _
    export.table="table" _
    export.condition="condition" _
    export.fields="fields" _
    import.values="ddltab_mm01_lgtyp"
  
  
  CreateStructure V[ddltabline] key text
  AppendRow V[ddltabline] table=V[ddltab_mm01_lgtyp]
  
endif

if not V[mm01_lgnum_ref=&V[mm01_lgnum_ref_lgtyp]]
  Set V[mm01_lgnum_ref_lgtyp] "&V[mm01_lgnum_ref]"  
  
  // Create a GuiXT table variable for the dropdownlist
  CreateTable V[ddltab_mm01_lgtyp_ref] key text
  
  // Prepare parameters for reading the text table
  
  // we join the check table "T301" and the text table "T301T"
  Set V[table] "T301 left outer join T301T on T301T~LGTYP = T301~LGTYP and T301T~SPRAS = '&V[_language]' AND T301~LGNUM = T301T~LGNUM"
  Set V[condition] "T301~LGNUM = '&V[mm01_lgnum_ref]'"
  
  // we use an outer join together with the "coalesce" function
  // in order to replace non-existing texts with the key value
  Set V[fields] "T301~LGTYP, COALESCE( T301T~LTYPT | T301~LGTYP ) as F2"
  
  // Read table via RFC call
  Call /guixt/dbselect  _
    export.table="table" _
    export.condition="condition" _
    export.fields="fields" _
    import.values="ddltab_mm01_lgtyp_ref"
  
  CreateStructure V[ddltabline] key text
  AppendRow V[ddltabline] table=V[ddltab_mm01_lgtyp_ref]
  
endif
