cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to implement a Empty Value Check in Integration Flow

shin861231
Participant
0 Likes
1,176

Hello,

I am now trying to create an integration flow with embedded value check function for mandatory fields, especially for CSV files.
For example, suppose there's an input CSV file as follow, and all three fields(Name, Cost, Category) should always be set as mandatory, meaning there should always be any value other than blank.

------------CSV File Image-----------
Name, Cost, Category
Apple, 80, Fruit
Banana, 50, Fruit
Milk, 40, Grocery
------------CSV File Image-----------

Therefore, if a CSV file as follow was input from the sender, after the process of integration flow, the status of it should show "Failed" because there's blank value (or Null) in the first row, for Category.


++++++++Bad CSV File Input++++++++
Name, Cost, Category
Apple, 80,
Banana, 50, Fruit
Milk, 40, Grocery
++++++++Bad CSV File Input++++++++

To achieve this scenario, I have designed an integration flow as below.

InquiryForEmptyValueHandling.jpg

Here's the detail setting in message mapping.

MessageMappingforEmptyValueCheck.jpg

Here's the detail setting for "Set Cost" content modifier.

SetCost.jpg

Here's the detail for Router.

Router.jpg

Here's the "Throw Error Message"(Content Modifier).

Throw Error Message.jpg

My thought was that we generate some message saying "Error" which was defined ourselves in message mapping, and the message replace empty values(in this case, the first row, for category). After that, we use Router to check if there's any "Error" values, if yes, then it will be routed to error end event.

However, it still shows error somehow, and I do not feel like it is a smart way to check empty values.
In this SAP learning tutorial[LINK], it mentions that this kind of checking falls into category as expected error handling, but it does not explain the best practice of how we could design in integration flows.

Could anyone please kindly advise on this one? It would be nice to paste a screenshot of integration flow.

 

Thank you.

 

Shin

Accepted Solutions (0)

Answers (2)

Answers (2)

Chetan7
Explorer
0 Likes

You can use XSLT Mapping to check if the mandatory fields are empty or not.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/root">
        <result>
            <xsl:choose>
                <!-- Check if Category, Name or Cost is empty -->
                <xsl:when test="row[string-length(Category) = 0 or not(Category)] or row[string-length(Name) = 0 or not(Name) or string-length(Cost) = 0 or not(Cost)]">true</xsl:when>
                <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
        </result>
    </xsl:template>
</xsl:stylesheet>

 

shin861231
Participant
0 Likes
Thank you for your reply! Does it also apply to CSV file? In my understanding XLST Mapping only applies to XML.
Srikanth
Product and Topic Expert
Product and Topic Expert
0 Likes

@shin861231 ,

Thanks for the question, Can't this be validated with a Groovy Script or java Script to  Read and Modify Message Header, Message Body etc, will this functionality won't suffice your scenario. 

Best Regards,
Sri