cancel
Showing results for 
Search instead for 
Did you mean: 

useOneAsMany

Former Member
0 Kudos

Hi,

In my Message Mapping, I have a situation where in I have to add all occurrence of A's based on unique occurrence of B's. For example in the structure has A= 1,3,5,6,4 for B='abc' and A= 8,9,10 for B='cba' then I need to get the values 19 for the first 5A's and 27 for the last B's as output. I am using use one as many in this case but getting the the total 19+27=46 for all A's and B's.

Please can you suggest some tips or UDF's. UDF where a function like 'on change' may help.....

Thanks in Advance

Manohar

Accepted Solutions (0)

Answers (4)

Answers (4)

dharamveer_gaur2
Active Contributor
0 Kudos

Hi

look these blog for useOneAsMany

Point 7 in this blog

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

Former Member
0 Kudos

HI Murli

Please provide input and output structures to suggest UDF. As Sarvesh suggested using Global variable the same can be achieved. But example given by you is not so clear to solve furthur

Thanks

Gaurav

Former Member
0 Kudos

Here is the structure.

I have to add all the Volume's for each MoreIdentifier and pass the value to TOTAL_CNT_VOLUME in the idoc.

E.g. if I have MoreIdentifier [16846882, 16846882, 16846882, 16846800, 16846800] and Volume[30,20,10,40, 50], then output should be as TOTAL_CNT_VOLUME [60, 60, 60, 90, 90]

Input Structure:

<ShippingOrderGroups>

<ShippingOrderGroup>

<ShippingOrder>

<MoreIdentifier>16846882</MoreIdentifier>

<DocumentNumber>MNL0151998</DocumentNumber>

<Consignee>

<CountryCode>US</CountryCode>

<BusinessEntityCode>TARGETST</BusinessEntityCode>

<SCVCode>33148741516</SCVCode>

<Name>TARGET STORES</Name>

</Consignee>

</ShippingOrder>

<ConsolidatedQuantities>

<Quantity>1500</Quantity>

<Packages>1500</Packages>

<Volume>30</Volume>

<Weight>3000</Weight>

</ConsolidatedQuantities>

</ShippingOrderGroup>

</ShippingOrderGroups>

Output Structure:

<_-FACTGLB_-GTROCEAN_ITEM SEGMENT="Constant">

<SEQ_NO>10</SEQ_NO>

<SHIPPING_ORDER>MNL0151998</SHIPPING_ORDER>

<CONTAINER_NO>GESU3413759</CONTAINER_NO>

<CONTAINER_SIZE>20</CONTAINER_SIZE>

<CONTAINER_TYPE>DRY</CONTAINER_TYPE>

<CONTRACT_NO>GB05/0062</CONTRACT_NO>

<PLANT_ORIGIN>PH03</PLANT_ORIGIN>

<PLANT_DEST/>

<ETA>2008-11-29</ETA>

<ETD>2008-11-15</ETD>

<TOTAL_CNT_VOLUME>22.500</TOTAL_CNT_VOLUME>

<VOLUME_UNIT>M3</VOLUME_UNIT>

<TOTAL_CNT_WEIGHT>3000.0</TOTAL_CNT_WEIGHT>

<WEIGHT_UNIT>KG</WEIGHT_UNIT>

<PAYTON_CONTAINER>22.500</PAYTON_CONTAINER>

<VOLUME>22.500</VOLUME>

<NET_WEIGHT>3000.000</NET_WEIGHT>

<PAYTON_SO>22.500</PAYTON_SO>

<PAYTON_RATIO>1.000</PAYTON_RATIO>

</_-FACTGLB_-GTROCEAN_ITEM>

Former Member
0 Kudos

You don't need useOneAsMany in this scenario. A simple UDF will do the job...

function calculateVol ( String[] MoreIdentifier, String[] volume, result) 
{
  Map vol = new HashMap();  
  int sum = 0;
  for ( int i =0; i < MoreIdentifier.length; i++)
 {
    String identifier = vol.get(MoreIdentifier[ i ] );
    if ( identifier != null )
   {
      sum = Integer.parseInt ( identifier );
   }
   else 
   {
     sum  = 0;
   }
   vol.put ( identifier, sum );
 }

//loop thr the map and the calculated sum to the result list.  Also add context change needed.

}

Former Member
0 Kudos

Thanks Anand,

I tried using your UDF (after some changes as well) but it gives me error Incompatible type.

" incompatible types found : java.lang.Object required: java.lang.String String identifier = vol.get(MoreIdentifier<i> ); "

I tried using the following imports java.lang.Number; java.lang.String; java.lang.Object;

Please can you help me on this.

Thanks in advance.

Edited by: Murli Manohar on Nov 30, 2008 3:36 AM

Former Member
0 Kudos

change the line to the following

String identifier = ( String ) vol.get(MoreIdentifier[ i ] );

Former Member
0 Kudos

Hi,

I will suggest you not to use the function UseOneAsMany, because it consumes lots of memory during message mapping.

The other alternative is to go for Global variable as discribed in this blog.

Regards,

Sarvesh

Former Member
0 Kudos

if you can give the source and target structure, it will be helpful to solve the problem.