Skip to Content
avatar image
Former Member

Multiple Mapping Again

Source Structure1:<?xml version="1.0" encoding="UTF-8"?>

<E_Students> Occurrence 1...1

|----<Student> Occurrence 1...Unbounded

|----


<ID> Occurrence 1...1

|----


<Name> Occurrence 1...1

|----


<Gender> Occurrence 1...1

Source Structure2:

<?xml version="1.0" encoding="UTF-8"?>

<C_Students> Occurrence 1...1

|----<Student> Occurrence 1...Unbounded

|----


<Index> Occurrence 1...1

|----


<Name> Occurrence 1...1

|----


<Sex> Occurrence 1...1

Target Structure:

<?xml version="1.0" encoding="UTF-8"?>

<Students> Occurrence 1...1

|----<Student> Occurrence 1...Unbounded

|----


<ID> Occurrence 1...1

|----


<Name> Occurrence 1...1

|----


<Gender> Occurrence 1...1

For my issue, I want to map E_Students.student.id to Students.student.id, E_Students.student.Name to Students.student.Name, but with a rule that if E_Students.student.Gender has value, map this value to Students.student.Gender, otherwise map C_Students.student.Sex to Students.student.Gender with the condition that if the value of C_Students.student.Index is the same as E_Students.student.ID. what's more, there is no guaranted ordering between these two source xml.

in my true scenario, these three xml structure is very big, and just have several elements need mapping rule like "Gender" element. who can provide me any mapping solution? hope from your help:)

Message was edited by: Spring Tang

Message was edited by: Spring Tang

Specify that there are no predefined order in these two source xml files.

Message was edited by: Spring Tang

change C_Students.student.ID to C_Students.student.Index

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 20, 2006 at 04:55 AM

    Hi,

    Assumption only either of sex or gender exists for a given id ...

    try this

    ID(context E_Students)----


    |

    Index(context C_Students)----


    | createGender SplitbyValueGender

    Gender(context C_Students)CollapseContext|

    Sex (context E_Students)--CollapseContext|

    Here createGender is a UDF:

    <b>

    public void createGender(String[] ID,String[] C_ID,String[] Gender,String[] Sex,ResultList result,Container container)

    {

    int k=0, j=0;

    for (k=0;k<ID.length;k++)

    {

    for (j=0;j<C_ID.length;j++)

    {

    if (ID[k].equals(C_ID[j]))

    {

    if (!Gender[j].equals ("") )

    result.addValue(" "+Gender[j]);

    else

    result.addValue(" "+Sex[k]);

    }

    }

    }

    }</b>

    For ID and name do 1..1 mapping

    collapseContext and SplitbyValue are node functions.

    Regards

    Suraj

    Message was edited by: S.R.Suraj

    Was the problem solved???

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2006 at 04:32 AM

    Hi Spring,

    You can do it like this.During graphical mapping,

    use a ifelse function which is predefined and there, your condition should be like this,

    if E_Students.student.Gender <>(use notequal to function) a constant(specify space as ur constant) map it to Students.student.Gender else C_Students.student.Sex map this to Students.student.Gender

    Regards,

    abhy

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 20, 2006 at 04:33 AM

    very easy.

    write a small user defined function.

    ud:mapgend

    if (a!= null)

    return a;

    else

    return b;

    gender->a mapgend target field

    sex->b

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2006 at 04:46 AM

    Hi Spring,

    check if e_student.studnt.gender<>constant without any value

    then

    map

    e-student.student.gender-->students.student.gender

    else

    map

    c-student.student.sex-->students.student.gender

    other mappings r direct one to one mapping.

    regards

    jithesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2006 at 04:49 AM

    1.I have no constants here, for "gender" element, it is my sample.

    2. in one source xml structure, I used the gender, in the other source xml structure, I used sex. in these two source xml, maybe they are in no order.

    Hope from your help in detail.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Spring,

      The Steps to be done are as follows:

      - Drag the field E_Students.student.Gender

      - Select the standard function constant (and input a space as constant)

      - select the not equals function.

      - let the first 2 be the input to the not equals function.

      - Drag the field C_Students.student.Sex

      - then select the ifelse function

      - let output from not equals and the C_Students.student.Sex be input for the ifesle function.

      - let the out of the ifelse be Students.student.Gender

      Now you will get the desired output.

      Pls see this link which explains a similar scenario with a screen shot.

      http://help.sap.com/saphelp_nw04/helpdata/en/5d/db0e83e8e74202a5bff527055ab7e5/content.htm

      Regards,

      abhy

  • Mar 20, 2006 at 05:42 AM

    Hi Spring,

    Have you tried the approach I have given and does it work?it z most simple way.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi, Sravya Talanki

      there are no guranteed order between these two source xmls, I have some doubts for your suggestion.

      Message was edited by: Spring Tang

      Message was edited by: Spring Tang

  • avatar image
    Former Member
    Mar 20, 2006 at 05:49 AM

    Hi,

    E_Students.Student-->Students.Student

    E_Students.ID >SORT >SplitByValue-->Students.ID

    (Context of ID IS E_Students)

    E_Students.ID------\

    -


    |SORT >SplitByValue >Students.Name

    E_Students.Name--/

    (Context of ID and Name IS E_Students)

    Note: E_Students.ID is refered as ID1 and C_Students.ID as ID2

    (Context of ID1 IS E_Students)

    (Context of ID2 IS c_Students)

    (Context of Gender IS Student)

    (Context of Sex IS Student)

    ID1----


    \

    -


    |SortByKey >splitbyvalue \

    Gender-->colapseContext-/

    -


    |stringequals >not >if

    -


    constanst("")-/

    ID1----


    \

    -


    |SortByKey >splitbyvalue \then

    Gender-->colapseContext-/

    ID2----


    \

    -


    |SortByKey >splitbyvalue \else

    sex-->colapseContext-/

    Regards,

    KNS Kumar.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,Kumar.

      Maybe your solution is right. but my xml schema is very large, I don't want to add sortbyKey at every mapping. I hope more convenient way. Thanks anyway:)

      Message was edited by: Spring Tang