on 10-02-2008 3:07 AM
hey folks
I am looking for a java udf for :
Source:
TEXT
msg : aaaaaccccc
TEXT
msg : bbbbb
TEXT
msg : dddddeeeeeggggg
Here TEXT is a repeating segment in a file.Basically there is no limit on the length of msg which can come in msg field.
Target tructure is an IDOC : E1EDPL35 segment repeats but needs to be formed multiple times if msg has more than 5 chars.Since target GBL can only hav 5 chars as maximum length.So basically we need to create multiple E1EDPL35 if it exceeds the 5 chars limit.
E1EDPL35
GBL: aaaaa
E1EPL35
GBL:ccccc
E1EDPL35
GBL :bbbbb
E1EDPL35
GBL : ddddd
E1EDPL35
GBL : eeeee
E1EDPL35
GBL : ggggg
So basically in target structure : E1EDPL35 repeats ,and it needs to be split up after 5 chars. So a new E1EDPL35 will be formed after 5 chars in GBL .
The java udf should be like a context function to whom we pass an arrray of values and i am not sure whether 2 or one udf will be good for this functionality as segment needs to be created after 5 chars and the field should also be formed in new segment
Thnx
Edited by: xi project on Oct 2, 2008 4:33 AM
Is it possible or is it going to be a big challenge via XI . I am not really sure of the cpaabilities of XI.
Thnx
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
try to use this context UDF (with input a 😞
>int startIndex = 0;
>while (startIndex < a[0].length()) {
> if (startIndex < a[0].length() -5)
> result.addValue(a[0].substring(startIndex, startIndex + 5));
> else
> result.addValue(a[0].substring(startIndex, a[0].length()));
> startIndex += 5;
>}
Your mapping should look like this:
Source -> UDF -> E1EDPL35
Source -> UDF -> splitByValue -> GBL
Regards
Patrick
Hi,
sorry you are right (I tested it only for one source field)...
This should work now:
>int startIndex;
>for (int index = 0; index < a.length; index++) {
>startIndex = 0;
>while (startIndex < a\[index].length()) {
> if (startIndex < a\[index].length() -5)
> result.addValue(a\[index].substring(startIndex, startIndex + 5));
> else
> result.addValue(a\[index].substring(startIndex, a\[index].length()));
> startIndex += 5;
>}
>}
Use the same mapping as mentioned above and set the context to at least Text level.
Regards
Patrick
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.