on 02-20-2009 5:04 AM
Hi All,
I have two different segments(VOL1 & VOL2) at same level on source side.
Say first segment repeats two times and second segment repeat three times.
I need to produce a single queue having combined occurences of these two segments which has five occurences in a single queue.
Please provide inputs how to achieve this.
Thanks,
Marz
Hi,
This is not possible without using UDF. What you can do is to use a mapping like this:
All UDF's must be of Context type, the simplified version would be:
VOL1 --> removeContext --> UDF1 --> concat: / --> UDF2 --> Target
VOL2 --> removeContext --> UDF1 -
> /
UDF1 is a UDF that concats all values of VOL1 or VOL2, while UDF2 is a UDF that splits the combined values of VOL1 and VOL2 that has undergone the transformation
For UDF1, you can use this code: input argument is a
StringBuffer e = new StringBuffer();
String b = null;
for (int i=0;i<a.length;i+){e = e.append("/"a<i>);}
b = e.toString();
b = b.substring(1,b.length());
result.addValue(b);
For UDF2, you can use this code: input argument is input
String b[] = input[0].split("/");
for (int a=0;a<b.length;a++){result.addValue(b[a]);}
Hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
Please remove a little doubt with a UDF here
I need to check if value returned after concatenation contains only ('/////')
I need to use
String b[] = input[0].split(""); in second UDF
else
I need to use String b[] = input[0].split("/"); in second UDF
Could you please help with this? Is there any standard function which can check all values within a field for (/) ?
Thanks,
Marz
Mark,
Say first segment repeat 2 times & 2nd segment repeat 3 times,then concatenation after above written 1st UDF will give value as [/////].
But if first segment repeat 2 times & 2nd segment repeat 3 times, and fields of these segments will be having some values, if I apply same UDF to fields instead of segments level, then concatenation after above written 1st UDF will give value as [/abc/abc/abc/abc/abc].
Now I need to ensure that, when I recieve value in format [/////], I should split it on basis of String b[] = input[0].split("") i.e blank space as seperator.
But if I recieve value in format [/abc/abc/abc/abc/abc], i should split it on basis of String b[] = input[0].split("/") i.e '/" as seperator.
Hope I am able to put it clear.
Thanks,
Marz
Hi Marz,
Just edit the code for UDF1 to this:
StringBuffer e = new StringBuffer();
String b = null;
for (int i=0;i<a.length;i+){e = e.append("/"a<i> + " ");}
b = e.toString();
b = b.substring(1,b.length());
result.addValue(b);
This should be able to handle the blank inputs. Basically, I just added a space so that should the inputs be blank, it will still have a value.
Hope this helps,
Regards,
Hi,
Please do the following mapping
Vol1 -- copyValue[0]- Target
Vol1 -- copyValue[1]- Target
Vol2 -- copyValue[0]- Target
Vol2 -- copyValue[1]- Target
Vol2-- copyValue[2]- Target
Provided the Taget has to be duplicated 5 times.
Thanks,
Kiran
Edited by: Kiran on Feb 23, 2009 9:28 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you really want to make sure that the target message contains the combined data from VOL1 and VOL2.
I would suggest to "duplicate subtree" in the Graphical mapper.
Vol_1 --> Target_1
Vol_1 --> Target_1
Vol_1 --> Target_1
Duplicate subtree (Target_1)
Vol_2 --> Target_1
Vol_2 --> Target_1
See SAP Help
http://help.sap.com/saphelp_nw04/helpdata/en/e8/a27440a3f0711de10000000a1550b0/frameset.htm
GReets
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Marz,
CAn you please provide some example data.
The problem is not quite clear to me.
Greets
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Check if there is any common field btw the two segments VOL1 and VOL2.
If yes, set its context to the header(which contains VOL1 and VOL2 segments).
sourcefield(with header context) -> count-> Target.. gives the number of occurrances of both the segments.
or,
sourcefield(default context) -> remove contexts->... gives all the occurances of the field in both the segments on a single queue.
Just try whether, the above suits your requirement.
Regards,
Swetha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Rajeev/Swetha for inputs,
But this willn't work as it will give right output only when a single same segment repeat multiple times.
But for my case, there are two different segments, but both of which are at same level just under Message type name(means default and only context will be message type name).
For my structure, at top level ,I have a message type name under which i have two different segments (Balance Records) and (Total Records) both at same level. Both of these segments can repeat multiple times.
Now I need to count combine occurences of both of these differernt segments at runtime and produce a target segment corresonding to combined occurences of these two.
Please provide help for achieveing this.
Thanks,
Marz
Marz,
If I understand your requirement correctly, you should use the 'duplicate subtree' option on the target segment (right-click the segment in the target message structure, select 'duplicate subtree'). You then use the first occurrence of the segment to map values from VOL1, and the second to map values from VOL2:
[VOL1] ------ [TARGETSEGMENT]
[VOL2] ------ [TARGETSEGMENT]
Kind regards,
Koen
Hi,
take any field of VOL1 segment and set its context to the Header node under which VOL1 and VOL2 are present..........then using exists and creatIf function, you can generate your target node.
Regards,
Rajeev Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.