on 04-12-2012 7:37 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
>>> 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
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
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.