Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
NESTED IF help...
 Login/Join
 
<Shane>
posted
All,

I'm brand new to WebFOCUS and am getting a crazy error. Maybe I don't understand the language well enough, but here goes. We're passing 3 variables into a fex and want it to calculate the start date based on the 3 variables (&DT_GRP, &DT_SPAN, &DT_CUR). Basically, the user selects a Date Group (1st variable) of Monthly, Weekly, or Daily. A second variable of Date Span (1-12 if date group is monthly or weekly & 1-31 if date group is daily). A 3rd variable of Date Current (Y or N flag) if they want to see up-to-date data. So, in the following situation, we're trying to calculate the start date if a user has selected up-to-date Monthly data for the last 11 months.

Here's my code:

-DEFAULT &DT_GRP = 'M';
-DEFAULT &DT_SPAN = 11;
-DEFAULT &DT_CUR = 'Y';

-SET &START_DATE = IF (('&DT_GRP' EQ 'M') AND ('&DT_CUR' EQ 'Y')) THEN AYM(EDIT(&YYMD,'999999'),&DT_SPAN_TEXT,'I6') ELSE 19000101;
- ELSE IF (('&DT_GRP' EQ 'D') AND ('&DT_CUR' EQ 'Y')) THEN AYMD(&YYMD,&DT_SPAN_TEXT*(-1),'I8')
- ELSE IF (('&DT_GRP' EQ 'W') AND ('&DT_CUR' EQ 'Y')) THEN
- IF (DOWK(AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8'), 'A3') EQ 'SUN' OR 'SAT')
- THEN DATECVT((DATEMOV((DATECVT(AYMD(AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8'),-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE DATECVT((DATEMOV((DATECVT(AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE 19000101;

Any help would be appreciated.

Shane
 
Report This Post
Virtuoso
posted Hide Post
Shane

the ";" after your first -SET line should be removed.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
<Shane>
posted
Frank,

I did that and am still getting an IF...THEN...ELSE error...

I've narrowed down where my error is coming from the following code statement...

-SET &TEST = AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8');

-SET &START_DATE3 = IF ((&DT_GRP.EVAL EQ 'W') AND (&DT_CUR.EVAL EQ 'Y')) THEN
- IF (DOWK(&TEST, 'A3') EQ 'SUN' OR 'SAT')
- THEN DATECVT((DATEMOV((DATECVT(AYMD(&TEST,-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE DATECVT((DATEMOV((DATECVT(&TEST,'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE 19000101;

Shane
 
Report This Post
Virtuoso
posted Hide Post
Maybe it is easier if you tell us what you want to achieve.

Splitting the code into some minor steps might help.

The last if... change the 19000101 to '19000101'
and the 4th line has unbalanced brackets.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Try this

-SET &TEST = AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8');
-TYPE &TEST
-SET &T1=DATECVT((DATEMOV((DATECVT(AYMD(&TEST,-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD');
-SET &T2=DATECVT((DATEMOV((DATECVT(&TEST,'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD');

-TYPE  &T1 &T2

-SET &START_DATE3 = IF ((&DT_GRP.EVAL EQ 'W') AND (&DT_CUR.EVAL EQ 'Y')) THEN
- IF (DOWK(&TEST, 'A3') EQ 'SUN' OR 'SAT') THEN &T1  ELSE &T2  ELSE '19000101';





Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Expert
posted Hide Post
quote:
-SET &TEST = AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8');

-SET &START_DATE3 = IF ((&DT_GRP.EVAL EQ 'W') AND (&DT_CUR.EVAL EQ 'Y')) THEN
- IF (DOWK(&TEST, 'A3') EQ 'SUN' OR 'SAT')
- THEN DATECVT((DATEMOV((DATECVT(AYMD(&TEST,-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE DATECVT((DATEMOV((DATECVT(&TEST,'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE 19000101;


Chg'd &DT_SPAN_TEXT to &DT_SPAN since I don't see the &DT_SPAN_TEXT set anywhere; tested on 7.6.1, based on the -DEFAULT, got 20070813:

-DEFAULT &DT_GRP = 'W';
-DEFAULT &DT_SPAN = 11;
-DEFAULT &DT_CUR = 'Y';

-SET &TEST = AYMD(&YYMD,&DT_SPAN*(-7),'I8');

-SET &START_DATE3 = IF ((&DT_GRP.EVAL EQ 'W') AND (&DT_CUR.EVAL EQ 'Y')) THEN
- IF (DOWK(&TEST, 'A3') EQ 'SUN' OR 'SAT')
- THEN DATECVT((DATEMOV((DATECVT(AYMD(&TEST,-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE DATECVT((DATEMOV((DATECVT(&TEST,'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD');


-*Commented this out, end the statement above with a ;
-* ELSE 19000101;


-TYPE &START_DATE3

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
<Shane>
posted
All:

I got it to work...here's my code...

-* File date.fex
-*SET &ECHO=ALL;
-DEFAULT &PLANT_NAME = 'FOC_NONE';
-DEFAULT &DEPT_NO = 'FOC_NONE';
-DEFAULT &WORKCENTER = 'FOC_NONE';
-DEFAULT &DT_GRP='M';
-DEFAULT &DT_SPAN_TEXT = 12;
-DEFAULT &DT_CUR = 'Y';
-*
-*DAYS CALCULCATION
-SET &DATE_DAY = AYMD(&YYMD,-1,'I8');
-SET &START_DAY = AYMD(&YYMD,&DT_SPAN_TEXT*(-1),'I8');
-SET &END_DAY = &YYMD;
-*
-*MONTH
-SET &TODAY_MON = EDIT(&YYMD,'999999');
-SET &START_MONTH = AYM(&TODAY_MON,&DT_SPAN_TEXT*(-1),'I6');
-SET &END_MONTH = IF &DT_CUR EQ 'Y' THEN &TODAY_MON ELSE AYM(&TODAY_MON,-1,'I8');
-*
-*WEEK CALCULATION
-SET &TODAY_WEEK = IF DOWK(&YYMD, 'A3') EQ 'SUN' OR 'SAT'
- THEN DATECVT((DATEMOV((DATECVT(AYMD(&YYMD,-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE DATECVT((DATEMOV((DATECVT(&YYMD,'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD');

-SET &START_WEEK = AYMD(&TODAY_WEEK,&DT_SPAN_TEXT*(-7),'I8');
-SET &END_WEEK = IF &DT_CUR = 'Y' THEN &TODAY_WEEK ELSE AYMD(&TODAY_WEEK,-7,'I8');

-SET &START_DATE = IF &DT_GRP EQ 'D' THEN &START_DAY ELSE
- IF &DT_GRP EQ 'M' THEN &START_MONTH||'01' ELSE
- &START_WEEK;

-SET &END_DATE = IF &DT_GRP EQ 'D' THEN &END_DAY ELSE
- IF &DT_GRP EQ 'M' THEN &END_MONTH||'01' ELSE
- &END_WEEK;

-TYPE START DATE = &START_DATE END-DATE = &END_DATE
 
Report This Post
Platinum Member
posted Hide Post
This is why we who've been in the programming game for 30+ years like to indent stuff. It takes more hits of the spacebar but it makes structural errors like yours quite visible:

-SET &START_DATE =
- IF (('&DT_GRP' EQ 'M')
- AND ('&DT_CUR' EQ 'Y'))
- THEN AYM(EDIT &YYMD,'999999'),
- &DT_SPAN_TEXT, 'I6')
- ELSE 19000101;
- ELSE IF (('&DT_GRP' EQ 'D')
- AND ('&DT_CUR' EQ 'Y'))
- THEN AYMD(&YYMD,&DT_SPAN_TEXT*(-1),'I8')
- ELSE IF (('&DT_GRP' EQ 'W')
- AND ('&DT_CUR' EQ 'Y'))
- THEN IF (DOWK(AYMD(&YYMD,&DT_SPAN_TEXT*(-7), 'I8'), 'A3')EQ 'SUN' OR 'SAT')
- THEN DATECVT((DATEMOV((DATECVT(AYMD(AYMD(&YYMD,&DT_SPAN_TEXT(7),'I8'),-2,'I8YYMD'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE DATECVT((DATEMOV((DATECVT(AYMD(&YYMD,&DT_SPAN_TEXT*(-7),'I8'),'I8YYMD','YYMD')),'BOW')),'YYMD','I8YYMD')
- ELSE 19000101;

[Of course, we're sometimes put off by those text editors and language input dialogues that force a new physical line after 80 or so characters !!]


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
 
Posts: 154 | Location: NY | Registered: October 27, 2005Report This Post
Platinum Member
posted Hide Post
... and those bulletin boards that strip out multiple spaces for the sake of enfoced 'brevity'.


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
 
Posts: 154 | Location: NY | Registered: October 27, 2005Report This Post
Expert
posted Hide Post
your spaces will not get stripped off if you use
[code]
[/code]
tags.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders