October 20, 2008, 07:14 AM
<Navin>[SOLVED] Tokenizing
I have the string like 987,654,321 i want to convert this to 987','654','321 .
How to convert this?
My String length will be differenat at run time . But the comms place is static , 3rd position only
Can we use this without GETTOK ??
Thanks
Naveen.
This message has been edited. Last edited by: Kerry, October 20, 2008, 10:49 AM
Francis MarianiTry the String Replace function to replace , with ','.
STRREP: Replacing Character Strings Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 23, 2008, 03:00 AM
AjaiNavin,
This may help you :
-SET &IN_VAL='456,232,232,2323,2323,23232,456,77676,56666';
-DEFAULT &CTR=0;
-DEFAULT &COUNTER =0;
-REPEAT ENDREPEAT WHILE &COUNTER NE 100
END
-SET &COUNTER = &COUNTER +1;
-SET &Var1=GETTOK(&IN_VAL,&IN_VAL.LENGTH,&COUNTER,',',40,'A40');
-IF &Var1 NE '' THEN LOOP1 ELSE GOTO LOOPEND;
-LOOP1
-SET &CTR = &CTR + 1;
-LOOPEND
-ENDREPEAT
-DEFAULT &COUNTER1 =0;
-DEFAULT &VALUE=' ';
-DEFAULT &NEW_VAL='';
-REPEAT ENDREPEAT1 WHILE &COUNTER1 LT &CTR
END
-SET &COUNTER1 = &COUNTER1 +1;
-SET &Var2=GETTOK(&IN_VAL,&IN_VAL.LENGTH,&COUNTER1,',',10,'A10');
-SET &VALUE = &VALUE |TRUNCATE(&Var2) |'","';
-SET &NEW_VAL=CTRAN(&VALUE.LENGTH,&VALUE,34,39,A400);
-TYPE &NEW_VAL
Thanks
October 23, 2008, 05:28 AM
SurentherCheck This Code
quote:
-SET &IN_VAL='456,232,232,2323,2323,23232,456,77676,56666';
-SET &VALUE = STRREP(100,&IN_VAL,1,',',4,''',''',100,A100);
-TYPE &VALUE
thanks Allen
October 26, 2008, 05:02 PM
WazNavin, is this string a single field in a report or are the groups of 3 digits multiple fields ?
November 02, 2008, 11:59 PM
<Navin>This Issue is solved . .
We got it using ,
STRREP(100,&CUSIP_VAL,1,',',4,''',''',800,A800);
Thanks all for your support.
January 04, 2012, 06:42 PM
DougFrancis,
Thanks for the refresher on STRREP. This is one of those command names that I just could not remember.
I needed to change the commas in a list of user ids to "
, @something.com" to fillout the list of email addresses. the techniques worked like a charm.