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

// Prepare parameters for reading the text table

// we join the check table "TBAC_PHYSCOMM" and the text table "TBAC_PHYSCOMMT"
Set V[table] "TBAC_PHYSCOMM left outer join TBAC_PHYSCOMMT on TBAC_PHYSCOMMT~COMMODITY = TBAC_PHYSCOMM~COMMODITY and TBAC_PHYSCOMMT~LANGU = '&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] "TBAC_PHYSCOMM~COMMODITY, COALESCE( TBAC_PHYSCOMMT~TEXT | TBAC_PHYSCOMM~COMMODITY ) as F2"

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