Focal Point
change default value from number type to char type

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8031000982

June 23, 2008, 05:34 PM
JZMSH
change default value from number type to char type
Hi,
I have a problem where i need to change the default value with condition.
Example
output Require output
0 NO
1 YES
2 2
3 3

When value = 0, I need to display to NO, and when value = 1, I need to display to Yes,
else display their actual value

I tried the compute, and it didn't work and give me error message as:
(FOC282) RESULT OF EXPRESSION IS NOT COMPATIBLE WITH THE FORMAT OF FIELD:

any quick inputs on this is highly appreciated.
June 23, 2008, 05:39 PM
Danny-SRL
  
R_OUT/A3=IF OUT EQ 0 THEN 'NO' ELSE
         IF OUT EQ 1 THEN 'YES' ELSE
         FTOA(OUT,'(F3)', 'A3');



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

June 23, 2008, 05:42 PM
Francis Mariani
It depends on what format the numeric input field is.

A COMPUTE like this should do the trick:
COMPUTE OUTVAL/A10 = 
IF INVAL EQ 0 THEN 'NO' ELSE
IF INVAL EQ 1 THEN 'YES' ELSE FTOA(INVAL ,'(D8)',OUTVAL);

If the input field format is Integer, then a simple EDIT will work:
EDIT(INVAL)



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
June 24, 2008, 12:39 AM
Danny-SRL
Francis,

Yes, but you might get leading zeroes.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

June 24, 2008, 11:39 AM
JZMSH
Hi,

Daniel's sample above does work. But my case is complex. Originally I have COL1 and COL2, I want to be able to display COL2_REFORMAT instead:
COL1 COL2 COL2_REFORMAT
row1 0 NO
row2 1 YES
row3 2.22 2
row4 3.33 3.33
row5 44.44 44.44%

I had a define filed to change the number format, like:
IVFMT/A10 = IF COL1 EQ 'row3' THEN 'D10'
ELSE IF COL1 EQ 'row4' THEN 'D10.2'
ELSE IF COL1 EQ 'row5' THEN 'D10.2%;

TABLE FILE....
PRINT COL2/IVFMT

Now, when I just use Daniel's sample, I got all number format as: F3.
Is there a way to get the exact format showing on COL2_REFORMAT?
June 24, 2008, 01:17 PM
Danny-SRL
It is just a bit more complex:
IVFMT/A8 = IF COL1 EQ 'row3' THEN '(D10)'
ELSE IF COL1 EQ 'row4' THEN '(D10.2)'
ELSE IF COL1 EQ 'row5' THEN '(D10.2%)' ELSE 'A15' ;
  
COL2FMT/A15=
IF COL2 EQ 0 THEN 'NO' ELSE
IF COL2 EQ 1 THEN 'YES' ELSE
   FTOA(COL2,IVFMT, 'A15');



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

June 25, 2008, 11:35 AM
JZMSH
That's it!!
Thank Daniel for your big help! Smiler