cancel
Showing results for 
Search instead for 
Did you mean: 

Split input string to chunk of characters and assign it to target idoc line item

Former Member
0 Kudos

Hello Experts,

My requirement is like this.

Input field is having values more than 135 characters and we want to split this value to multiple segments of IDOC SEGMENT. This is like First 13 characters to segment one ,secon d 13 to segment 2 and so on.

I tried with solit by value(each value but it did not work. Can someone please help me on this?

Really appreciate help.

Thanks in advance,

Accepted Solutions (0)

Answers (14)

Answers (14)

Former Member
0 Kudos

solved

Former Member
0 Kudos

Hello ,

I wrote UDF which is splitting the string into 13 string each, but I want the idoc segment to be created for every next 13 fields but the other values of the other fields in the idoc segment should be as it is. I tired with this logic in mapping but its not working

Source--UDF---SpilitByValue(Each Value)---target.

Can you please suggest any corrections in it?

Thanks in advance

dhivakar
Participant
0 Kudos

Hi,

First add ","delimiter after every 13 characters using a simple udf and write the below code in the same udf. This will give the output as the attached screenshot. Then you can use splitbyvalue function to assign it to the field in consecutive segments.

for (String a: value[0].split(","))

{

result.addValue(a);

}splitstring.png

JayChan
Active Participant
0 Kudos

Hi,

If you need to pass value every 13 character to "different field", rather than graphical mapping, I think it would be much possible using java mapping.

che_eky
Active Contributor
0 Kudos

Looks like you have an extra closing bracket that you do not need. Try this:

result.addvalue(a,pos+13);

Former Member
0 Kudos

Tried with this code

Getting this error

Can you please tell me where it went wrong?

Thanks in advance

Former Member
0 Kudos

Any help on this please?

Thanks in advance

Former Member
0 Kudos

Hi Mark,

I created it this way but it did not work. Did I use the code correctly or there is any error in using it? Can you please advise where it went wrong?

Thanks in advance

markangelo_dihiansan
Active Contributor
0 Kudos

Try this one:

Test

Regards,

Mark

Former Member
0 Kudos

Hello Mark,

Do I select it as Argument or parameter? Also should it have any Result/Output parameter ?

Thanks in advance

former_member190293
Active Contributor
0 Kudos

Hi BRM Fresher!

It looks like you use single value UDF to produce result list.

As far as I remember, if you want to return a list of values, you should switch to all values of context or all values of queue and process input array instead of single value.

Regards, Evgeniy.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

I do not have PI at the moment, but you can replace System.out.println with result.AddValue;

Hope this helps,

Mark

Former Member
0 Kudos

Thamks Mark and Evgeniy for your valueable replies. Let me try.

Former Member
0 Kudos

Hello Experts,

Any help on this please ?

Thanks in advance

Former Member
0 Kudos

Hello Experts,

Any help on this please?

Thanks in advance

Former Member
0 Kudos

I corrected the UDF like this but it did not work

int size = 13; for (int i = 0; i < input.length(); i += size){ int end = i + size > input.length(); input.length() = i + size; result.addValue(input.substring(i, end)); }

Can someone please help on this?

Thanks in advance

Former Member
0 Kudos

I tried the code in this discussion but its giving the error.

Can you please help me correct the code in this discussion?

https://archive.sap.com/discussions/thread/3160240

Thanks in advance

Former Member
0 Kudos

Hello Experts,

Any help on this please?

Thanks in advance