cancel
Showing results for 
Search instead for 
Did you mean: 

Messager Mapping Question

Former Member
0 Kudos

My Source has tructure like this

Source 1..unbounded

stCode

product

cost

expDate

Target 1:unbounded

Division

product

cost

expDate

Basically I need to get Divisions for the given state Code. For each Division I should repeat target structure.

for example if Source has structure (<b>WA</b>,123,12.20,12/12/2006) I should create 4 target structures like ( <b>(001</b>,123,12,20,12/12/2006), (<b>002</b>,123,12,20,12/12/2006), (<b>003</b>,123,12,20,12/12/2006), (<b>004</b>,123,12,20,12/12/2006) )

Is these any standard function to achive this? Or do I have to write advanced user defined function? If UDF can you please explain how to achive this ?. Thanks a bunch in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

moorthy
Active Contributor
0 Kudos

<i>Basically I need to get Divisions for the given state Code. For each Division I should repeat target structure</i>.

>>>Is it for each statecode , you need to create multiple target structures or how?

How you will get know, how many divisons are there in the source side ?If your Statecode is able to provide this details, then , it is easy with java mapping

But you can try out with user defined functions also. But need to know, is it for each Statecode or based on statecode value etc..

hope this gives some hints

rdgs,

Moorthy

Former Member
0 Kudos

Hi Krishna Moorthy, thanks for quick response. I need to code in UDF as I know for each state there are fixed number of divisions. So StateCode will be input to UDF and should return multiple divisions.

I have to use advanced UDF right ?. So for the given state code I get multiple divisions out of the UDF. I have to use Context or Queues ?..Will you please guide me steps I need to take within UDF and after UDF returns values ?

moorthy
Active Contributor
0 Kudos

SO it is predetermined, that, for each state code, that many divisions. So you need to hardcode these values in the user defined like AB =4 , BC =5 etc...

So as per the given state code , you need to generate that many target structure right ?

yes, you need to use advanced UDF. to simplify, write a logic to get one target for each one records. Once you do this, then extend this logic with division no.s with condition

rgds,

Moorthy

Former Member
0 Kudos

If I understand your question correctly, you may want to check out my weblog on UDF + context changes. This will help you manipulate a target structure based on values from the source:

/people/harrison.holland5/blog/2006/12/08/mapping-context-changes-in-xi

Former Member
0 Kudos

UDF returns for example 4 divisions.

How can I map

StCode -


>(getDivision)------>Division

Where stCode is input and division is output of the function. But Since getdivision returns multiple values how can make multiple target structures ? UseOneasMany helps ?. Pl help me here.

Former Member
0 Kudos

Hey Ram,

Have a look at this weblog for UseOneAsMany function

/people/claus.wallacher/blog/2006/04/17/replication-of-nodes-using-the-graphical-mapping-tool

thanks

Former Member
0 Kudos

Harrison,

this is very close to what I might need. From your Blog I can use CreateContext to return multiple values from the Fucntion. I will map this to the element and node.

Do I still have to have 2nd UDF jumpContext to map remaining fields from Source to Target ?

Former Member
0 Kudos

No you do not for your scenario

Former Member
0 Kudos

I'm still having probelm.. Again

Source 1..unbounded

stCode 0..1

product 0..1

cost 0..1

expDate 0..1

Target 1:unbounded

Division 0..1

product 0..1

cost 0.1

expDate 0..1

UDF( Convert) takes StCode as Input and returns variable number of Divisions.

My Mapping as follows:

StCode -


> (Convert) -


> Target

StCode------> (Convert) -


> Division

product -


> Product

cost -


> cost

expDate -


> expDate

With the above mapping Target structure does not have the number of Divisions returned from UDF. It has only 1 node genrated.

I looked at DisplayQueue for Target Node and Division there are many divisions with context change. My Target Structure should look like 4 nodes as (001,123,12,20,12/12/2006), (002,123,12,20,12/12/2006), (003,123,12,20,12/12/2006), (004,123,12,20,12/12/2006)

WHat I'm doing wrong?. Can someone please explain ?

Former Member
0 Kudos

Hi,

Your target node Division has an occurence of 0..1.

Therefore you can have a maximum of 1 node created in the target.

Even if the queue shows the correct values, the target node that can be created is only one, and the remaining 3 values in the queue are ignored.

You could change the occurence of the target field 'Division' to 0..unb and you will get the expected result.

Regards,

Smitha.

Former Member
0 Kudos

Hi Smitha,

Target Node is 1..unbounded

Within this structure Individual fields are 0..1

Is it wrong ?

Please look at earlier message in this posting how I need my target structure.

If mys source is

<b>WA</b>,123,12.20,12/12/2006)

I should create 4 target structures like ( (<b>001</b>,123,12,20,12/12/2006), (<b>002</b>,123,12,20,12/12/2006), (<b>003</b>,123,12,20,12/12/2006), (<b>004</b>,123,12,20,12/12/2006) )

With UDF I will derive values of Divisons in target structure for the given StCode

Former Member
0 Kudos

Hi,

My mistake, sorry!

Since you need a Division node for each Target element, you need to use a split by value function which is available under the node functions list in message mapping.

Regards,

Smitha.

Former Member
0 Kudos

I'm sorry would you please eloborate on using splitbyvalue. I really need help here.

I used this mapping but no use.. stil lsame result..

StCode -


> (Convert) -


>Splitbyvalue----> Target

StCode------> (Convert) -


> Division

product -


> Product

cost -


> cost

expDate -


> expDate

Message was edited by:

Ram Krish

Former Member
0 Kudos

Hi Ram,

SplitByValue function is used to create a parent for every Division element.

You could use this after the UDF that you have created for the Division node.

SDivision>UDF->SplitByValue--->TDivision.

I donot have access to the repository now, to try this out.

You could refer this link for more information on SplitByValue:

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/21/3bb8c495125e4eb5969f0377885fe0/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/21/3bb8c495125e4eb5969f0377885fe0/content.htm</a>

Regards,

Smitha.

Former Member
0 Kudos

Hi,

The function is to be used with Division node and not the Target element.

Regards,

Smitha.

Message was edited by:

Smitha Rao

Former Member
0 Kudos

Sorry It couldn't help..Still same result

Former Member
0 Kudos

Hi,

I am not sure what the convert UDF that you have mapped to the Target node is doing. In any case, it should be returning 4 Target elements. Is it doing that?

The logic for the UDF for 'Target' element must have the following logic:

Take st code as input, determine the number of Divisions there need to be. In this case, I assume 4.

So, write a code, to generate 4 different 'Target' elements using addContextChange() function in the UDF.

Only when there are 4 'Target' elements created, 4 'Division' nodes will be created under them, with the help of SplitByValue function.

This might help you write the code:<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/b1/83a09f668320419dbe00a741e0fe6a/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/b1/83a09f668320419dbe00a741e0fe6a/content.htm</a>

Hope this is clear.

Regards,

Smitha.

Former Member
0 Kudos

Hi. I'm already doing that. Please see this mapping

StCode -


> (Convert) -


> Target <i>// This is Node .. I mean to generate as many Target Nodes as Convert UDF returns // </i>

StCode------> (Convert) -


> Division <i>// Same UDF ..see stCode --> Target Mapping //</i>

product -


> Product <i> // Product should be same for all occurances of the node //</i>

cost -


> cost <i> // Cost should be same for all occurances of the node //</i>

expDate -


> expDate <i> // expDate should be same for all occurances of the node //</i>

Example: Here is Source and Target Structures with Examples

Source:

Source 1..unbounded

stCode 0..1 <b>WA </b>

product 0..1 <b>1234</b>

cost 0..1 <b>12.34</b>

expDate 0..1 <b> 12/12/2006</b>

Target:

Target 1:unbounded

Division 0..1

product 0..1

cost 0..1

expDate 0..1

Data in Target should be : Target Structure 1..unbounded

Division,Product,cost,expDate

<b>001,1234,12.34,12/12/2006

002,1234,12.34,12/12/2006

003,1234,12.34,12/12/2006

004,1234,12.34,12/12/2006</b>

Please note Divisions are derived from StCode and node should repeat as many times as UDF returns

All other fields should repeat as many times as Division appears.

When I look at Display Queue for Target and Division I can see as many values I returned from UDF with context change. But when I test it it generates only 1 node with data ( <b>001,1234,12.34,12/12/2006</b> ).

Former Member
0 Kudos

Hi,

Try using CollapseContext after the UDF for the 'TargetNode'. I just tried this, and it seems to work for me.

Regards,

Smitha.