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     [CLOSED] STRREP when string is unknown

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] STRREP when string is unknown
 Login/Join
 
Platinum Member
posted
Hi All,
I have the following string where i have to replace the from and to dates with new dates.

Department:'None';Participant_address:N;FROM_DATE:11/01/2018;TO_DATE:03/31/2019;REDACT_IND:N;

The problem is i wont know the dates at runtime.
for now i am doing

-SET &OTHER_PARMS = TRUNCATE(&OTHER_PARMS);
-SET &FROM_DT_OTHER_PARMS = STRREP (&OTHER_PARMS.LENGTH, &OTHER_PARMS, 10, 'FROM_DATE', 1, '!', &OTHER_PARMS.LENGTH, 'A&OTHER_PARMS.LENGTH');
-SET &ABCD = GETTOK(&FROM_DT_OTHER_PARMS, &FROM_DT_OTHER_PARMS.LENGTH ,-1, '!', 31, 'A31');
-SET &ABCD = '!'||&ABCD;
-SET &FROM_DT_OTHER_PARMS = STRREP (&FROM_DT_OTHER_PARMS.LENGTH, &FROM_DT_OTHER_PARMS, &ABCD.LENGTH,&ABCD, 0, '', 100, A100);
-SET &OTHER_PARMS = TRUNCATE(&FROM_DT_OTHER_PARMS)||&DATES;
-TYPE &OTHER_PARMS

Is there any way to do this more efficiently.
In future i might have cases where there are some more date parameters(Say,Transaction_Start and End Dates)

WF8105M
windows 10

This message has been edited. Last edited by: FP Mod Chuck,
 
Posts: 181 | Registered: October 25, 2017Report This Post
Virtuoso
posted Hide Post
Are you on 8105? There's a bunch of new simplified functions that might help but only available in 82xx.

https://webfocusinfocenter.inf...source/substring.htm


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
Unfortunately i am in 8105 still
 
Posts: 181 | Registered: October 25, 2017Report This Post
Expert
posted Hide Post
There are a number of simplified functions in 8105.

Check out the documentation.

Are the dates always in the same position ?, i.e. token number, assuming a semicolon can be trusted.

An example of what you want out the other side would help


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
You probably need to replace that date "manually", by finding the POSITION() of the strings "FROM_DATE:" and "TO_DATE:" and using the fact that a date is 10 characters long (assuming it can't be left empty).

Armed with that, you can concatenate substrings based on these positions to get the desired string.
-SET &FROM_START = POSITION(&OTHER_PARAMS, 'FROM_DATE:') + CHAR_LENGTH('FROM_DATE:');
-SET &FROM_LENGTH = CHAR_LENGTH('11/01/2018');
-SET &FROM_END = &FROM_START + &FROM_LENGTH -1;
-SET &TO_START = POSITION(&OTHER_PARAMS, 'TO_DATE:') + CHAR_LENGTH('TO_DATE:');
-SET &TO_LENGTH = CHAR_LENGTH('11/01/2018');
-STE &TO_END = &TO_START + &TO_LENGTH -1;

-SET &OTHER_PARAMS = SUBSTRING(&OTHER_PARAMS, 1, &FROM_START)
- + &NEW_FROM_DATE
- + SUBSTRING(&OTHER_PARAMS, &FROM_END, &TO_START - &FROM_END, &TO_LENGTH)
- + &NEW_TO_DATE
- + SUBSTRING(&OTHER_PARAMS, &TO_END, &OTHER_PARAMS.LENGTH - &TO_END);


I'm sure there are some off-by-one errors in that example, but you get the drift.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Master
posted Hide Post
Assuming that the string will always be semicolon delimited and that the date positions will always be in the third and fourth positions, the following seems to work on my end:
  
-SET &ECHO=ALL;
-SET &MYSTRING = 'Department:''None'';Participant_address:N;FROM_DATE:11/01/2018;TO_DATE:03/31/2019;REDACT_IND:N;';
-SET &NEW_FROM_DATE = '01/01/2019';
-SET &NEW_TO_DATE = '05/31/2019';

-SET &OLD_FROM_DATE = TOKEN( TOKEN(&MYSTRING, ';', 3)||':', ':', 2 );
-SET &OLD_TO_DATE = TOKEN( TOKEN(&MYSTRING, ';', 4)||':', ':', 2 );

-SET &MYSTRING = TRUNCATE(STRREP(CHAR_LENGTH(&MYSTRING), &MYSTRING, CHAR_LENGTH(&OLD_FROM_DATE), &OLD_FROM_DATE, CHAR_LENGTH(&NEW_FROM_DATE), &NEW_FROM_DATE, 1000, 'A1000'  ) );
-SET &MYSTRING = TRUNCATE(STRREP(CHAR_LENGTH(&MYSTRING), &MYSTRING, CHAR_LENGTH(&OLD_TO_DATE), &OLD_TO_DATE, CHAR_LENGTH(&NEW_TO_DATE), &NEW_TO_DATE, 1000, 'A1000'  ) );
-TYPE &MYSTRING


As Waz mentioned, there are Simplified Character Functions in 8105, and this uses two of those: CHAR_LENGTH and TOKEN

In 8201 there is also a simplified function for replacing a string, simply called REPLACE that would would simplify it further by changing the STRREP with:
 
-SET &MYSTRING = TRUNCATE(REPLACE(&MYSTRING, &OLD_FROM_DATE, &NEW_FROM_DATE));
-SET &MYSTRING = TRUNCATE(REPLACE(&MYSTRING, &OLD_TO_DATE, &NEW_TO_DATE));
 


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
 
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Report This Post
Expert
posted Hide Post
Will the source string always have "FROM_DATE:" and "TO_DATE:" in it?If so, getting the tokens should be the key to this working as desired.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report 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     [CLOSED] STRREP when string is unknown

Copyright © 1996-2020 Information Builders