I am hoping this is a stupid question, but I am having trouble finding documentation for it. Maybe someone can easily answer for me:
Here is the scenario: I am using DECODE to reassign some field values. Pretty straight forward.
DECODE FIELD1('The Fieldname Value A' 'A' 'The Field Value B' 'B' ...
That sort of thing. But instead of assigning a default literal value, like: ELSE 'Other', I want to use the incoming field value if that value has not been included in the DECODE.
So, instead of:
DECODE FIELD1('The Fieldname Value A' 'A' 'The Field Value B' 'B' ELSE 'Other');
I want something like:
DECODE FIELD1('The Fieldname Value A' 'A' 'The Field Value B' 'B' ELSE FIELD1);
Where the table value of FIELD1 is displayed, if a decoded value has not been supplied for that field value.
I am sure that I had some method of doing this at some point (and that it was simple), but I'm banging my head on the desk a bit trying to figure it out now. I am sure that I could do it with a couple of DEFINE fields, but I am trying to avoid getting into a large, convoluted IF THEN ELSE statement.
Any tips would be appreciated.This message has been edited. Last edited by: Kerry,
You could try something like this.
DEFINE FILE CAR NEWCAR/A20 = DECODE CAR ('JAGUAR' 'JAG' 'JENSEN' 'JEN' ); NEWCAR2/A20 = IF NEWCAR NE ' ' THEN NEWCAR ELSE CAR; END TABLE FILE CAR PRINT CAR NEWCAR NEWCAR2 END
Maybe it works as is, but I always make the default of a DECODE assignment explicit:
... = DECODE CAR ('JAGUAR' 'JAG', 'JENSEN' 'JEN', ELSE ' ');
Do you always put commas in your DECODE?
I tested it and IT WORKS although never mentioned in the documentation!
Another WF wonder?
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
The bottom of the function definition in the documentation says:
So in practice you can put those comma's wherever you like and it should work.
So apparently you could also write it as:
... = DECODE CAR ('JAGUAR','JAG' 'JENSEN','JEN' ELSE ''); ... = DECODE CAR ('JAGUAR','JAG','JENSEN','JEN',ELSE '');
I am a bit surprised that a comma before the ELSE statement is accepted though!
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
Wep5622 just beat me
j.gross - yes the ELSE ' ' should be added.
Interesting about the comma...
|Powered by Social Strata|