on 12-22-2010 4:34 PM
Hi folks,
I am working on file to idoc
My input file has 1 field and output Idoc has 5 records.
in my input Account field has length 16. in this length 16. this field is mapping to all the fields of output.
for example account field has 1234 67 86 34 33. I need to map 1234 to field 1
67 to field 2
86 to field 3
34 to filed 4
33 to field 5.
for every space we need to split and need to map output field. after completing this I need to sort the field 1 of output. please explain me. Account data may very
examples input file :
1238 67 86 34 33
1234 66 86 34 33
need output as 1234 67 86 34 33
1238 66 86 34 33
here only first field is sorted i.e 1234 and 1238 ....remainiing fields need to be same
ur help is highly appreciated.
Thanks,
enivass
Hi,
Since you can have spaces any where in the file/field, use "String Tokenizer" concept, you will not need java mapping, you can use graphical mapping and write UDF by selecting "All values of the Queue/Context"
Here are some useful links:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
http://www.javafaq.nu/java-example-code-195.html
http://www.devdaily.com/java/edu/pj/pj010006/ - Concept
http://download-llnw.oracle.com/javase/1.4.2/docs/api/java/util/StringTokenizer.html - Concept
http://www.java-examples.com/java-stringtokenizer---specify-delimiter-example - with Delimiter
Regards,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for example account field has 1234 67 86 34 33. I need to map 1234 to field 1
67 to field 2
86 to field 3
34 to filed 4
33 to field 5.
Can achieve this without UDF also
Source --> replaceString (replace space so that you now have 123467863433) --> Substring (0,3) --> Field1
Change the value of start and end position in substring and map it to the respective target fields.
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As of I know there is no list objects in UDF. so you might have to do java mapping for this case.
You have to basically create a string array using java StringTokenizer class. Once you create the array of string you can assign those values to the target fields.
// Insert the below code in your java mapping
This code does for you
String[] output;
StringTokenizer Token = new StringTokenizer("Your input string goes here");
int count=0;
while (Token.hasMoreElements()){
output [count++] = (String)Token.nextElement();
}
// After creating string array you can assign like this to the target fields
output[0] = field1
output[1] = field2
...
...
output[5] = field6
Note: Add square bracket before and after count variable in the while block. This editor removing it.
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.