cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping!!

Former Member
0 Kudos

Hi All,

My Source Structure is


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

<ns0:MT_AR xmlns:ns0="urn:testXYZ">
   <data_records1>
      <key><key/>
      <field1><field1/>
     ...............
     ...............
     <fieldn><fieldn/>
  </data_records1>
 <data_records2>
      <key><key/>
      <field1><field1/>
     ...............
     ...............
     <fieldn><fieldn/>
  </data_records2>
................................
.............................
<data_recordsn>
      <key><key/>
      <field1><field1/>
     ...............
     ...............
     <fieldn><fieldn/>
  </data_recordsn>
</ns0:MT_AR>

My target structure is like

 IDOC->1...unbounded
                   segmentA->1....unbounded
                         counterA->1..1
                   segmentB->1....unbounded
                         counterB->1..1
                     segmentARef->1....unbounded
                         counterARef->1..1
                   segmentBRef->1....unbounded
                         counterBRef->1..1

now depending upon the value of key i have to create IDocs

suppose 4 line item comes with key as 1,2,1,3

i have to create 3 Idocs for 1,2,3

for IDoc with key 1 there will be 8 segements...

for Idoc with key 2,3 there will be 4 segment for each idoc.

Now my requirement is to fill the counter field with appropriate values.

the output for IDoc with key 1 should be like

 IDOC->1...unbounded
                   segmentA->
                         <counterA>1</counterA>
                    segmentA->                                      
                         <counterA>2</counterA>
                   segmentB->
                          <counterB>3</counterB>
                   segmentB->
                          <counterB>4</counterB>
                     segmentARef->
                         <counterARef>1</counterARef>
                     segmentARef->
                         <counterARef>2</counterARef>
                     segmentBRef->
                         <counterBRef>3</counterBRef>
                     segmentBRef->
                         <counterBRef>4</counterBRef>

                   

the output for IDoc with key 2,3 should be like

 IDOC->1...unbounded
                   segmentA->
                         <counterA>1</counterA>
                  segmentB->
                          <counterB>2</counterB>
                  segmentARef->
                         <counterARef>1</counterARef>
                  segmentBRef->
                         <counterBRef>2</counterBRef>

any idea?

regards

Biplab

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi biplab,

I think you can use the index, counter function and to avoid the duplicates you can use sort and sortbykey.

see this blog for sort and sortbykey functions usage

Thanks,

Srini

Former Member
0 Kudos

sloved!!!

using 3 udf!!

used udf1 to segment1


for(int p=1;p<=a.length;p++)

result.addValue(""+p);

used udf2 to segment2


int q=a.length;
for(int p=1;p<=a.length;p++)
{
 q = q+1;
result.addValue(""+q);

}

used udf3 to segment3


int q=a.length;
q=q*2;
for(int p=1;p<=a.length;p++)
{
 q = q+1;
result.addValue(""+q);

}