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] Using fieldname to represent string in STRREP function

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Using fieldname to represent string in STRREP function
 Login/Join
 
Member
posted
I want to replace the occurrences of a string in another string by referencing a fieldname instead of a fixed string value.

As far as I can tell, the STRREP function only allows the entry of a value in the command line, and therefore it can only search for and replace one particular string in all of my records. I would like for this string to change its value according to a particular field that is unique to each record, the record that also contains the string that is the subject of the search and replace.

I know this coding structure works...

COMMENT_B/A375V = STRREP (375,COMMNET_A, 10, 'first name', 10, 'XXXXXXXXXX', 375, COMMENT_B);

...but it limits the value of the string that can be replaced to just one name. Instead, I would like to use the fieldname FIRST_NAME to vary the string value with each record and remove that particular name from the comment text. I have not been able to get the following coding structure to work, but it sort of indicates what I am trying to accomplish.

COMMENT_B/A375V = STRREP (375,COMMNET_A, 10, FIRST_NAME, 10, 'XXXXXXXXXX', 375, COMMENT_B);

I've also considered OVRLAY and some other functions; however, in my case I would need to vary the starting position of the substrings to be replaced by each record, and as far as I can tell those functions require fixed starting positions for each record as well.

It seems relatively straightforward with the STRREP function, but I do not know if it is possible to make WebFOCUS read a variable string value by referencing a fieldname, not to mention whether this is possible within this function. Any suggestions on how this could be accomplished?

This message has been edited. Last edited by: jltz83,
 
Posts: 2 | Registered: June 18, 2014Report This Post
Expert
posted Hide Post
Did you try it out.

All seems to work.

Single Char
DEFINE FILE CAR
 CNTR/I9 WITH MODEL = IF LAST CNTR EQ 0 THEN 65 ELSE LAST CNTR + 1 ;
 CHAR/A1 = HEXBYT(CNTR,'A1') ;
 NEWMODEL/A50 = STRREP (24,MODEL,1,CHAR,3,'???', 50,'A50') ;
END
TABLE FILE CAR
 PRINT MODEL
CNTR
CHAR
NEWMODEL
END


Variable Chars
DEFINE FILE CAR
 CNTR/I9 WITH MODEL = IF LAST CNTR EQ 3 THEN 1 ELSE LAST CNTR + 1 ;
 STR/A3 = SUBSTR(24,MODEL,1,CNTR,CNTR,'A3') ;
 NEWMODEL/A50 = STRREP (24,MODEL,ARGLEN(3,STR,'I1'),STR,3,'???', 50,'A50') ;
END
TABLE FILE CAR
 PRINT MODEL
CNTR
STR
NEWMODEL
END


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
Member
posted Hide Post
Thank you for the advice!

I ended up using the following:

DEFINE FILE JLTCDV4
CNTR_F/I2 WITH 5LINESB = ARGLEN(12,FIRST_NAMEB,'I2');
CNTR_L/I2 WITH 5LINESB = ARGLEN(12,LAST_NAMEB,'I2');
STR_F/A12 = SUBSTR(12,FIRST_NAMEB,1,CNTR_F,CNTR_F,'A12');
STR_L/A12 = SUBSTR(12,LAST_NAMEB,1,CNTR_L,CNTR_L,'A12');
5LINESC/A375V = STRREP (375,5LINESB, ARGLEN(12, STR_F, 'I2'), STR_F, 5, 'XXXXX', 375, 'A375');
5LINESD/A375V = STRREP (375,5LINESC, ARGLEN(12, STR_L, 'I2'), STR_L, 5, 'XXXXX', 375, 'A375');
END
 
Posts: 2 | Registered: June 18, 2014Report This Post
Expert
posted Hide Post
Can you add [SOLVED] or [CLOSED] to the title of your first post in this thread.

Just click on the folder image with the pencil.


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
  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] Using fieldname to represent string in STRREP function

Copyright © 1996-2020 Information Builders