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:
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>
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();
}
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.
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>
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();
}
Refer below blog to use SOAP UI
https://blogs.sap.com/2023/09/21/sending-xml-data-using-soap-adaptor-to-mail-using-message-mapping/
<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>[email protected]</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>[email protected]</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>[email protected]</Email>
</Order>
</Order_root>
Thanks
Dushyant