cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping request

Former Member
0 Kudos

Hi Experts,

Scenario : IDOC to File

When any of the repeated source segment value has Name = "WEL" then target segment will occur once, else as many time as that of source segment.

How to do this mapping?

Regards

Sara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Name--->Split By Value(Value change)--->Collapse Context---->Targetsegment

The above mapping removes the repeating segment and produces a single target for those segments provided the input is in sorted order.

Former Member
0 Kudos

May be you can use a ABAP Mapping to deal your scenario !

Good Luck

Former Member
0 Kudos

Could you please provide some soultion for my query?

Regards

Sara

Former Member
0 Kudos

HI Sara

Did you tried the solution given by Malini

That you have to implement. Check for Name Do SplitByValue with Value change this created only one node if NAME is WEL.

Thanks

Gaurav

Former Member
0 Kudos

Hi Gaurav,

It is not working.

I need the output like below.

Case 1: If Name = WEL then only one target segment.

Source Data:

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

<ns0:MT1_N xmlns:ns0="http://tec.com/pymnt">

<Details>

<Name>WEL</Name>

<Date/>

<Time/>

</Details>

<Details>

<Name>SE</Name>

<Date/>

<Time/>

</Details>

</ns0:MT1_N>

Target Data:

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

<ns0:MT2_N xmlns:ns0="http://tec.com/pymnt">

<Details>

<Name>WEL</Name>

<Date/>

<Time/>

</Details>

</ns0:MT2_N>

Case 2: ( If Name = !WEL then as many of source to target segment.)

Source Data:

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

<ns0:MT1_N xmlns:ns0="http://tec.com/pymnt">

<Details>

<Name>SA</Name>

<Date/>

<Time/>

</Details>

<Details>

<Name>RE</Name>

<Date/>

<Time/>

</Details>

</ns0:MT1_N>

Target Data:

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

<ns0:MT2_N xmlns:ns0="http://tec.com/pymnt">

<Details>

<Name>SA</Name>

<Date/>

<Time/>

</Details>

<Details>

<Name>RE</Name>

<Date/>

<Time/>

</Details>

</ns0:MT2_N>

Please let me know, how to do this mapping?

Regards

Sara

Former Member
0 Kudos

Any suggestions please

former_member200962
Active Contributor
0 Kudos

Hi,

Use two If (without else) conditions and one If (with else)..

First If (without else) will chekc whether your Name = WELL...second If(without else) will check whether Name != WELL...use a constant and EqualS function for both these checks...a boolean not has also to be used.

Use the output of first If (without else) as input to If-Else....else part will come from second If(without else)....

Now map this to the Details node.....

Alternately (Preferred by me):

Also since your Details node seems to be 0...unbounded you can use the Duplicate Subtree option to create two different Details node and then impose the conditions (= WELL, !=WELL) separately...it will help....

Regards,

Abhishek.

Edited by: abhishek salvi on Dec 4, 2008 12:08 PM

Former Member
0 Kudos

Hi Sara,

A small change..This works perfectly

for the first case the udf is changed to


public void check(String[] a,ResultList result,Container container)
{
   //write your code here
 int i = 0;
int j = 0;
for( i = 0; i != a.length ; i++)
 { 
    if(a<i>.equals("WE"))
         {
          j = 0;
          k++;
          break;
          }
   else
         j = 1;
 }
result.addValue(Integer.toString(j));
        }

Here k is a global variable initialized to 0.

second case

Name>check1->createif--->Details


public void check1(String[] a,ResultList result,Container container)
{
 { 
    if((!(a<i>.equals("WE"))) && k == 0)
         {
          j = 1;
          result.addValue(Integer.toString(j));
         }
}
}

Change the context of name to higher level

Former Member
0 Kudos

Hi,

Where to initialize the global variable k?

Instead of writing two UDF, is it possible to write one?

Regards

Sara

Former Member
0 Kudos

Hi,

When u click on to the design tab of message mapping, u ll have an icon called Edit Java Sections.

Click on to it. A screen appears and there under Global variables write int k=0;

I ll try doing this with a single udf.

Former Member
0 Kudos

Hi Experts,

Could you please tell me, how to do this mapping with UseOneAsMany?

Regards

Sara

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

The below solution works 4r ur input

Duplicate the target node Details

Name-->check-->not--->Createif--->Details(1st target node)

Create udf check(use cache parameter as context)


public void check(String[] a,ResultList result,Container container)
{
int i = 0;
int j = 0;
for( i = 0; i != a.length ; i++)
 { 
    if(a<i>.equals("WE"))
          j = 0;
    else
         j = 1;
 }
result.addValue(Integer.toString(j));
  }

Name--->Name

date--->date

time--->time

for second case


Name----------------->equalsS------>not---->createif---->Details(2nd target node)
Constant[WE]------>

Change the context of name here to its higher level.

Map other fields correspondingly..

Hope u can understand..

Former Member
0 Kudos

Hi Malini,

First case works fine, but how to add the second case also in the same mapping?

Regards

Sara

Former Member
0 Kudos

Hi,

Click on to the design tab of Message Mapping

Right click on details and select Dupliacate subtree..

One more structure for details appears..u can use this structure 4r second case..

Former Member
0 Kudos

u can use split by value and select the option value change so when there is a value change in ur source element only then ur target segment will be created.

chirag

dharamveer_gaur2
Active Contributor
0 Kudos

Hi

Use UseOneAsMany for only one occurance.

look use of this point 7

/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

Former Member
0 Kudos

> When any of the repeated source segment value has Name = "WEL" then target segment will occur once, >else as many time as that of source segment.

for first condition, try using CollapseContext...

for second condition; you can use UseOneAsMany.. ..