LordMrT
29th November 2023, 12:17
Hello everyone,
I have created a new CDF field of type List at table level. Now I would like to select this field in a report and output the description in the report.
How can I select the description of the list entry in an SQL? I get the enum value but not the description from the list.
Here is my current SQL query:
select atcibd001.cdf_sub1 :reach_gefahr_nr1,
atcibd001.cdf_sco1 :ext.reach_konz1
from tcibd001 atcibd001
where atcibd001._index1 = {:sh.line.item}
selectdo
select atxibd005.subs :ext.reach_gefahr1,
atxibd005.casn :ext.reach_cas1
from txibd005 atxibd005
where atxibd005._index1 = {:reach_gefahr_nr1}
selectdo
endselect
endselect
The CDF Listfield is: atcibd001.cdf_sco1
Thank you very much
bdittmar
29th November 2023, 12:43
Hello,
are you searching for the enum description ?
enum.descr$()
Syntax:
function string enum.descr$ (string domain_code(12), enum_expr [, string language_code])
Description
This returns the description associated with a specific value in an enumerated domain.
Arguments
string domain_code(12) The name of the domain. The domain must be of type enumerated.
enum_expr One of the possible values of the enumerated domain.
[string language_code] To retrieve the description in a language other than the user language, specify the relevant language code in this argument. This is an optional argument. The default language is the language of the user.
Note that the language code of the user is available in the predefined, read-only variable language$.
Return values
The description of the specified enumerate value, either in the current user language or in another specified language.
The function returns an empty string, and displays an error message, if an unknown domain is specified or if no description exists in the data dictionary for the specified language.
Context
This function is implemented in the porting set and can be used in all script types.
Example
This example assumes an enumerated domain 'tcyesno' with two possible constants: 'tcyesno.yes' and 'tcyesno.no'. It also assumes that 1 is the language code for Dutch, 2 is the language code for English, and 3 is the language code for German. English is the current user language.
domain tcyesno active | enumerated domain
string descr(25)
active = tcyesno.no
descr = enum.descr$("tcyesno", active, "1") | descr contains "nee"
descr = enum.descr$("tcyesno", active) | descr contains "no"
descr = enum.descr$("tcyesno", active, "3") | descr contains
"nein"
LordMrT
29th November 2023, 16:15
Hello,
no, as far as I know this is the wrong function. My CDF does not have a domain but is of the data type list. The list entries are maintained via references.
LordMrT
30th November 2023, 12:46
Hello, I have found the solution. The following function is necessary:
enum.descr$()
Syntax:
function string enum.descr$ (string domain_code(12), enum_expr [, string language_code])
Description
This returns the description associated with a specific value in an enumerated domain.
Arguments
string domain_code(12) The name of the domain. The domain must be of type enumerated.
enum_expr One of the possible values of the enumerated domain.
[string language_code] To retrieve the description in a language other than the user language, specify the relevant language code in this argument. This is an optional argument. The default language is the language of the user.
Note that the language code of the user is available in the predefined, read-only variable language$.
ext.reach_konz1 = enum.descr$("tccdf_lstcon", konz1, "3")
It is important that the value with the correct domain is selected. In my case, this was the automatically generated one "tccdf_lstcon".