convert a string to a enum value

Hi experts,

I need to convert a string to a enum value.

The scenerio is, the string value is Open Order and it has to be converted to the enum value of salesstatus baseenum.

I have tried the below code.

assume “orderStatus” string variable contain “OpenOrder”

Salesstatus _salesStatus;


_salesStatus = str2enum(_salesStatus, orderStatus);

It is not working and _salesStatus is getting backOrder values in the enum irrespective of the string in the “orderStatus”.

If you try the reverse function, enum2str(salesStatus::Backorder), you’ll get “Open order”, not “OpenOrder”. Therefore str2enum() works for “Open order” and not for “OpenOrder”, which is considered an invalid value.