Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Can I condition which field to print
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Can I condition which field to print
 Login/Join
 
Gold member
posted
I have a merged file with 3 different date fields. I need to condition which one actually prints on a report based on the value of another field. Is this possible?

example: If tran_type = 'R' Print dateAA
else If tran_type = 'E' Print dateBB
else If tran_type = 'A' Print dateCC


Report looks something like this:
Name tran_type Date count
John R 07/11 40
John E 08/01/2011 29 John A 31 Amy R 09/10 17 Amy R 12/11 7 Amy E 07/14/2011 21
Bill R 02/11 44 Bill R 12/11 19 Bill E 08/01/2011 21

This message has been edited. Last edited by: Kerry,



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Gold member
posted Hide Post
Well that report sample didn't come out right, try it again..


Name tran_type Date count
John R 07/11 40
John E 08/01/2011 29
John A 31
Amy R 09/10 17
Amy R 12/11 7
Amy E 07/14/2011 21
Bill R 02/11 44
Bill R 12/11 19
Bill E 08/01/2011 21



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
I think you have answered your own question

DEFINE or COMPUTE
PRINT_DATE/{format} = IF TRAN_TYPE EQ 'R' THEN dateAA ELSE
IF TRAN_TYPE EQ 'E' THEN dateBB ELSE
IF TRAN_TYPE EQ 'A' THEN dateCC ELSE {other date} ;


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6278 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Gold member
posted Hide Post
getting If then else syntax error. I'm new at this for WF so I must be missing something. Here is actual:
COMPUTE PRINT_DATE/A20V = IF MERGE.MERGE.TYPE EQ 'R' THEN MERGE.MERGE.MMYY ELSE
IF MERGE.MERGE.TYPE EQ 'E' THEN MERGE.MERGE.OLDEST ELSE
IF MERGE.MERGE.TYPE EQ 'A' THEN MERGE.MERGE.ALL ;



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Please post a copy of your error message. It may have something to do with the fieldname: "TYPE" (MERGE.MERGE.TYPE). But, a closer look at the error message and number may prove otherwise...




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3106 | Location: Tennessee, Nashville area | Registered: February 23, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
Here is the error:

(FOC266) IF .. THEN .. ELSE .. SYNTAX ERROR
(FOC009) INCOMPLETE REQUEST STATEMENT
BYPASSING TO END OF COMMAND



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
I would suggest adding an ELSE something at the end of the IF THEn ELSE for the compute.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6278 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Reply With QuoteReport This Post
Master
posted Hide Post
Brenda,

is het possible that one ( or more ) of the dates is 'empty' or 'missing'?

That might cause the IF...THEN...ELSE error.

Have you tried using a define instead?

G'luck


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 669 | Location: Veghel, The Netherlands | Registered: February 16, 2010Reply With QuoteReport This Post
Gold member
posted Hide Post
The dates are different formats, 1 is yymd and the other 2 are A20V so I will have to convert the date formatted one in the if statement? When I commented that date out, it ran.



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Yes Brenda. Your PRINT_DATE compute field is defined as A20V and therefore it expects that every result sent to it is an alphanumeric value. If your expression contains numbers or dates then they have to be converted to alphas.

You can use DATECVT to convert dates to alpha, and EDIT/FTOA/PTOA to convert numbers to alpha.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
Brenda convert the dates to the same format first in a Define and then do the IF then Else using the converted dates.


Duane

WebFOCUS 8.0.7
DS 8.0.7 AS 8.0.7
Windows
Output: Excel, HTML, PDF, AHTML,Mobile
In Focus 1982
 
Posts: 83 | Location: Princeton NJ | Registered: October 26, 2007Reply With QuoteReport This Post
Gold member
posted Hide Post
thx, got it to work with the define.....

Code below, if there is a shorter way around this, please let me know. Otherwise thanks so much for all your help Big Grin

DEFINE FILE MERGE
cvtdate/YYMD=DATECVT(OLDEST, 'YYMD', 'YYMD');
cvtdate1/A8YYMD=cvtdate;
cvtdate2/A20V=cvtdate1;
cvtdatedsp/A20V=EDIT(cvtdate2,'9999/99/99');
END



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
quote:
DATECVT(OLDEST, 'YYMD', 'YYMD');


Is OLDEST already a date? No conversion is taking place in the code you posted.

Try this:

DEFINE FILE MERGE
cvtdatedsp/A20V=EDIT(DATECVT(OLDEST,'YYYY','A8YYMD'),'9999/99/99')
END



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
oldest is a YYMD date,



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
I figured so. Using the DEFINE line I posted above takes care of converting your date into an alpha field [ DATECVT(date, 'YYMD',' A8YYMD) ] and then formatting it by adding "/" in between the components.

Not functionally different from your original logic but you'll be saving yourself 3 temporary fields from the internal matrix for each processed row. Yeah, even on this day and time I still worry about saving one byte here and there Wink



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
Yes, thank you that worked as well and cleaner. I knew there had to be an easier way but being fairly new at this, couln't put it together from looking at the help.

I took classed over 3 years ago and by the time we installed WF I had been pulled off on other projects. I am just now getting my feet wet again and it has been a struggle. The old saying "what you don't use you loose" is so true. But, I am getting there.

Thanks again



WebFOCUS 7.7.03
Windows 7
 
Posts: 55 | Location: USA | Registered: November 02, 2009Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Well, better late than never to get back to dive into WebFOCUS waters! Just don't give up Brenda and keep both the WF documentation and the URL to this forum nearby as it has been (and continues to be) of great help to many of us.

As other folks in this forum have said before, happy WebFOCUS sailing!



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Can I condition which field to print

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.