cancel
Showing results for 
Search instead for 
Did you mean: 

Substring with a dynamic length

Former Member
0 Kudos

Hi All.

I need to convert the URL that comes as a https to http.

This URL is dynamic and so im not able to give the 'To' value when trying to use the substring functionality.

If i have a URL as https://forums.sdn.sap then i need to convert this as http://forums.sdn.sap and process it.

Is there any UDF available for this functionality?

Kindly help....

Thanks in advance.

Sai

Accepted Solutions (1)

Accepted Solutions (1)

sunilchandra007
Active Contributor
0 Kudos

Hi,

Try this !!!

public String getHTTP(String a, Container container)
{
return a.replace("https","http");
}

Also you can use standard text function replaceString.

Regards,

Sunil Chandra

Edited by: sunil chandra on May 3, 2010 2:35 PM

Former Member
0 Kudos

Hi Sunil,

Using this code is throwing me the following error:-

illegal start of expression public String getHTTP(String a, Container container)

I tried passing the URL to be converted as the input to the UDF as 'a'.

Have i missed out anything??

Thanks,

Sai

sunilchandra007
Active Contributor
0 Kudos

Sorry try this.

public String getHTTP(String a, Container container)
{
a = a.replace("https","http");
return a;
}

Regards,

Sunil Chandra

Former Member
0 Kudos

Hi Sunil,

No problem...

I tried this code now.. bt still does not seem to work...

Can you please confirm if this is working fine?

Thanks,

Sai

sunilchandra007
Active Contributor
0 Kudos

I guess you made some basic mistake creating the udf or you pasted the whole code I provided. You just need to copy the two lines.

a = a.replace("https","http");
return a;

I would suggest you to check out http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm for basic steps to create udf.

Regards,

Sunil Chandra

Former Member
0 Kudos

Hi Sunil,

Have given it as you have mentioned..

The error i get is:-

replace(char,char) in java.lang.String cannot be applied to (java.lang.String,java.lang.String) a = a.replace("https","http");

Thanks,

Sai

sunilchandra007
Active Contributor
0 Kudos

It should work. Anyways, give one more try with a = a.replaceFirst(""https","http");

One more thing . Is there any special requirement to go for UDF. The same can be done with standard text function replaceString.

Regards,

Sunil Chandra

Answers (0)