COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: ramakrishnamanne on 17 Jun 2015 09:09:35 AM

Title: Remove the special
Post by: ramakrishnamanne on 17 Jun 2015 09:09:35 AM
Hi All,

I have a description field with special characters and unwanted number, I want to remove that special characters and unwanted numbers which is BOLD in the example description in report studio report.

Description Field:-
31- Customer Reference Number: 2388094412 ~32- BUYER NAME OR DEPARTMENT:F13 -~33- DELIVERY REQUESTED ON 06/01/11 ~34- CANCEL AFTER 06/16/15 ~35-ATTENTION ELAINE HOWIE~36- CANCEL ALL BACKORDERS. CHECK COSTS****|| BEFORE SHIPPING~37-FAX 43575 8795~10-CALL FOR APPT: 450/642-0101.  ~30-GST/HST #10574 8278 RT0001##~

Note:- We don't know how many special characters , unwanted numbers and specific length of characters.
Cognos :-10.2.2 version
Database :- Oracle
Relational database

Thanks
RK
Title: Re: Remove the special
Post by: CognosPaul on 17 Jun 2015 12:51:11 PM
Stuff like this should be cleaned in the ETL. Anything you do will always be slower and dirtier than the what is possible in the ETL.

Oracle has a function called REGEX_REPLACE that will allow you to replace strings with a regex search. Since I don't have Oracle handy at the moment, I can't test it. But the code will probably be something like:

regexp_replace([Field], '^[0-9]+-|~[0-9]+-', '')

That should find the numbers, but take care, it's very easy to get unwanted results with regex.
Title: Re: Remove the special
Post by: ramakrishnamanne on 18 Jun 2015 02:20:08 AM
 Thanks CognosPaul,
I will try with that function and let you know how it will work.

Thanks
RK
Title: Re: Remove the special
Post by: ramakrishnamanne on 18 Jun 2015 05:27:56 AM
Hi Paul,

I am not able to find the function which is you suggested in database functions in cognos.

In crystal report they have written code for removing special characters and unwanted numbers like this

local stringvar notes:= trim(Replace (left(mid({Description},4),len(mid({Description},4))-1),"#" ,"
" ))+"
";
while instr(notes,'~')>0
do (
local stringvar snipe:= mid(notes,instr(notes,'~'),4);
notes:= replace(notes,snipe,"");
);
notes


They have written loop.

Using this code shall we create it in cognos report side? Can you please help anyone on same to write in cognos report side?

Thanks
RK
Title: Re: Remove the special
Post by: CognosPaul on 18 Jun 2015 07:11:37 AM
Crystal allows for some programming logic on the resultset after it's been returned. In this case it looks like a VBA variant of some sort. Cognos doesn't give us this flexibility, but there are plenty of workarounds.

The function isn't listed in Cognos as it's not officially supported. Try using it anyway. You may need to wrap the function in curly braces and use the database field name to get it to work. An alternative is to create a UDF and import that into framework.
Title: Re: Remove the special
Post by: ramakrishnamanne on 06 Jul 2015 10:54:34 AM
Thanks Paul.

What you suggested oracle function is worked for me


thanks
RK