Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Dushyant_Garg
Explorer
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>


  1. 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();
}




  1. 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.

  1. Configuring route 4 as below.

  2. Configure Process-Direct.

  3. Save and deploy this IFlow and create another IFlow for processdirect.

  4. Configure Process Direct, give the same address as you give in previous flow.

  5. 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>


  1. 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();
}

 

  1. Add Content modifier to store the customer email.

  2. Configure XML to CSV convertor.

  3. Configure Mail Adaptor.

  4. Save and deploy the IFlow. Change the log of both IFlow to trace in monitoring.

  5. Open SOAP UI to trigger the data.


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/

  1. 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>


  1. Check the customer mail.I hope this blog helps you, if you have any concern or doubt, drop in the comment section.


Thanks

Dushyant
5 Comments
Labels in this area