on 03-19-2015 5:34 AM
Hi Experts,
We have below requirement,
Source structure:
<A>one</A>
Target Structure:
<Name>
<Id>
If A=one, hard code 'Roof' to Name, '123' to Id else if A=two, hard code 'Moon' to Name, '456' to Id else pass Null to Name and Id.
I need one UDF to achieve this, so that in single map window i can map name and Id.
We can achieve this using graphical mapping, but we want to try UDF since we need same logic in more than 5 mappings.
Appreciate your help on this. Thank you.
Hi Mohan,
If you really want to use UDF then use below.
public void mapNameAndID(String source, ResultList name, ResultList id, Container container)
throws StreamTransformationException {
if (source.equals("one")) {
name.addValue("Roof");
id.addValue("123");
} else if (source.equals("two")) {
name.addValue("Moon");
id.addValue("456");
} else {
name.addValue("null");
id.addValue("null");
}
}
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to wrap the inside a for loop.
Execution type : All values of context
Signature :
Argument : source
result : name
result : id
for( int i=0;i<source.length;i++)
{
if (source[i].equals("one")) {
name.addValue("Roof");
id.addValue("123");
}
else if (source[i].equals("two")) {
name.addValue("Moon");
id.addValue("456");
}
else {
name.addValue("null");
id.addValue("null");
}
}
Hi Mohan,
Have you thought to use mapping templates http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50171256-1ee2-2a10-3f84-ddecf098f...?
Your logic can be done easily with SAP standard functions, to do an UDF is not the best choice.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
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.