on 2020 Apr 16 7:51 AM
Dear Experts,
I need to replicate the root node based on the value in one of the fields, please suggest if there is any option to achieve it using graphical mapping.
Input XML:
<example_MT><Records>
</Records></example_MT>
If value of count is more than 1, as it is in above example, it should create target nodes with the count value as below:
<example_MT><Records>
</Records>
<Records>
</Records>
<Records>
</Records></example_MT>
Thanks,
Sudhir
Finally I was able to get the required result. Initially I was trying to do everything at the record level, which could be confusing with changing context at every level. Now I'm using the same UDF at both Record and field level.
UDF:
Execution Type: All values of queue
Two arguments: Var1: String, Var2: Integer
for(int i=0;i<var1.length;i++)
{ for(int j=0;j<var2[i];j++)
{ result.addValue(var1[i]);
}
}
Record level Mapping:
Pass "Records" as first argument and "Count(data type: Integer)" as second argument, will create the correct output structure.
Field level Mapping:
Pass "field1" as first argument and "Count" as second argument, then pass the output of this UDF with Node function "SplitByValue(each value)" It'll populate the correct value in the output structure.
Same has to be done for all other fields.
Regards,
Sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think this isn't possible with the standard modules of a graphical mapping. So from my understanding you should write an UDF with two input. First input is the field to be mulitplied, the second input is the counter value. Then just loop as often as counter tells and place the input value each loop-run into the result queue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't want to be harsh, but this UDF isn't that hard to write and I won't make your job for you. If you don't know how to write a UDF start with reading some SAP Blogs about UDFs. If you struggle or have a specific problem when writing the UDF you can write a new question here on answers.sap.com. But you should try it yourself, because its you getting the salary for writing the UDF not we the SAP community members...
Hi Raffael!
I guess that your comment ought to be used as default automatic answer for every question like: "please provide the code...".
Regards, Evgeniy.
Raffael, I'm already trying my piece of code is not providing the exact output that I need, that is why have asked if some one can help. Your salary argument is bizarre, ideally then you shouldn't help anyone because all of them are getting paid from somewhere else. I don't want to be too harsh, but stay way from providing any help, after all you're not getting paid for it.
Hi Sudhir,
I really like to help other people, if I see that they at least tried it. But there are quite often people asking for a ready-to-go solution without even having tried. They really just want that someone does their work. And that's definitely not ok. From your question "Thanks Raffael, can you please help share the UDF which can provide similar output." in which you were asking for a complete UDF one couldn't see that you even tried it. Even now it's still unclear what is not working in your UDF or whats the problem. So instead of blaming me, why not just open a new question here, with the specific problem of your UDF. Provide the code you have written for now and I'm sure you will immediately find someone that have a look at your problem.
User | Count |
---|---|
70 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.