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     [SOLVED] DEFINEs in IA - using LIKE or CONTAINS
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] DEFINEs in IA - using LIKE or CONTAINS
 Login/Join
 
Platinum Member
posted
I have a user trying to create a define field in InfoAssist to this effect:
IF FIELDA LIKE '%' THEN FIELDB ELSE MISSING.

FIELDA has values like "5%" and "10%" and "$5000". InfoAssist isn't having any of this. How do we make this work?

Thanks!

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


WebFOCUS 8.2.03 (production), 8.2.06 (testing)
AppStudio, InfoAssist
Windows, All Outputs
 
Posts: 172 | Location: Indiana | Registered: December 05, 2017Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Deb

With 8.2.06 I had no luck with LIKE but CONTAINS works just fine in a WHERE statement, but if I replicate your DEFINE I have the same issue as you neither LIKE or CONTAINS works. Better open a case with techsupport...

This message has been edited. Last edited by: FP Mod Chuck,


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 1813 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport This Post
Master
posted Hide Post
quote:
IF FIELDA LIKE '%' THEN FIELDB ELSE MISSING.


This answer assumes the following:
1. FIELDA is an ALPHA field, because LIKE only works on text strings
2. That you are trying to get the ALPHA values that have the percent sign in it.

The percent sign in a LIKE statement is a wildcard. So the statement above is basically saying if the field has anything in it, then return the field. Also if you want MISSING values, you need to set MISSING=ON.

So to get fields with the percent sign, you need to escape the percent sign. Something like this
  
DEFINE FILE masterFileName
NEWFIELDNAME/A50V MISSING ON = IF FIELDA LIKE '%~%%' ESCAPE '~' THEN FIELDB ELSE MISSING.
END DEFINE


More info here: Using an Escape Character for LIKE


Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Yes, FIELDA is an alpha field. Sorry I didn't clarify that.

quote:
IF FIELDA LIKE '%~%%' ESCAPE '~' THEN FIELDB ELSE MISSING.


I get an error when I try that. InfoAssist doesn't seem to like ESCAPE. I tried using other characters in place of ~ and got the same error. :/


WebFOCUS 8.2.03 (production), 8.2.06 (testing)
AppStudio, InfoAssist
Windows, All Outputs
 
Posts: 172 | Location: Indiana | Registered: December 05, 2017Reply With QuoteReport This Post
Master
posted Hide Post
quote:
Originally posted by DWaybright:
I get an error when I try that. InfoAssist doesn't seem to like ESCAPE. I tried using other characters in place of ~ and got the same error. :/


*SIGH* Yeah, sorry. I just noticed that. Once again IA saying perfectly valid code is invalid.

I'm trying one other thing of using a REGEX to see if there is a percent sign in the text. I'll post the answer if it works.


Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Master
posted Hide Post
The REGEX seems to work for me:
  
IF REGEX(FIELDA, '[%]') THEN FIELDB ELSE MISSING;

I built this code in IA and it seemed to work:
  
DEFINE FILE ibisamp/car
Margin/D12.2%=(CAR.BODY.RETAIL_COST / CAR.BODY.DEALER_COST -1)*100;
FIELDA/A25=IF CAR.BODY.SEATS EQ 5 THEN TRIM_(BOTH, ' ', FTOA( CAR.BODY.SALES, '(D12M)', 'A25V')) ELSE TRIM_(BOTH, ' ',FTOA( Margin ,'(D12.2%)', 'A15'));
FIELDB/D12M=CAR.BODY.SALES ;
FIELDC/D12M MISSING ON=IF REGEX(FIELDA, '[%]') THEN FIELDB ELSE MISSING;
END
ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET SQUEEZE=ON
-DEFAULTH &WF_HTMLENCODE=ON;
SET HTMLENCODE=&WF_HTMLENCODE

SET HTMLCSS=ON
-DEFAULTH &WF_EMPTYREPORT=ON;
SET EMPTYREPORT=&WF_EMPTYREPORT

-DEFAULTH &WF_SUMMARY='Summary';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
TABLE FILE ibisamp/car
SUM FIELDA
FIELDB
FIELDC
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
BY CAR.CARREC.MODEL
BY CAR.BODY.SEATS
ON TABLE PCHOLD FORMAT HTML
ON TABLE NOTOTAL
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/endeflt.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
ENDSTYLE
END

-RUN



Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Master
posted Hide Post
More info on REGEX here: REGEX: Matching a String to a Regular Expression


Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Hallway - You're a genius! Smiler
REGEX works! Thank you!

Focal Point comes through for me again.


WebFOCUS 8.2.03 (production), 8.2.06 (testing)
AppStudio, InfoAssist
Windows, All Outputs
 
Posts: 172 | Location: Indiana | Registered: December 05, 2017Reply With QuoteReport This Post
Master
posted Hide Post
🙌

Glad to help


Hallway
WF(Prod):8202M1
WF(Test):8202M4
OS/Platform:Win 10
Outputs:All
 
Posts: 559 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] DEFINEs in IA - using LIKE or CONTAINS

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