cancel
Showing results for 
Search instead for 
Did you mean: 

Subsring functionality

Former Member
0 Kudos

Hi,

Information Line 1:

IF E1IDB02 BA-FIIKWAER = CNY

then MID(E1EDKA1 BE-NAME1,12,11)

IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)<=35

then MID(E1EDKA1 BE-STRAS,1,35)

IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)>35

then MID(E1EDKA1 BE-NAME1,36,35)

MID(E1EDKA1 BE-NAME1,12,11), If the total lenght NAME1 is ManoJ Kumar Musunuri and the the request is to pick the string from 11 to 22 lenghs, But the defined value is give is less than 22 lenght.

In these cases the a run time exception error is given. So my understanding is that the other total lenth of the field(ie.., 35characters) has to be entered atleast with spaces.

I would like to know if you have solution for this. Else we need to create a user defined function.

Manoj

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Yes, but you have to write your own UDF ,

but i can give example use this to solve your problem.

IF E1IDB02 BA-FIIKWAER = CNY

then MID(E1EDKA1 BE-NAME1,12,11)

1)

input E1EDKA1 BE-NAME1,E1IDB02 BA-FIIKWAER

<i>if (E1IDB02 BA-FIIKWAER = CNY) {

return substring(E1EDKA1 BE-NAME1,12,11);

}</i>

2)

input E1EDKA1 BE-NAME1,E1IDB02 BA-FIIKWAER

IF (E1IDB02 BA-FIIKWAER <> CNY ) && ( (E1EDKA1 BE-NAME1).length<=35)

{

return substring(E1EDKA1 BE-STRAS,1,35);

}

3)

IF (E1IDB02 BA-FIIKWAER <> CNY) && ((E1EDKA1 BE-NAME1).length>35)

{

return substring(E1EDKA1 BE-NAME1,36,35);

}

Regards

Chilla

ravi_raman2
Active Contributor
0 Kudos

Manoj,

or u can use this simple java function..

//specify the location on the string u want to cut from

int start = 1;

//specify the location on the string u want to cut to

int end = 4;

//"aString is the string you want to cut.

String substr = "aString".substring(start, end);

public class subStringer(){

//main method

public static void main(){

int start = 4;

int end = 8

String cutMe = "kingKongRuledTheWorldWithDinosaurs ";

String choppedString = cutMe.subString(start, end);

System.out.println(choppedString);

}//end main

}

The above program should give an output of "Kong"

Hope that helps..

Regards

Ravi

Former Member
0 Kudos

Hi,

I had a solution.

Solution:

field name , constant with total spaces as max length and concat it and add the substring function.

Thanks and Regards,

Manoj Kumar

Former Member
0 Kudos

Hi,

Use UDF , it is the best option.

use substring java function to get it.

Regards

Chilla

Former Member
0 Kudos

Hi Chilla,

Is there any UDF defined earlier for the same.

Thanks,

Manoj