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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved] Error using DECODE in IF statement

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved] Error using DECODE in IF statement
 Login/Join
 
Member
posted
I'm getting a FOC272 FORMAT ERROR IN DECODE OR FILE ELEMENT error when using a DECODE within an IF statement. The IF statement functions correctly if I replace the DECODE with a value.

 
DEFINE FILE CAR
CURNT_DT/YYMD = &YYMD;
CURNT_YR/YY=CURNT_DT;
CURNT_MT/M =CURNT_DT;
MTH_ID/A4 = 
IF (CURNT_YR LE '2006') THEN 
DECODE CURNT_MT(4 '0604' 10 '0610' ELSE '????') ELSE 
DECODE CURNT_MT(3 '0703' 11 '0711' ELSE '????');
END
TABLE FILE CAR
PRINT
CAR
CURNT_DT
CURNT_YR
CURNT_MT
MTH_ID
END



Using the DECODE alone works fine.
MTH_ID/A4 = 
DECODE CURNT_MT(3 '0703' 11 '0711' ELSE '????');


Does anyone have any ideas as to why?

Thanks,
Jeff

This message has been edited. Last edited by: Jeff_f,
 
Posts: 18 | Registered: January 12, 2011Report This Post
Expert
posted Hide Post
Sorry, I don't get it. What exactly are you trying to accomplish here?




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Member
posted Hide Post
I was trying to use Mickey's code to determine if it is currently EST or EDT.
 
Posts: 18 | Registered: January 12, 2011Report This Post
Virtuoso
posted Hide Post
If my memory does not fail me, I think that DECODE cannot be used in an IF-THEN-ELSE statement. So break it up:
  
DEFINE FILE CAR
CURNT_DT/YYMD = &YYMD;
CURNT_YR/YY=CURNT_DT;
CURNT_MT/M =CURNT_DT;
MTH_ID1/A4=DECODE CURNT_MT(4 '0604' 10 '0610' ELSE '????');
MTH_ID2/A4=DECODE CURNT_MT(3 '0703' 11 '0711' ELSE '????');
MTH_ID/A4 = IF (CURNT_YR LE '2006') THEN MTH_ID1 ELSE MTH_ID2 ;
END
-RUN
TABLE FILE CAR
PRINT
CAR
CURNT_DT
CURNT_YR
CURNT_MT
MTH_ID
END


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Member
posted Hide Post
That will work. Thanks Danny.
 
Posts: 18 | Registered: January 12, 2011Report This Post
Virtuoso
posted Hide Post
Jeff --

What release are you on? The code you posted works in 7.6.9.


I suspect the restriction (in your release) relates to using a date variable as argument of DECODE (within an IF clause).

If you take the error message, "FORMAT ERROR IN DECODE OR FILE ELEMENT", literally, it is a complaint about a format mismatch within the DECODE (comparing "4" to the format of CURNT_MT/M) -- rather than a complaint about the presence of a DECODE within the IF clause, or mismatch between its resultant value and the LHS, MTH_ID/A4. The primary form for a literal value to be assigned to a date variable is a character literal (to be converted to the corresponding integer date-offset value), not the offset integer value.


What happens if you substitute a proper numeric variable:
. . .
CURNT_MT/M =CURNT_DT;  iMth/I2=CURNT_MT;
MTH_ID/A4 = IF (CURNT_YR LE '2006') 
 THEN DECODE iMth(4 '0604' 10 '0610' ELSE '????')
 ELSE DECODE iMth(3 '0703' 11 '0711' ELSE '????');
. . .
?

This message has been edited. Last edited by: j.gross,
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
We are on 7.7.03.

Using the integer variable worked. thanks
 
Posts: 18 | Registered: January 12, 2011Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved] Error using DECODE in IF statement

Copyright © 1996-2020 Information Builders