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 21This message has been edited. Last edited by: Kerry,
WebFOCUS 7.7.03 Windows 7
October 24, 2011, 06:52 PM
Brenda Wilkerson
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
October 24, 2011, 06:53 PM
Waz
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.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
October 24, 2011, 08:48 PM
Brenda Wilkerson
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
October 24, 2011, 09:47 PM
Doug
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
October 24, 2011, 09:59 PM
Brenda Wilkerson
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
October 24, 2011, 10:09 PM
Waz
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.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
October 25, 2011, 03:44 AM
Dave
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
October 25, 2011, 09:23 AM
Brenda Wilkerson
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
October 25, 2011, 09:48 AM
njsden
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.
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
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
October 25, 2011, 06:37 PM
njsden
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!