on 02-15-2010 10:34 AM
Hi All,
My scenario is soap to Idoc
Source structure:
Details 0......n
............. Name 1-1
Target structure:
Ztest 0.....1
............ FieldA 0-1
............ FieldB 0-1
............ Fieldc 0-1
............ FieldD 0-1
............ FieldE 0-1
............ FieldF 0-1
............ FieldG 0-1
............ FieldH 0-1
............ FieldI 0-1
My requirement is that ,I have to map the sender field to multiple fields in the target,say when the sender occurs for the first time the value should get posted to First field of the target and it so on.
I tried as,
Name----->mapWithDefault>CopyValue(position 0)-->FieldA
Name----->mapWithDefault>CopyValue(position 1)-->FieldB and so on.....
But here copy value expects value and it is throwing error when the field is not present.
Please suggest me on this.
Thanks in Advance,
Lavanya.B
Hi Lavanya,
How can Name not be there? It is a mandatory field isn't it(As per your definition)?
And more over, you are using mapWithDefault, so copyValue will always get a value.
What is the error that you get?
Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear All,
Issue is solved.
Solution:
Name->Removecontext->Count->Greater-> If
Constant(0) -> FieldA
Copyvalue-> Then
Thanks all for the valuable suggestions.
Regards,
Lavanya.B
Edited by: Lavanya Balanandham on Mar 4, 2010 3:46 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lavanya,
U can easily achive this by a simple UDF.
Type:
All Values of queue.
Input:Position,Name,container,result.
Output:Void
-
try
{
result.addValue(Name [Position] );// this is in brackets [, Position
}
catch(Exception e)
{
result.addValue("");
}
-
Now the input to UDF are...
when u r mapping to first element FieldA 0-1
then...
0(1-1=0)
Name(Change the context to top)
UDF FieldA 0-1
In the same way for mapping FieldB 0-1
then
1
Name(Change the context to top)
UDF FieldA 0-1
I hope this will solve ur problem.
If still not, pl do post
Babu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lavanya,
What I understood from your requirement is:
If the Details node repeats, then each detail will have a single node NAME, now you need to map this NAME field to corresponding target field depending on its occurance i.e. say if its first name then to Field A, if second then to Field B and so on.
Please tell if waht I understood is correct.
My doubt is that are you sure that the Details field will occur maximum of 9 times only. Cos if it can occur more than that then what you want to do.
Also if I understood correctly then use a UDF(queue) with two arguments: 1. Names with collapse context (a[]).
2. Constant count of the target node (b[]) i.e say FieldA=1, FieldB=2 and so on.
Code inside UDF:
if(a.lenght>(Integer.parseInt(b[0])-1))
{result.addValue(a[Integer.parseInt(b[0])-1]);}
Edited by: rahul grover on Feb 16, 2010 10:56 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lavanya,
If your target is fixed, (Only 9 fields) and your source cannot have more than 9 occurances of Name, then you have to use Index function .
First use mapwith default for your Name field.
Then use removecontexts.
Then check the index of that field, using Index function (Statistical function).
Check if that equalS "1" (for the first time), if true, then map it to the target.
Name ->mapWithDefault ->removeContexts->index
\
equalS-> ifwithoutElse -> fieldA
1/ Name /
Regards,
Ravi Kanth Talagana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
USE Node Function EXISTS Function in the mapping, if the field is not there, it will not give you error.
Name -
> exists > mapWith Default -
Name-------> exists > mapWithDefault>CopyValue(position 1)-->FieldB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Couldn't really make out why you are using copyValue here.
Simply putting mapWithDefault would suffice.
This way if Name value comes it will be posted else the constant value that's used in mapWithDefault will be passed.
Regards
Soumen...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi SoumenDas,
Let me explain in detail,say example the source node executes for 5 times with the values of A,B,C,D,E then the first value A should get posted to the first field of target and second field value of source to the second field of target,ie
Sender Values: Receiver
name(first time occurance) A FieldA
name(Second time occurance) B FieldB
name(Third time occurance) C FieldC
name(Fourth time occurance) D FieldD
name(fifth time occurance) E FieldE
Lavanya.B
Hi Lavanya,
Source structure:
Details 0......n
->Name 1-1
Target structure:
Ztest 0.....1
->FieldA 0-1
->FieldB 0-1
->Fieldc 0-1
->FieldD 0-1
->FieldE 0-1
->FieldF 0-1
->FieldG 0-1
->FieldH 0-1
->FieldI 0-1
If i understood your problem correctly then you have target fields (A to I) and one source field (with 0 to n occurrence).
Now there can be three cases:
1. Source Details (and hence Name) occurs 9 time
your logic as you mentioned in the query will work
2. Source Details occurrence is less than target field (say source comes 3 times and the required value was 9). But in this case how you will know that the three value for source are for position say 1, 4 and 7. If this is required then there need to be a change in the source structure itself ELSE (we nee to make a logic out of this)
3. Source Details occurrence is more than target field (say source comes 15 times and the required value was 9). What will be the mapping logic in this case.
Try answering my question we can see if some one is able to provide you a logic. Please be precise and clear with your replies
Regards
Suraj
Dear Suraj,
My requirement is that ,let me take your example,
If source node executes more than 9times say 15times then the target field needs only the first 9 values and remaining to be ignored.
If source node executes only for 4 times ,then the values will be mapped to the first four target fields and remaining could be ignored or an empty string value could be passed to the remaining 5 fields.
Thanks&Regards,
Lavanya .B
Hi Suraj,
I tried as u stated.It is working fine until the source node execution is equal to the number of times the copy value function is assigned,i.e ,say if the copy value function is mapped to 9 fields and if the source node executes only for 4 times then while executing ,I am getting an error like ,"Insufficient number of values in argument queue for function CopyValue. Value with index '5' not found".
Regards,
Lavanya.B
Hi Lavanya,
Ok, try this:
Name-->removecontext->collapsecontext->Ztest
Name>removecontext>|copyvalue_udf->FieldA
Constant(0)---->|
for each target field increase the value of constant, ie FieldB will have Constant (1) and so on.
Now the copyvalue_udf code will be
int current_node = Integer.parseInt(i);
if (current_node <= input.length)
result.addValue(input<i>);
else result.addValue("");
This udf will be an advanced udf with two input variables namely input and i. Also it will be for all values in a queue
Regards
Suraj
--useOneAsMany standard function should be implemented in your case.
Many blogs are available for the same (and even exmaple on help.sap.com), so just make a search and get the required details.--
Update:
Ignore above logic....didnt read the full question
in mapWithDefault what value are you passing? When the Name node is not present then nothing seems to be passing through the queue...can you check what your queue (right-click--> Display queue) has to say.
And if not wrong Name will have an occurence only when its parent node is occuring....if it si not occuring the even Name will not occur.
Regards,
Abhishek.
Edited by: abhishek salvi on Feb 15, 2010 4:16 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.