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     Function for getting right two characters

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Function for getting right two characters
 Login/Join
 
Gold member
posted
Is there a function in WebFocus, like there is in Excel, where you can request characters at the far right (or left) of a field?

In excel, the function is:

RIGHT(A2,2) and it would return 04 if cell A2
contained 20070204.

Thank you.


PROD: WebFocus 7.6.9 on WinXP
 
Posts: 59 | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
Depends on the field and is it fixed length a number alphanumeric and so on.

Oh, by the by, before someone else asks you to do so, please update your signature so we know what platforma and so on.

Thanks


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
You could just reverse the string using a few computed fields for length and format and then grab the (then) first two characters and reverse them -
TABLE FILE CAR
PRINT COMPUTE C_LEN/I3    = ARGLEN(20, COUNTRY, 'I3');
      COMPUTE C_FMT/A4    = 'A' || EDIT(C_LEN);
      COMPUTE LAST_TWO/A2 = REVERSE(2,REVERSE(C_LEN,COUNTRY,C_FMT),'A2');
   BY COUNTRY
END

The output, of which, is -
COUNTRY C_LEN C_FMT LAST_TWO 
ENGLAND     7  A007       ND 
FRANCE      6  A006       CE 
ITALY       5  A005       LY 
JAPAN       5  A005       AN 
W GERMANY   9  A009       NY

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
You could also put this into a function that can be called from any TABLE request -
DEFINE FUNCTION RIGHT(SOURCE/A999, CHARS/I3, X_FMT/A4)
  C_LEN/I3     = ARGLEN(999, SOURCE, 'I3');
  C_FMT/A4     = 'A' || EDIT(C_LEN);
  RIGHT/A999V  = REVERSE(CHARS,REVERSE(C_LEN,SOURCE,C_FMT),X_FMT);
END
TABLE FILE CAR
SUM COMPUTE LAST_TWO/A2 = RIGHT(COUNTRY, 2, 'A2');
   BY COUNTRY
END
TABLE FILE GGSALES
SUM COMPUTE CARDINAL/A4 = RIGHT(REGION, 4, 'A4');
   BY REGION
END

This will get the "n" right characters from a string with a maximum length of 999 chars.

Note: There is no validation on this function to ensure correct parameter passing, so trying to pass a numeric field will fail.

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
I like the reverse(reverse. Creative thinking. I probably would have gone with SUBSTR once I knew the length of the argument.


ttfn, kp


Access to most releases from R52x, on multiple platforms.
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
Expert
posted Hide Post
Thanks Karen, just proves that you can't write off "old" FOCUS programmers Wink

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Gold member
posted Hide Post
Thank you all so much. I like the idea of creating a function, Tony, I think I'm going to try it. And I NEVER write off programmers, we don't have any FOCUS programmers, but I send my mainframe programmers thanks all the time, and sometimes gifts, too.

I thought I updated my signature, Leah...sorry.


WebFocus 7.1.3 on WinXP


PROD: WebFocus 7.6.9 on WinXP
 
Posts: 59 | Registered: October 31, 2006Report 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     Function for getting right two characters

Copyright © 1996-2020 Information Builders