cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Problem with JDBC Adapter

Former Member
0 Kudos

Now we have the following data type


   <head_line>
      <A>1</A>
      <B>2</B>
   </head_line>
   <line_item>
      <C>3</C>
      <D>4</D>
   </line_item>
   <line_item>
      <C>5</C>
      <D>6</D>
   </line_item>

We want to seperate the head line and the line item in database tables, so we hope that we can get the following structure after mapping:


<STMT1>
  <dbtable>
    <table>Table_Name</table>
	  <access>
	    <A>1</A>
	    <B>2</B>
	  </access>
  </dbtable>
</STMT1>
<STMT2>
  <dbtable>
    <table>Table_Name</table>
	<access>
	  <A>1</A>
	  <B>2</B>
	  <C>3</C>
	  <D>4</D>
	</access>
  </dbtable>
<STMT2>
  <dbtable>
    <table>Table_Name</table>
	<access>
	  <A>1</A>
	  <B>2</B>
	  <C>5</C>
	  <D>6</D>
	</access>
  </dbtable>

but the mapping test continue giving us the error

"14:32:22 Start of test

Compilation of MM_TEST successful Cannot produce target element /ns0:MT_STMT/STMT2[2]/dbtable/access/A. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd Cannot produce target element /ns0:MT_STMT/STMT2[2]/dbtable/access/A. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd

14:32:23 End of test"

here's the mapping text:

/ns0:MT_STMT=/ns0:MT_TEST=

/ns0:MT_STMT/STMT1=/ns0:MT_TEST/head_line=

/ns0:MT_STMT/STMT1/dbtable/table=const([value=Table_Name])

/ns0:MT_STMT/STMT1/dbtable/access/A=/ns0:MT_TEST/head_line/A=

/ns0:MT_STMT/STMT1/dbtable/access/B=/ns0:MT_TEST/head_line/B=

/ns0:MT_STMT/STMT2=/ns0:MT_TEST/line_item=

/ns0:MT_STMT/STMT2/dbtable/table=const([value=Table_Name])

/ns0:MT_STMT/STMT2/dbtable/access/A=/ns0:MT_TEST/head_line/A=

/ns0:MT_STMT/STMT2/dbtable/access/B=/ns0:MT_TEST/head_line/B=

/ns0:MT_STMT/STMT2/dbtable/access/C=/ns0:MT_TEST/line_item/C=

/ns0:MT_STMT/STMT2/dbtable/access/D=/ns0:MT_TEST/line_item/D=

Message was edited by:

YiNing Mao

Accepted Solutions (1)

Accepted Solutions (1)

prabhu_s2
Active Contributor
0 Kudos

go thru this blog:

Message Splitting Using the Graphical Mapping Tool

Former Member
0 Kudos

Well, Prabhu, it is a good blog. But this blog is trying to solve the problem when the target interface can only hold limited number of line item, and our interface doesn't have this limitation.

I think there might be an idea without message splitting. Any suggestion?

prabhu_s2
Active Contributor
0 Kudos

maybe check with udf. but again on what basis u want to split the records item wise?

Former Member
0 Kudos

No udf is used.

I just want to split the head line and line item, put them into different database tables so that we can save the space.

Former Member
0 Kudos

Hi ,

You are getting this error when you try to map fields A and B from header segment to access in target node . Do one thing either wirte UDF which will repeat A and B for the number fo occurances of line_item . Or the second option is use the function <i>useAsMany</i> to map A and B from Soruce to target . While using useAsMany function you would need to pass three parameters . First paramer give the field A with the context as Header .In Second sepcify the Line_item and in third Input also specify line_item and then map it to target access node's A field . repeat the same for B field .

Thanks ,

Suvarna

Award pts if it helps .

Answers (3)

Answers (3)

justin_santhanam
Active Contributor
0 Kudos

YiNing Mao,

As per your design, I assume that Header will come only once and Line items will come multiple times, isn't it. If my understanding is correct then please follow the below logic.

Please see the structure defined in the below URL

http://www.flickr.com/photo_zoom.gne?id=602255112&size=o

As per the structure defined in the above URL -( U have to duplicate the STMT Node)

<b>Logic for First STMT</b>

Constant[] -


>STMT[target]

Constant[Table-Name] -


>table[target]

A[source] -


> A[Target]

B[source] -


> B[Target]

<b>Logic for Second STMT</b>

line_item[source] -


> STMT[target] <b>refer</b> http://www.flickr.com/photo_zoom.gne?id=602255092&size=o

Constant[Table-Name] -


>table[target]

Mapping Target A -


>http://www.flickr.com/photo_zoom.gne?id=602255124&size=o

Mapping Target B -


>http://www.flickr.com/photo_zoom.gne?id=602255242&size=o

C[source] -


> C[Target]

D[source] -


> D[Target]

<b>Results.</b>

http://www.flickr.com/photo_zoom.gne?id=602255060&size=o

I defined the target as you gave in the thread, but don't forget to add action attribute for the <DBtable> node.

Fyr :http://help.sap.com/saphelp_nw70/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm

I hope it helps, if you have any doubt,reply.

Best regards,

raj.

Former Member
0 Kudos

Thanks for your explaining, guys. Especially, Raj. Your pics are great.

I found a way easier, use the removeContext standard function and it works.

prabhu_s2
Active Contributor
0 Kudos

mapping of STMT1 is one-one where are for STMT2 u may require to use UDF. In this case change the context of head_line and line_item popint to root node and using a udf coupled with context handeling u can have the strucutre framed for STMT2 as requried....

Former Member
0 Kudos

hi mao,

there seems a problem with context handling. iare the contexts rite?

For STMT2 use the following kind of mapping:

/ns0:Resultset_MT/Row/address=SplitByValue(concat(/ns0:PurchaseOrder_MT/Order/Item=, /ns0:PurchaseOrder_MT/Order/Header/Address=))

Here replace item with line_item and adress with A/B

vat we are doing here is :

you want A and B to occur as many times as line_item (for STMT2). so concat line_item and A (and B) then use split by value to insert context at relevant place.

hope it helps.

[reward if helpful]

regards,

latika.