dromeo
25th July 2018, 18:39
Hello,

In a report script I have a SELECT to read and display the content of an enum list field on a Purchase Order. The field is properly displayed.

Now, I'm trying to assign to this enum variable, a string variable of another field (always on the Purchase Order) to be displayed instead of the enum variable, if a certain condition is met. The problem is that if I try to assign to an enum variable a string, I will get an error because the 2 variables are of a different type. I've been looking on the forum but I'm not finding the function to eventually convert the enum type to string so to then assign the string value to be displayed.

Thank you very much,

Daniel Romeo

NPRao
25th July 2018, 19:30
Daniel,

I don't think there is a function to convert enums to strings.

Here are all the available standard Tools functions -

Enumerates overview and synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_enumerates_overview_and_synopsis)

The closest function that you can use is - str$() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_string_operations_str), however it will convert the enumerate value to string but not fetch the enumerate description to make it more meaningful.

dromeo
25th July 2018, 20:58
Daniel,

I don't think there is a function to convert enums to strings.

Here are all the available standard Tools functions -

Enumerates overview and synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_enumerates_overview_and_synopsis)

The closest function that you can use is - str$() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_string_operations_str), however it will convert the enumerate value to string but not fetch the enumerate description to make it more meaningful.

Hello NPRao,

Thank you so much for that link. In fact it was very useful. The enum.descr$() function did the trick for me. For the rest of the community:

What I did was to define directly on the layout of the report a variable of type string. I extracted the description of the enum variable with the mentioned function, enum.descr$(), and stored it to the above variable. The same variable that I used in the condition to assign the other field of type string when the condition is met.

Thank you again for the valuable link! :)

Daniel Romeo

mark_h
25th July 2018, 20:59
I think what I would do is change the report variable to output a string. Then I would set the string variable to the description using the enum.descr function. Then if I wanted I output something else I would just set the string to the new value. I know I have used string variables to pass multiple different table fields to a report. So I might use string order.number - then order number could be production order, purchase order or even a GRP order number.

mark_h
25th July 2018, 21:01
LOL - posting around the same time.

dromeo
25th July 2018, 22:16
LOL - posting around the same time.

eheheh!!! same thinking!!! thank you anyway Mark!!! :)