cancel
Showing results for 
Search instead for 
Did you mean: 

How to do the multimapping in File to File Scenario

Former Member
0 Kudos

Hi All,

I am doing File to File scenario using Multimapping Concept.pls send the procedure how to do the Massege mapping using Multimapping.

I have a source structure like this.

<order header>

order no

order Description

</order header>

<Orderitem>

matno

description

Qty

UOM

</Orderitem>

i need output text file Like

Ono Oodesc OMatno Odes Oqty OUOM

1 02 123 Oil 2 L

1 02 789 Milk 4 L

How to do the multimapping for this.if any Advanced java functions needed pls send the code.

Thanks

Govindu.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ALL,

Source structure look like this

<Order Header> 1 Occurence

<Order No>1</order no>

<order Description>02</order Description>

</Order Header>

<OrderItem>1 to Unbounded

<Matno>123</Matno>

<Desc>oil</Desc>

<Qty>2</Qty>

<UOM>L</UOM>

</OrderItem>

Pls send me the solutions.

Thanks,

Govindu.

Former Member
0 Kudos

Hello Govind,

Make the target str as below

<root>

<Row>

<OrderNo></OrderNo>

<OrderDesc></OrderDesc>

<Matno></Matno>,

<Desc></Desc>

<Qty></Qty>

<UOM></UOM>

</Row>

</root>

The mapping for elements

<Matno>,<Desc>,<Qty>,<UOM> is straight-forward. The node <Row> can be mapped to <OrderItem> node in source. For orderNo and OrderDesc you need to use advanced UDF (with entire queue cached) as below.

public void getOrderNo(String[] a,String[] b,ResultList result, Container container){

/Declare a vector to store unique Order Numbers /Order Desc/

Vector vOno = new Vector();

for (int i = 0;i<a.length;i++){

if (a<i>.equals()ResultList.CC) continue;

/Add distinct Order numbers to the vector/

if(!vOno.contains(a<i>)) vOno.add(a<i>);

}

int headerCounter = 0;

String value = new String();

value = (String) vOno.get(headerCounter);

for (int j = 0;j<b.length;j++){

/When context changes, move to next order no/

if (b[j].equals()ResultList.CC){

headerCounter++;

value = (String) vOno.get(headerCounter);

continue;

}

/Repeat the current order number/Order Desc until a context change occurs/

result.addValue(value);

}

}

The mapping for OrderNo can be like below:

Pass <Order No> from Header to the UDF as array a[] and <OrderItem> from Item as array b[]. Take the output of the function and make it SplitByValue the result of which can be passed to OrderNo. The context of both < Order No> and <OrderItem> has to be one level higher.

Similar mapping for OrderDesc can be made using the same UDF

I hope that resolves your problem.

Regards

Amit

Former Member
0 Kudos

Hi Amit,

Thanks for Reply.

But in my case <OrderNo>,<OrderDesc>are Duplicates.

<Matno>,<Desc>,<Qty>,<UOM> These fields are having the multiple occurences with unique number.

Can i use that above mapping and UDF for <Matno>,<Desc>,<Qty>,<UOM> and straight-forward mapping for <OrderNo>,<OrderDesc>.

Output should be like this

OrderNo,OrderDesc,Matno,Desc,Qty,UOM

1 02 123 Oil 2 Lit

1 02 789 Milk 4 Lit

pls Suggest me.....

Thanks

Govindu.

Former Member
0 Kudos

Hi Govindu,

Yes, that's exactly what I have given solution for. The problem boils down to copying all the item rows to target and adding correct header level details for each item. You need UDF for mapping Header level fields so that you get the correct description / order no for each item. Just try this out and see.

One correction in the code : Read b[j].equals()ResultList.CC as b[j].equals(ResultList.CC)

and a.equals()ResultList.CC as a.equals(ResultList.CC)

CHEERS

Amit

Former Member
0 Kudos

Read a.equals()ResultList.CC as a<i>.equals(ResultList.CC)

CHEERS

Amit