Scenerio:
Customer Order data is coming from sender using SOAP adaptor. CPI should generate order_no acc. to the given format. After generating order_no we need to add a field company_name. After this we need to check the action is Pending/Not_Available/Delivered.
If its pending then its end the flow, if its delivered then it direct to another IFlow using Process Direct in which we are generating TransactionId according to the given format. One its generated it should send the mail to the customer and the company admin mail, if its Not_Available it should end and send the mail to the customer and admin that your order is not available.
Order_no: random alphanumeric string of length 6 and concat it with quantity and Item as below.
Example: Item:- xyz, Quantity: 1 => Order_no = AB12CDxyz1
TransactionId:- Random alpha character string of length 10 and concat it with the Order_no.
Example: ABCDEFGHIJAB12CD1xyz
Steps:
1. Create an IFlow connect with sender using SOAP 1x adaptor as it is one way communication.
2. Add message mapping pallete and add source and target xsd as per the data.
Source XSD:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Order_root">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Order">
<xs:complexType>
<xs:sequence>
<xs:element name="Orderno" />
<xs:element name="Cust_Name" type="xs:string" />
<xs:element name="Cust_Add" type="xs:string" />
<xs:element name="Item" type="xs:string" />
<xs:element name="Action" type="xs:string" />
<xs:element name="Quantity" type="xs:unsignedByte" />
<xs:element name="Email" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Target XSD:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Order_root">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Order">
<xs:complexType>
<xs:sequence>
<xs:element name="Orderno" />
<xs:element name="Cust_Name" type="xs:string" />
<xs:element name="Cust_Add" type="xs:string" />
<xs:element name="Item" type="xs:string" />
<xs:element name="Action" type="xs:string" />
<xs:element name="Quantity" type="xs:unsignedByte" />
<xs:element name="Company" type="xs:string" />
<xs:element name="Email" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
3. Configure Message Mapping.
Custom Function Script:
import com.sap.it.api.mapping.*;
def String customFunc(String arg1){
def chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
def random = new Random();
def sb = new StringBuilder(6);
for (int i = 0; i < 6; i++) {
sb.append(chars.charAt(random.nextInt(chars.length())));
}
return sb.toString();
}
4. Add Splitter to split the XML record and send to router.
Route 2 is ending as it is for Action Pending.
Route 3 is connecting to receiver using process direct adaptor.
Route 4 is connecting content modifier as we need customer mail id from the respective data.
Route 5 is default if the action not defined it should end the flow.
5. Configuring route 4 as below.
6. Configure Process-Direct.
7. Save and deploy this IFlow and create another IFlow for processdirect.
8. Configure Process Direct, give the same address as you give in previous flow.
9. Add mapping pallete and source and target xsd.
Source xsd should be same as the previous IFLOW Target xsd.
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Order_root">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Order">
<xs:complexType>
<xs:sequence>
<xs:element name="Orderno" />
<xs:element name="Cust_Name" type="xs:string" />
<xs:element name="Cust_Add" type="xs:string" />
<xs:element name="Item" type="xs:string" />
<xs:element name="Action" type="xs:string" />
<xs:element name="Quantity" type="xs:unsignedByte" />
<xs:element name="Company" type="xs:string" />
<xs:element name="Email" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Target XSD:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Order_root">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Order">
<xs:complexType>
<xs:sequence>
<xs:element name="Orderno" type="xs:string" />
<xs:element name="Cust_Name" type="xs:string" />
<xs:element name="Cust_Add" type="xs:string" />
<xs:element name="Item" type="xs:string" />
<xs:element name="Action" type="xs:string" />
<xs:element name="Quantity" type="xs:unsignedByte" />
<xs:element name="Company" type="xs:string" />
<xs:element name="Transition_ID" type="xs:string" />
<xs:element name="Email" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
10. Configure Mapping.
Custom Function Groovy:
import com.sap.it.api.mapping.*;
def String customFunc(String arg1){
def chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
def random = new Random();
def sb = new StringBuilder(10);
sb.append(arg1);
for (int i = 0; i < 8; i++) {
sb.append(chars.charAt(random.nextInt(chars.length())));
}
return sb.toString();
}
11. Add Content modifier to store the customer email.
12. Configure XML to CSV convertor.
13. Configure Mail Adaptor.
14. Save and deploy the IFlow. Change the log of both IFlow to trace in monitoring.
15. Open SOAP UI to trigger the data.
16. Add sample data.
<Order_root>
<Order>
<Orderno></Orderno>
<Cust_Name>Sahil</Cust_Name>
<Cust_Add>xyz</Cust_Add>
<Item>Pen</Item>
<Action>Pending</Action>
<Quantity>1</Quantity>
<Email>abc@gmail.com</Email>
</Order>
<Order>
<Orderno></Orderno>
<Cust_Name>Dushyant</Cust_Name>
<Cust_Add>xyz</Cust_Add>
<Item>Notebook</Item>
<Action>Delivered</Action>
<Quantity>4</Quantity>
<Email>efg@gmail.com</Email>
</Order>
<Order>
<Orderno></Orderno>
<Cust_Name>Aman</Cust_Name>
<Cust_Add>xyz</Cust_Add>
<Item>Pencil</Item>
<Action>Not Available</Action>
<Quantity>2</Quantity>
<Email>ijk@gmail.com</Email>
</Order>
</Order_root>
17. Check the customer mail.