on 2005 Apr 13 1:49 PM
Hi,
I have a case where we receive a file with the following structure:
<ORDERS01>
<ORDERS03>
...
<ORDERS04>
...
<ORDERS02>
<ORDERS05>
...
where
<ORDERS01> = (Header info. for the order)
<ORDERS03> = (Header Texts for the order,
one textline/segment.This means
that we could have one
or many ORDERS03 segments)
<ORDERS04> = (Also Header Texts for the order,
one textline/segment.This means
that we could have one
or many ORDERS04 segments)
<ORDERS02> = (Items for the order)
<ORDERS05> = (Item texts for the order,
one textline/segment.This means
that we could have one
or many ORDERS05 segments)
The thing is that lets say we have 4 <ORDERS03> segments
with 1 row of text in each segment. All these 4 texlines should then be mapped to a E1EDKT1 segment with a certain textid. At the moment Iam only able to get the first occurance of the <ORDERS03> segment to be mapped to the E1EDKT1 segment.
Any suggestions of how to best solve this issue?
Kind regards,
Fredrik
Hi,
Could you please let us know what mapping you are using?
In message map, you can define a user-defined function to take all the <ORDERS03> segment. Inside the loop, you can concat the values of header text and then finally map it to the E1EDKT1 segment. You should set the Queue Context properly to the correct level of the message.
It will be easy if your mapping is in XSLT.
I did a similar mapping, not using XI, but in another middleware tool, where I had a standard function to extract all the data of a particular segment.
Thanks,
Sasikumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Iam using message map, so the approach with defining a user defined function feels at the moment best. I have not done that much java programing, anyone who has a suggestion of how such a function could look like.
Basically the function should loop thru all <ORDERS03> segments and concatenate all NTTEXT's together and export the concatenated full text which then is mapped to the field.
Anyone who could give me an idea what the function could look like.
Kind regards,
Fredrik
Hi Fredrik,
In the message map, create a advance user defined function, say for example, getNTText() with one argument, an use the following code,
-
String NTText = "";
for(int i=0;i<a.length;i++)
{
NTText = NTText + a<i>;
}
result.addValue(NTText);
-
And pass the <NTText> segment as input argument. Make sure you set the queue context to root of <ORDERS03>.
Hope it helps!!
Thanks,
Sasi
Hi Sasi,
Thanks a lot for your kind help. I tried the code but it
did not work completely. The output was concatenated but the values were a little bit strange,
[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598[Ljava.lang.String;@1f4d598
and the input texts were,
[This is free header text line 01 that can up to 80 characters long and continues]
[This is free header text line 02 that can up to 80 characters long and continues]
[This is free header text line 03 that can up to 80 characters long and continues]
[This is free header text line 04 that can up to 80 characters long and continues]
[This is free header text line 05 that can up to 80 characters long and continues]
[This is free header text line 06 that can up to 80 characters long and continues]
[This is free header text line 07 that can up to 80 characters long and continues]
[This is free header text line 08 that can up to 80 characters long and continues]
What do you think?
Kind regards,
Fredrik
Hi,
Its better to use StringBuffer instead of String directly for appending your text values.
String buffers are used by the compiler to implement the binary string concatenation operator +.
For example, the code:
String x = "a" + 4 + "c"
is compiled to the equivalent of:
String x = new StringBuffer().append("a").append(4).append("c").toString()
which creates a new string buffer (initially empty), appends the string representation of each operand to the string buffer in turn, and then converts the contents of the string buffer to a string. Overall, this avoids creating many temporary strings and improves performace.
Thanks,
Sasi
Thanks all for your valuable input. I will now elaborate a little bit more with your different contributions and get back with feedback of the outcome.
Kind regards, Fredrik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fredrik,
If I understand you correct you want also 4 occurences for the E1EDKT1 segment. Then you have to make sure that this segment is created 4 times. In this case you can map the <ORDERS03> element to <E1EDKT1> element. So if the occurence of <ORDERS03> element is 4, so will the <E1EDKT1> element.
Cheers,
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fredrik,
it's easy to solve with XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:for-each select="//ORDERS01/*">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards, Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
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.