cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Problem ( IDoc to File )

Former Member
0 Kudos

Hi,

I am working on Idoc to file scenario...My input and output structures like below...

Idoc:

ZOrderInfo 1----99999

OrderNumber 0---1

ZItem 1----99999

Quantity 0---1

File:

Item

OrderNumber 0-1

Quantity 0-1

Problem : I need to produce Item nodes in output structure based on OrderNumber. like for 4 order numbers in source need to 4 Item segments.

a) Summation: If any duplicate Ordernumber comes in picture...we need to omit that and need to take the quantity from that...do summation and send to target.

like OrderNumber -1...quantity -10 and Ordernumber -1 ....quantity -20

Need to produce only one ordernumber -1 with the quantity of 10+20 =30.

b) If the Ordernumber not present in any segment....Need to pass the quantity as is...

any suggestions would be appreciated.

-Esha.

Accepted Solutions (1)

Accepted Solutions (1)

sunil_singh13
Active Contributor
0 Kudos

Hi Esha,

Just check my article it has example that you can use to accomplish you requirment

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/soa-middleware/ser...

Thanks

Sunil Singh

Former Member
0 Kudos

Thanks Sunil...I am almost done with the changes....

But...I have only one query - If the Ordernumber node not present in the input pay load- I need to pass the quantity value as is.

So that....need to check all segment first and process...I am doing that...Its not working though...Can you help me out.

-E

sunil_singh13
Active Contributor
0 Kudos

Hi Esha,

You can use exists function available in Standard functions (It is a node function).

It checks if the node is available (But not for the value).

Thanks

Sunil Singh

Former Member
0 Kudos

Sunil,

I am using the same function...But its not working fine..Can you just give me an Idea..for quantity field map?

-Esha

sunil_singh13
Active Contributor
0 Kudos

Hi Esha,

I have uploaded the Screen shot at http://www.4shared.com/file/81372898/6bdf9682/New_Microsoft_Office_Word_Document__5_.html

Just download it and use, I have tested the Functionality it is working fine.

I havent added any description is required revert back.

Thanks

Sunil Singh

Former Member
0 Kudos

Sunil,

I will do the changes as you suggested and let you know soon.

Thanks for your help.

-Esha

Former Member
0 Kudos

Sunil,

I have made the changes as you suggested...and I got an exception for the SortBY key node function.

and the exception is....

Exception:com.sap.aii.mappingtool.tf3.IllegalInstanceException: Queues have different lengths in function sortByKey in class com.sap.aii.mappingtool.flib3.NodeFunctions method sortByKey.

any suggestion would be appreciated.

-Esha

sunil_singh13
Active Contributor
0 Kudos

Give me your source File.

It looks like the No of Nodes for Order No and Quantity are not same.

(Right click on both the input and see if the no.f input for both are same).

I had assumed that no of both the inputs will be same. Any how send me your Input structure i will handle that also.

Thanks

Sunil Singh

Former Member
0 Kudos

Sunil,

Note: In this input Idoc - It has 3 segments, 2 segments have same ordernumber and 1 segment doesn't have order number.

And I am expecting two Item nodes in output structure - One with quantities summation (500 +500 =1000) for the same order number and One with no ordernumber and quantity as is (600).

Hope my requirements clear to you! Please help me with the valueable suggestions!

My input structure - IDoc:

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

<ZORDR01>

<IDOC BEGIN="">

<EDI_DC40 SEGMENT="">

<TABNAM/>

<MANDT/>

<DOCNUM/>

<DOCREL/>

<STATUS/>

<DIRECT/>

<OUTMOD/>

<EXPRSS/>

<TEST/>

<IDOCTYP/>

<CIMTYP/>

<MESTYP/>

<MESCOD/>

<MESFCT/>

<STD/>

<STDVRS/>

<STDMES/>

<SNDPOR/>

<SNDPRT/>

<SNDPFC/>

<SNDPRN/>

<SNDSAD/>

<SNDLAD/>

<RCVPOR/>

<RCVPRT/>

<RCVPFC/>

<RCVPRN/>

<RCVSAD/>

<RCVLAD/>

<CREDAT>20080310</CREDAT>

<CRETIM>104301</CRETIM>

<REFINT/>

<REFGRP/>

<REFMES/>

<ARCKEY/>

<SERIAL/>

</EDI_DC40>

<Z1ORDAPH SEGMENT="">

<ORDNO>1234567890</ORDNO>

<DATE/>

<Z1ORDAPL SEGMENT="">

<ORDAPQTY>500</ORDAPQTY>

</Z1ORDAPL>

</Z1ORDAPH>

<Z1ORDAPH SEGMENT="">

<DATE/>

<Z1ORDAPL SEGMENT="">

<ORDAPQTY>600</ORDAPQTY>

</Z1ORDAPL>

</Z1ORDAPH>

<Z1ORDAPH SEGMENT="">

<ORDNO>1234567890</ORDNO>

<DATE/>

<Z1ORDAPL SEGMENT="">

<ORDAPQTY>500</ORDAPQTY>

</Z1ORDAPL>

</Z1ORDAPH>

</IDOC>

</ZORDR01>

sunil_singh13
Active Contributor
0 Kudos

Hello Esha,

I found two conflicting statement in your requirment:

I need to produce Item nodes in output structure based on OrderNumber. like for 4 order numbers in source need to 4 Item segments

and then in your secopnd requirement you said if OrderNumber is not present then pass the quantity as it is.

As in this case there wont be any parent (No item node will be created) then sending quantity doesn't makes sense.

Also if there are Multiple Nodes in which there is no OrderNumber do i have to sum the Quantity as it is possible that there could be more than one Node in which there in No orderNumber then this will become like duplicated OrderNumer Scenario.

As number of item at the output side is dependent on the OrderNumber. So if OrderNumber get repeated then is it required to create the Item node for those repeated node also or I have to create the Item Fields only for unique values of ItemNumbers.

Kindly clear me on this.

Thanks

Sunil Singh

Former Member
0 Kudos

Hi,

you can not handle this through Message mapping.Message mapping working with based on context and queue.as per your input quantity and order number both are in the same context and queue.

Regards,

Prakasu

Former Member
0 Kudos

Hi Esha,

What will be the output in case of 4 nodes wiht 2 nodes having same order no and 2 nodes having blank order no?

Will there be 2 item nodes in output?

Thanks,

Beena.

sunil_singh13
Active Contributor
0 Kudos

use this UDF

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

{

if(!var1<i>.equals("[]"))

{

result.addValue(var2<i>);

}

}

change the mapping as

OrderNumber->MapWithDefault (Put "[]" value as defautl) it is first input to the UDF (It will act as a var1)

second input will be Quantity. Now give the Output of this function(UDF) as first input to the SortByKey and second input as OrderNumber . rest of the things will be same.

Thanks

Sunil Singh

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi esha,

Try the below mapping.

1.OrderNumbermapwithdefault(Function)removecontextsplitybyvalue(valuechange)collapsecontext---Item

2.OrderNumbermapwithdefault(Function)removecontextsplitybyvalue(valuechange)collapsecontext---splitbyvalue(eachvalue)OrderNumber(Target)

3.Quantity(Change the context to idoc) Formatbyvalue>

OrderNumbermapwithdefault(Function)removecontextsplitybyvalue(valuechange)

->Sum(Statistic Function)Quantity(Target).

Regards,

Prakasu

Former Member
0 Kudos

Prakashu,

I have done the changes as you suggested...But it still its not performing calculating/summation of quanties for the same Ordernumbers.

help me out...

-Esha

Former Member
0 Kudos

Hi,

i thing your quantity not passed in a single queue.

Just made a small change in your mapping.after the quantity add the remove context function and map the field to formatby example.

(quantityremovecontext) should be mapped with first node of formatbyexample.

Regards,

Prakasu

Edited by: prakasu on Jan 19, 2009 7:33 AM

SudhirT
Active Contributor
0 Kudos

For Quantities try like this

Quantity->RemoveContext(Node Func)->SUM----->Quantity(Target)

Thanks!