cancel
Showing results for 
Search instead for 
Did you mean: 

UDF required

former_member10771
Active Participant
0 Kudos

Hello,

I have the incoming value as ABC/1234568654/G8 . I need to truncate this and pass as 1234568654 to the target.

Can anyone please help me on this.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

No need to go for an udf. This can be done using std function" SubString"

SubString(4,14). in PI7.1(start position as 4, character count as 10)

Regards,

Swetha.

Answers (2)

Answers (2)

former_member10771
Active Participant
0 Kudos

Thanks the issue has been solved.

former_member187339
Active Contributor
0 Kudos

Hi Amit,

Try this:


int startPosition = input.indexOf('/');
int endPosition = input.lastIndexOf('/');

String output = input.substring(startPosition, endPosition);
return output;

Regards

Suraj

former_member10771
Active Participant
0 Kudos

Hi Suraj,

Thanks for the solution. One more thing is I am now getting the output only thing is it is coming as /123456 . / is coming at the start. Any change in the UDF.

former_member187339
Active Contributor
0 Kudos

HiAmit,

Small change

int startPosition = input.indexOf('/');

int endPosition = input.lastIndexOf('/');

String output = input.substring(startPosition+1, endPosition);

return output;

Regards

Suraj

former_member10771
Active Participant
0 Kudos

Thanks Suraj for the help.

Swetha : I could have used substring but the value that is coming is not always 4..10 and can change.

Thanks

Amit