Skip to Content
avatar image
Former Member

Doubt on mapping

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 19, 2015 at 10:59 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 19, 2015 at 10:52 AM

    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-ddecf098f724?overridelayout=t…?

    Your logic can be done easily with SAP standard functions, to do an UDF is not the best choice.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded