cancel
Showing results for 
Search instead for 
Did you mean: 

split a string field to mutiple line items in IDOC

former_member260907
Participant
0 Kudos

Hi expert,

I have a flat file to IDOC scenario. Inside the flat file, there is a field string which will have 2000 characters. In the receiver IDOC side, there is a text line item field with 1-999999999 occurrence. I need to split the string into multiple lines with 135 characters each line and map it to the text line item field. That is, in source side, one long string field to generate multiple line items for that field only. Does anyone know how to do it?

Thanks,

Charles 

former_member206439
Contributor
0 Kudos

Hi I am also having the same issue .

Could you please let me know what we need to add in UDT and SplitByValue functions?

I am new to this functions.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi,

I think this split can only be done with a UDF:

int size = 135;
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));
}

Then use simple mapping: source (2000 chars long) -> UDF -> target (135 chars long). You might also need to put splitByValue(Each Value), depending on your target structure - I believe you'll be able to handle it .

Hope this helps,

Greg

former_member260907
Participant
0 Kudos

Hi Greg,

Thanks for the reply! I implemented your UDF. However, system could not recognize the result. What data type do you define it? Also, what I chose for execution type? I see have three options: Single values, All values of Queue and All values of context. I searched on SDN. I don't see I have java type of ResultList option. How I can get it?

Thanks again!

Charles

former_member184681
Active Contributor
0 Kudos

>>> However, system could not recognize the result.

What precisely do you mean by that? Do you get some particular error? Unexpected results? What kind of?

>>> What data type do you define it?

One input variable named input and the default output named result.

>>> Also, what I chose for execution type?

It does not really matter, since you only have one input value in one context (is that correct for me to assume?).

Hope this helps,

Greg

former_member260907
Participant
0 Kudos

Hi Greg,

i just updated my last text. Please see above. Interesting thing is I don't have the default output named result.

Charles

former_member260907
Participant
0 Kudos

Never mind. I saw it now.

former_member184681
Active Contributor
0 Kudos

So what's the current status, because frankly speaking I got lost in those post updates . Do you need further help?

former_member260907
Participant
0 Kudos

Hi Grag,

Sorry to make you confusion. I used single valule, it does not have result parameter. Even I changed it to context/queue, it did not show up. I had to delete it and make a new UDF with context/queue. And then I saw the result parameter.

Now,  I still need your help.Sorry, I made your confuse again. . Let me make it clear:

My source structure is like this:

MT_source : 1-1

  Recordset :1-1

     Record: 1-unbound

        field1:  1-1

        field2:  1-1

        textstring:  1-1  ---> this has 2000 characters

My target structure:

IDOC: 1-unbound  -->Map to "Record"

     Segment1: 1-1

        field1: 1-1

        field2: 1-1

     Segment2: 0-999999999

       LineItemNumber: 0-1 --->00010(constant)

       textline:0-1  --> map to textstring

Now, the problem is: I need to split the textstring into multiple lines. Let's say n lines. I need to make Segment2 and its fields (here is 2 fields:LineItemNumber and textline) appear n times. And each line's value is mapped to textline. How I can make Segment2 n times based on textstring's splitted lines number,  textstring itself map to field " textline"?

  Thank you!

   Charles

former_member184681
Active Contributor
0 Kudos

Hi Charles,

No problem, I'm glad you got the UDF working . This should do the job for you in mapping:

Hope this helps,

Greg

former_member260907
Participant
0 Kudos

Hi Greg,

Yes. It is working. Thank you so much!

All the best!

Charles

Answers (0)