cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Issue

former_member182412
Active Contributor
0 Kudos

Hi Experts,

I am doing IDOC to JDBC scenario, My IDOC is ISU_DL_NOTIF, with in this idoc there is nod called E1ISU_NOT_TASK, this node is 1 to unbounded, so multiple nodes are coming from ISU, but i need to take the last node and map it to database table field, because databse side they dont need all the values coming from ISU.

can anyone please suggest me how to map the last node value to database field.

Kind Regards,

Praveen.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

you can use and UDF


String res = "";

if (list.length() > 0) {
 res =  list[list.length()-1];
}
else {
 res ="";
}
result.addValue(res);

former_member182412
Active Contributor
0 Kudos

Hi

in my source message The node E1ISU_NOT_TASK occurs four times.

<E1ISU_NOT_TASK SEGMENT="1">

<MNKAT>2</MNKAT>

<MNGRP>ZNEWCON2</MNGRP>

<MNCOD>Z1</MNCOD>

</E1ISU_NOT_TASK>

<E1ISU_NOT_TASK SEGMENT="1">

<MNKAT>2</MNKAT>

<MNGRP>ZNEWCON2</MNGRP>

<MNCOD>Z103</MNCOD>

</E1ISU_NOT_TASK>

<E1ISU_NOT_TASK SEGMENT="1">

<MNKAT>2</MNKAT>

<MNGRP>ZNEWCON2</MNGRP>

<MNCOD>Z1</MNCOD>

</E1ISU_NOT_TASK>

<E1ISU_NOT_TASK SEGMENT="1">

<MNKAT>2</MNKAT>

<MNGRP>ZNEWCON2</MNGRP>

<MNCOD>Z105</MNCOD>

</E1ISU_NOT_TASK>

I need to take the last occurance of E1ISU_NOT_TASK node and i need to take the MNCOD value(Z105) and map it to target field (TASK_CODE) of database.

Can anyone suggest me how can i do this requirement????

Edited by: Praveen Kumar on Aug 31, 2009 8:51 AM

Former Member
0 Kudos

Hi,

Refer any of the above code and create the UDFs, then you need to map it with all the fields

E1ISU_NOT_TASK --> TestUDF -->

<MNKAT> ---> TestUDF -->

<MNGRP> ---> TestUDF -->

<MNCOD> ---> TestUDF -->

PS note : May be based on context change you need to RemoveContext/SplitBy value APIs along with TestUDF.

Thanks

Swarup

former_member182412
Active Contributor
0 Kudos

Hi

I am getting this error when i use those UDF

/usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapf85b5220960911deb28200144f2b5900/source/com/sap/xi/tf/_MM_SAPIsuToJW_NewConnection_.java:139: cannot resolve symbol symbol : method length () location: class java.lang.String[] if(a.length() > 0)

/usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapf85b5220960911deb28200144f2b5900/source/com/sap/xi/tf/_MM_SAPIsuToJW_NewConnection_.java:140: cannot resolve symbol symbol : method length () location: class java.lang.String[] result.addValue(a[a.length() -1]); ^ 2 errors

Can anyone suggest me what was the problem?????

jyothi_anagani
Active Contributor
0 Kudos

Hi Praveen,

cannot resolve symbol symbol : method length () location: class java.lang.String[] if(a.length() > 0)

Remove () after length...Length is not a method..It is a variable...Use length only

Thanks.

Former Member
0 Kudos

Hi,

Use below modified code (I have removed "()")



if(a.length > 0)
 result.addValue(a[a.length-1]);

Thanks

Swarup

Answers (2)

Answers (2)

Former Member
0 Kudos

use


MNCOD--->removeContext-->UDF....>TASK_CODE

UDF choose context while creating the UDF


 result.addValue(a[a.length-1]);

Former Member
0 Kudos

Hi,

You can use the following UDF to take only the last value.


if(a.length() > 0)
 result.addValue(a[a.length()-1]);

Use that in your message mapping.

Regards

Ivan