cancel
Showing results for 
Search instead for 
Did you mean: 

Java concenate with an offset ?

Former Member
0 Kudos

Hi,

For Javamen...

I'm facing to a stupid pb: easy in abap, but in Java is another story...

Here's what I want to do in Java (with a UdF):

Source = abcdefgh.

Target = 1234567

Target+10(6) = Source(6).

Thus result should be: Target = "1234567___abcdef" with three spaces "_" (for this example), coz the first part is on 10 characters.

My pb is not to get the 6 char of Source (cf. fct substring), but it's the managment of the offset "+10".

Regards

Mickael

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

source and target are two input values -> is this right?

Regards

Patrick

Former Member
0 Kudos

Hi Patrick

Yes for instance, but I think the pb is not here coz we will have two inbound parameters of our UdF.

Mickael

Former Member
0 Kudos

Hi,

if I understand you right you want to bring the target value to a length of 10.

In this case you could write a udf with one parameter (here a) like this:

if (a.length() < 10) {

while (a.length() < 10) {

a = a + " ";

}

}

return a;

Then you can use the standard concat-function with the output of the udf and the source value.

(Works only if your target could not be longer than 10 otherwise you have to check this also)

Regards

Patrick

Former Member
0 Kudos

Patrick

Yes, I thank also to that, but is there a standard Java function for this offset ?

it takes 1 line in abap... and a couple in Java.

Mickael

Edited by: Mickael Huchet on Jul 1, 2008 4:10 PM

Former Member
0 Kudos

Hi,

Can you pls. tell me how can you do this in a single line in ABAP?

Thanks

Amit

GabrielSagaya
Active Contributor
0 Kudos

There is no offset function in JAVA

sour>myudf->Target

This is your udf

function myudf(String a,Container container)

{

if (a.length()<10)

{

for (int i=a.length();i<10;i++)

a+="_";

}

return a;

}

henrique_pinto
Active Contributor
0 Kudos

Then do it in an ABAP Mapping.

Henrique.

PS: lines of code means nothing, unless you're talking about assembly.

Former Member
0 Kudos

)

Mickael

P.S: Hopefully developper cannot use what they want to do a mapping... Else maintenance will be not really happy / easy....

Former Member
0 Kudos

Hi Amit,

yes I can, it's written if my first post...

Target+10(6) = Source(6).

Regards

Mickael

Answers (0)