on 03-25-2014 10:47 AM
Hi,
I have a file to multiple idoc scenario.
Msg type
Data Type
Header (1) (field1, field 2, field 3 etc)
ITEM( 0 to U) (field X, field Y, field Z etc)
Idoc Type
IDOC (1 to U)
Begin
Idoc Ports (1) (field a1, field a2, field a3 etc)
Idoc_HDR (1) (field1, field Y, field 3 etc)
Idoc_ITM (1 to 99999999) (field X, field Z etc)
Idocs are generated only for some ITEM lines of source and so the value of field X is used and mapped to IDOC node using createif.
Rest of the mapping is done normally and works fine and creating multiple idocs if there are multiple ITEM lines in the source file. This mapping is doesn't work if I want to create multiple Idoc-ITMs
My requirement is to create multiple Idoc_ITM nodes under one parent IDOC node for for all ITEMs relating to one "field Y" of source. At the moment I am creating 4 idocs for the below example, but I want 3 like below:
Country, city, date
emp1, department1, roleA
emp2, department1, roleB
emp3, department2, roleC
emp4, department3, roleC
Idoc_HDR
Country, department1, date
emp1, department1, roleA
emp2, department1, roleB
Idoc_HDR
Country, department2, date
emp3, department2, roleC
Idoc_HDR
Country, department3, date
emp4, department3, roleC
How can achieve it please?
Many thanks.
Ramesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Muni,
Under the header mapping, just before the "useOneAsMany" you used the output of collapseContexts function twice. How is that possible?
Also, I did everything you mentioned. In the header mapping, we mapped the field Y to field2. It is giving me an error "Too many values in first queue in function useOneAsMany. It must have the same number of contexts as second queue.] in class com.sap.aii.mappingtool.flib3.NodeFunctions method useOneAsMany"
The field 2 in the target header occurs only once but it occurs many times in the source. How do we overcome this problem?
I think I am getting close to this.
Many thanks for your help.
Ramesh.
Hi Muni,
The source and required target xmls are here: I made it a bit simpler for better understanding and space.
If you want the xml of the source message structure, I can send that too.
Source:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:expense_source_msg xmlns:ns0="http://dtsp.com/postexpense">
<Online_Expenses>
<Expenses_Header>
<Constant/>
<BatchDate>20140320<BatchDate/>
<Record_Count/>
<Amount_Total/>
</Expenses_Header>
<Expenses_Item>
<Employee_ID>test1<Employee_ID/>
<Employee_Name>RAMESH<Employee_Name/>
<price>10.00<price/>
<Org_Unit>z1<Org_Unit/>
<Type>Price<Type/>
</Expenses_Item>
<Expenses_Item>
<Employee_ID>test2<Employee_ID/>
<Employee_Name>ANKIT<Employee_Name/>
<price>20.00<price/>
<Org_Unit>z2<Org_Unit/>
<Type>Price<Type/>
</Expenses_Item>
<Expenses_Item>
<Employee_ID>test3<Employee_ID/>
<Employee_Name>SIVA<Employee_Name/>
<price>30.00<price/>
<Org_Unit>z2<Org_Unit/>
<Type>Price<Type/>
</Expenses_Item>
</Online_Expenses>
Required Target:
</ns0:concur_online_expense_source_msg>
<?xml version="1.0" encoding="UTF-8"?>
<ZFI204_AR_INV01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="EDI_DC40">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>2</DIRECT>
<IDOCTYP>ZFI204_AR_INV01</IDOCTYP>
<MESTYP>ZFI204_AR_INV</MESTYP>
<RCVPRN/>
</EDI_DC40>
<Z1ZFI204_HDR SEGMENT="Z1ZFI204_HDR">
<DOCUMENT_TYPE>KX</DOCUMENT_TYPE>
<DOCUMENT_DATE>20140320</DOCUMENT_DATE>
<POSTING_DATE>20140320</POSTING_DATE>
<COMPANY_CODE>z1</COMPANY_CODE>
<Z1ZFI204_ITM SEGMENT="Z1ZFI204_ITM">
<NET_INVOICE_AMOUNT>10.00</NET_INVOICE_AMOUNT>
<EMPLOYEE_NAME>RAMESH</EMPLOYEE_NAME>
<EMPLOYEE_NUMBER>test1</EMPLOYEE_NUMBER>
</Z1ZFI204_ITM>
</Z1ZFI204_HDR>
</IDOC>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="EDI_DC40">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>2</DIRECT>
<IDOCTYP>ZFI204_AR_INV01</IDOCTYP>
<MESTYP>ZFI204_AR_INV</MESTYP>
<RCVPRN/>
</EDI_DC40>
<Z1ZFI204_HDR SEGMENT="Z1ZFI204_HDR">
<DOCUMENT_TYPE>KX</DOCUMENT_TYPE>
<DOCUMENT_DATE>20140320</DOCUMENT_DATE>
<POSTING_DATE>20140320</POSTING_DATE>
<COMPANY_CODE>z2</COMPANY_CODE>
<Z1ZFI204_ITM SEGMENT="Z1ZFI204_ITM">
<NET_INVOICE_AMOUNT>20.00</NET_INVOICE_AMOUNT>
<EMPLOYEE_NAME>ANKIT</EMPLOYEE_NAME>
<EMPLOYEE_NUMBER>test2</EMPLOYEE_NUMBER>
</Z1ZFI204_ITM>
<Z1ZFI204_ITM SEGMENT="Z1ZFI204_ITM">
<NET_INVOICE_AMOUNT>30.00</NET_INVOICE_AMOUNT>
<EMPLOYEE_NAME>SIVA</EMPLOYEE_NAME>
<EMPLOYEE_NUMBER>test3</EMPLOYEE_NUMBER>
</Z1ZFI204_ITM>
</Z1ZFI204_HDR>
</IDOC>
</ZFI204_AR_INV01>
Hi Muni,
I will try that now.
What should be the mapping for the "IDOC" node and "Z1ZFI204_HDR" node?
I have mapped createif condition to "IDOC" node (0 to unbounded) as I want to use only ITEM lines with field Org_Unit which has value starting with "z"
So, If ---> first letter of "Org_Unit" equals to "z" ----> createIf ----> IDOC (0 to unbound)
Can I leave it like that? and also what should be mapped to Z1ZFI204_HDR?
Many thanks mate.
Hi Muni,
I have been trying different combinations, but the target fields are not being populated. Before I come to that there is a basic problem which is critical.
As you already may have understood, I have to create an idoc for every selected item line of the source. I am doing the selection by using createif and map it to the IDOC node. I also want all the items lines (Z1ZFI204_ITM) to be packed under one Z1ZFI204_HDR for item lines having same "Org_Unit".
Now the basic problem lies in the IDOC node. It is creating a separate Idoc for every line item no matter what the "Org_Unit" is. Is there a way to combine createif with other functions to achieve this?
PS: Apologies for giving different field names. I just made it simpler earlier, but looks like I am getting no where with that. This is the original mapping. I can give you the exact source and target xmls, but the source has many unused fields and is very long.
Many thanks.
I won't forget your help.
Hi Ramesh,
please share your sender and receiver xml. Me or someone else will be able to help you. sometimes you don't need written logic when you have source and target xml.
from your reply
you want to create separate idoc for selected line item of source.
say if you have 10 selected line items then it will create 10 idocs. this is not an issue.
but when coming to Z1ZFI204_HDR and Z1ZFI204_ITM these are mandatory. so each idoc must be having at least one Z1ZFI204_HDR and one or more Z1ZFI204_ITM.
let us say you have 10 Org_Units for ten line items. for example z1,z1,z1, z1,z1,z1, z1,z1,z1,z2.
when you group these then it will give only 2. i.e z1 and z2.
this is going to cause issue as for 10 idocs you need Z1ZFI204_HDR nodes to be created.
you may need to check your logic. if you are creating idoc based on Org_Units then it will not cause any issue.
say in my above example you will get 2 idocs.
1st idoc will have z1,z1,z1, z1,z1,z1, z1,z1,z1 under Z1ZFI204_ITM.
2nd idoc will have z2 under Z1ZFI204_ITM.
Regards,
Muni.
Hi Muni,
That is exactly how I want it. Multiple Idocs for different Org_Units and/or one idoc (with multiple ITEMs) for unique Org_Units.
I have attached the xsds for both Source and target. The actual fields are slightly different as I wanted to make them look easy. Attached are the originals.
The Org_Unit we were talking about is actually "Employee_Org_Unit_2" under "AR_Expenses_Item" node of source and is mapped to "COMPANY_CODE" under Z1ZFI204_HDR of target. The IDOC node creation is dependant on the contents of the field "Tax_Authority_Label" under "AR_Expenses_Item" node of source.
Many thanks.
Ramesh.
Hi Muni,
I finally got it working
I have mapped "Org_Unit" to IDOC by formatByExample. Mapped a constant to Z1ZFI204_HDR. Mapped all fields under the Header directly. Mapped the item line condition to Z1ZFI204_ITM. Mapped all fields under the item lines of source to target fields under Z1ZFI204_ITM directly.
Many thanks for your time.
Regards,
Ramesh.
Hi Ramesh,
Based on the example provided by you, if you want 3 IDocs instead of 4, try the following in multimapping:
1. If the file is sorted
In message mapping, take the queue of Field Y
=> Split by value (value change) (Map it to Idoc_ITM)
=> Collapse Context
=> Map to IDoc node of target structure. (Also, map the same to Idoc_HDR)
2. If the file is not sorted, sort it first and then follow the above point.
Hope this helps.
Thanks,
Abhishek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to use below methods to create multiple idocs
File to Multiple IDOC Splitting without BPM - Process Integration - SCN Wiki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.