on 02-22-2010 10:57 AM
Hello Friends,
I need to do a mapping where description ( text ) need to be mapped to Idoc-field TDLINE. Tdline has a size around 132 char. And description from source can be longer than 132 charter...
e.g:
Source Message
-
<Product>
<Description>will be the special instructions information required for
the shop floor that the planner may have added..
</Description>
</Product>
Target Message
<IDocSegment>
<TDLINE>will be the special instructions</TDLINE>
<TDFormat> * </TDFormat>
</IDocSegment>
<IDocSegment>
<TDLINE>information required for the shop floor</TDLINE>
<TDFormat> * </TDFormat>
</IDocSegment>
<IDocSegment>
<TDLINE>that the planner may have added..</TDLINE>
<TDFormat> * </TDFormat>
</IDocSegment>
How I can achieve this ? do I need to create a java function or so ?
please suggest...
Hi Shah,
Yes you need to have a java udf to do this. Try using this code
This an advanced udf for all values of the queue
public void RemarkSplit(String[] input, ResultList result, Container container) throws StreamTransformationException{
int i = 0;
int start = 0;
int end = 0;
int var = 0;
int empty = 0;
AbstractTrace trace;
trace = container.getTrace();
//loop through entire values in input array
for (int j=0; j<input.length; j++) {
if (input[j].length() == 0) {
result.addValue(" ");
}
else {
//repeat for the length of each value
for (i=0;i<input[j].length(); i=i+132){
start =i;
end =i+132;
if (input[j].length( )> end) {
result.addValue(input[j].substring(start,end));
}
if (!(input[j].length()==0)){
if (end >= input[j].length()) {
end = end -132;
result.addValue( input[j].substring(end,input[j].length()));
}
}
}
}
}
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shah,
>>Thanks Sven for your reply , can you please suggest how I can dublicate the segment with in UDF ?
For duplicating the parent node you need to use the same udf code with the parent node.
The code which I wrote might need some changes (which you can do by providing different length input and checking the display queue of the udf)
Regards
Suraj
Hi Shah,
One way to get the segment E1EDKT2.repeated is
input (132 length field) > UDF (the code which I wrote)> splitbyValue (for each Value)--> E1EDKT2
>>I searched the fourm and did not get an example which explains HOW to dublicate the node usin
Rather than searching SDN, these things should be done at your end to get a satisfactory output result
Regards
Suraj
When XI evalutes how many target nodes it needs to create it looks at the resultList that your UDF creates and replicates
the target nodes according to the number of values in your resultList. So when you have n values in your resultList
XI is going to create n repetitions of your target segment (as long as your cardinality is 0..unbounded/99999999).
e.g., create an UDF that populates your resultList with three empty strings
result.addValue("");
result.addValue("");
result.addValue("");
mapped to a target nodes with cardinality of 0..999999 will create the node 3 times.
is it possible to dynamically duplicate the segment of Idoc ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
TDLINE is 0..1 so you can only have 1 per E1EDKT2.
E1EDKT2 cardinality is 0..9999999999 so you need to come up with an UDF that splits your string into
132 char chunks and passes these to the resultList. If you map the UDF to E1EDKT2 it should replicate
your segment as many times as you need it (# of 132char chunks).
Then map your UDF to TDLINE for the text itself.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
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.