﻿// Create a GuiXT table variable for the dropdownlist
CreateTable V[ddltab_mm01_matkl] key text

// Prepare parameters for reading the text table

// we join the check table "T023" and the text table "T023T"
Set V[table] "T023 left outer join T023T on T023T~MATKL = T023~MATKL and T023T~SPRAS = '&V[_language]'"

// we use an outer join together with the "coalesce" function
// in order to replace non-existing texts with the key value
Set V[fields] "T023~MATKL, COALESCE( T023T~WGBEZ | T023~MATKL ) as F2"

// Read table via RFC call
Call /guixt/dbselect -bundle _
  export.table="table" _
  export.fields="fields" _
  import.values="ddltab_mm01_matkl"
