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

// we join the check table "TVTW" and the text table "TVTWT"
Set V[table] "TVTW left outer join TVTWT on TVTWT~VTWEG = TVTW~VTWEG and TVTWT~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] "TVTW~VTWEG, COALESCE( TVTWT~VTEXT | TVTW~VTWEG ) as F2"

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