ganesh_kapase
21st December 2005, 06:22
Hi All,
Please tell me how to use ON CASE statement instead of IF THEN statements for below code. Here Data Type of field tisfc001.osta is Enumerated.
if tisfc001.osta = tcosta.hours.adj then
m.osta = "Active"
endif
if tisfc001.osta = tcosta.ready then
m.osta = "Completed"
endif
if tisfc001.osta = tcosta.closed then
m.osta = "Closed"
endif
Thanx & Regards,
Ganesh
bigjack
21st December 2005, 07:00
Hi,
on case etol(tisfc001.osta)
case etol(tcosta.hours.adj ): m.osta = "Active"
break
case etol(tcosta.ready): m.osta = "Completed"
break
case etol(tcosta.closed): m.osta = "Closed"
break
endcase
Bye
en@frrom
21st December 2005, 11:01
Bigjack,
Your code is correct, and will work. But may I ask you why you convert the enums to the numeric constants twice?? I would just leave out the etol function completely. And if already I want to use it, I would write ON CASE etol(tisfc001.osta) case 1: etc.. But now You just seem to be doing double work...
Was just wondering if maybe you have a specific reason to it....?
bigjack
21st December 2005, 11:22
Hi,
I wanted to make my code independent of any changes in domain.
i.e. assuming the order sequence of values of enum is changed, my code would still work fine
Bye
en@frrom
21st December 2005, 11:26
Ok, a valid remark, IF ever such things happen. Do they? You know of this ever having happened?
en@frrom
21st December 2005, 11:29
Ehm oops sorry, actually not a valid remark. You don't have to use the numeric values at all! You can just write the enum constants only. I.e.
ON CASE tisfc001.osta
case tcosta.hours.adj:
etc.
bigjack
21st December 2005, 11:40
stumped me.......never thought enums can be used directly in case :)
actually the care needs to be taken in case of customised domains and in particular of deleting any value....
bye
en@frrom
21st December 2005, 11:53
Yes, that's why I never (except for once, when it was really necessary!!) changed anything about a domain... these are things you just don't do. And IF already you do, you of course must check first all the 'where used' for that domain...!!!
ganesh_kapase
21st December 2005, 13:27
Hi bigjack & En
Problem solved, thanx for your efforts.
Bye
Ganesh