on 04-05-2006 9:47 PM - last edited on 02-03-2024 8:53 PM by postmig_api_4
All,
Hope one of you can help me with this. I have a structure with over 15 fields and would like to concatenate all the fields into one target field and while I do this, I need to ensure that each field is padded with blanks as defined the data type. Can one of tell me if this is possible with a java user-defined function and if so, what type of logic is needed.
Input_MT
Field_1 string len=10 "need"
Field_2 string len=6 "java"
Field_3 string len=7 "help"
Field_4 string len=8 "asap"
etc,
Output_MT
DataOut string "need java help asap "
(for some reason the exact spaces in between the words disappear in my Preview message)
I have several fields in the input mt and therefore I find graphical mapping using concatenate and my own user defined function padWithSpace too messy.
Thank you for you help.
Hi Parimala,
I guess this should work.
For Example:
If Length of the field is 15,
String m1 = "<Spaces for length of the field (15)>".substring(0,15-a.trim().length()).concat(a.trim());
Like this do it for all the fields(m2, m3, m4..) and concatenate all the fields.
m1 = m1m2m3...
Regards,
Dhana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I hope following blog will help you.
/people/sravya.talanki2/blog/2005/12/06/limitations-of-message-mapping-editor-in-xi-can-we-make-it-user-friendlier
-Kavita Laddha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for all the replies.
I followed the blog carefully and I've used some node functions before. But how can I access all the fields of a given node. Once I get there, I can pad my elements with spaces....however, I will need to know the element max length size (?) which might end up being another dilemma.
In the blog, I don't see an specific node function that gives visibility to all fields.
Any help....I appreciate all you assistance.
Hi Parimala,
Store the input fields in a string array. Then using a for loop append a " " to each of the fields.
Hope this would help u.
Regards,
-Naveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If your final req is to write all these fields next each other in a file, you can configure this in receiver file adapter by specifying the fixed length for each field.
If you want the padded string as your MM o/p, you can create a simple user defined funtion with 15 fields as input and 15 constants for their lengths, and find out the length of the each string and pad it with required no of spaces.
int max_len = 10;
int actual_len;
actual_len = a.lengh();
for(int i=0; i < (max_len-actual_len; i++)
a = a.append(" ");
return a;
praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.