cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping using UseOneAsMoney

former_member331856
Participant
0 Kudos


Hi Experts,

I am doing the Message Mapping as mentioned in the below blog. I am getting the Error as

05:15:46 Start of test

Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Too few values in the first queue in function useOneAsMany. It must have the same number of contexts as the second queue] in class com.sap.aii.mappingtool.flib7.NodeFunctions method useOneAsMany[[Ljava.lang.String;@478d13c, [Ljava.lang.String;@17f0bc6f, [Ljava.lang.String;@3de327b0, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@c42b38e, com.sap.aii.mappingtool.tf7.rt.Context@6f1a35eb]
com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Too few values in the first queue in function useOneAsMany. It must have the same number of contexts as the second queue] in class

I have searched in other blog also and ended up with the same error. Please check and do the needful.

The Basic Problem

We have an IDoc ORDERS05 with purchase order information where each purchase order line item (represented by segment .<E1EDP01>) can contain multiple schedule lines (represented by segment <E1EDP20>). For example, we have 2 line items with 3, resp. 2 schedule lines. Then the corresponding portion of message ORDERS05 can look as follows:

...   

   <E1EDP01>

      <POSEX>00010</POSEX>

      <E1EDP20 SEGMENT="1">

         <WMENG>15</WMENG>

      </E1EDP20>

      <E1EDP20 SEGMENT="1">

         <WMENG>44</WMENG>

      </E1EDP20>

      <E1EDP20 SEGMENT="1">

         <WMENG>3</WMENG>

      </E1EDP20>

   </E1EDP01>

   <E1EDP01>

      <POSEX>00020</POSEX>

      <E1EDP20 SEGMENT="1">

         <WMENG>32</WMENG>

      </E1EDP20>

      <E1EDP20 SEGMENT="1">

         <WMENG>12</WMENG>

      </E1EDP20>

   </E1EDP01>

...   

We want to map the information of the IDoc ORDERS05 to the message OrderCreate of the CIDX v4.0 standard. This message uses a more flat

structure where the purchase order line items and the corresponding schedule lines are on the same level. The corresponding portion of the

message OrderCreate (for the same information as in the IDoc) looks as follows:

...   

   <OrderCreateProductLineItem>

<PurchaseOrderLineItemNumber>00010</PurchaseOrderLineItemNumber>

      <ProductQuantity>15</ProductQuantity>

   </OrderCreateProductLineItem>

   <OrderCreateProductLineItem>

      <PurchaseOrderLineItemNumber>00010</PurchaseOrderLineItemNumber>

      <ProductQuantity>44</ProductQuantity>

   </OrderCreateProductLineItem>

   <OrderCreateProductLineItem>

      <PurchaseOrderLineItemNumber>00010</PurchaseOrderLineItemNumber>

      <ProductQuantity>3</ProductQuantity>

   </OrderCreateProductLineItem>

   <OrderCreateProductLineItem>

      <PurchaseOrderLineItemNumber>00020</PurchaseOrderLineItemNumber>

      <ProductQuantity>32</ProductQuantity>

   </OrderCreateProductLineItem>

   <OrderCreateProductLineItem>

      <PurchaseOrderLineItemNumber>00020</PurchaseOrderLineItemNumber>

      <ProductQuantity>12</ProductQuantity>

   </OrderCreateProductLineItem>

...   

The data in red correspond to data of the segment <E1EDP01>, while the information in blue correspond to data of the segment <E1EDP20> of the original IDoc. Note that the data in red need to be duplicated based on the occurence of segment <E1EDP20>.

Solution 1

A simple solution of this mapping problem exists under the assumption that in the IDoc ORDERS05 each segment <E1EDP01> contains at least one segment <E1EDP20>. Luckily this assumption holds true for IDocs created via the purchase order creation process in ERP.

  1. 1. Mapping of <OrderCreateProductLineItem>

The segment <OrderCreateProductLineItem> of the target structure needs to be created once for each occurrence of segment <E1EDP20> of our source structure. This can easily be achieved via the following mapping:

Remember to change the context to IDOC.

  1. 2. Mapping of <PurchaseOrderLineItemNumber>

Since the information for the node <PurchaseOrderLineItemNumber> comes from the IDoc segment <E1EDP01>, this node needs to be replicated based on the occurrence of segment <E1EDP20> under each segment <E1EDP01>. This can be achieved using the node function useOneAsMany as follows:

I will not describe the functionality of the node function useOneAsMany in detail since there is a lot of excellent documentation available on this function, for example in the SAP help . In our scenario you only need to change the context of the second input parameter to E1EDP01.

With the sample input from above, the function useOneAsMany will give the following result:

  1. 3. Mapping of <ProductQuantity>

Since the <ProductQuantity> is derived from a value of the IDoc segment <E1EDP20> the mapping for this field is trivial (remember that <ProductQuantity> must occur once per <E1EDP20> segment):

Please check the error and guide me how to proceed further.

Regards,

GIRIDHAR

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

The problem is that you the first and second input queue of UseOneAsMany function does not have the same number of context changes.

Do your mapping like this

E1EDP20(set context to Idoc level )----> OrderCreateProductLineItem


First input of UseOneAsMany   --->POSEX ( set context to E1EDP01)

Second input of UseOneAsMany--->  E1EDP20 ( set context to E1EDP01 )

Third  input of UseOneAsMany--->  E1EDP20 ( set context to E1EDP01 )


Then after UseOneAsMany use removeContext--->SplitByEachValue--->PurchaseOrderLineItemNumber


WMENG ( set context to E1EDP20) ----> ProductQuantity


This will give you the output in the format you are asked for.

Let me know if any issues.

Answers (1)

Answers (1)

Harish
Active Contributor
0 Kudos

Hi Giridhar,

The error is in Use one as many, you can not use the useOneAsMany for this requirment. it can be achieve in multiple way with standart function or simple UDF.

Standard function - Contact POSEX and E1EDP20 in parent context. Then map using split by value.

UDF - take input of POSEX and E1EDP20 in context of E1EDP01. Loop POSEX for all the occurence of POSEX and map to target.

  1. 2. Mapping of <PurchaseOrderLineItemNumber>

Since the information for the node <PurchaseOrderLineItemNumber> comes from the IDoc segment <E1EDP01>, this node needs to be replicated based on the occurrence of segment <E1EDP20> under each segment <E1EDP01>. This can be achieved using the node function useOneAsMany as follows:

I will not describe the functionality of the node function useOneAsMany in detail since there is a lot of excellent documentation available on this function, for example in the SAP help . In our scenario you only need to change the context of the second input parameter to E1EDP01.

regards,

Harish