cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter source data and write two files in parallel

0 Kudos

Hi Team,

I am querying a DB and I want to write two csv files in parallel.

1. All the valid records as in skipping null/blank values, valid email id - File 1.csv

2. All invalid records as in null/blank records, invalid email id - file 2.csv

Inorder to determine whether email id is valid or not, I need to execute another query which will return the email domains maintained in DB.

How to achieve this ?

Thanks,

Varun

Accepted Solutions (0)

Answers (1)

Answers (1)

karthikarjun
Active Contributor
0 Kudos

Hi srivarun15 - Will you try the below approach to achieve your requirement?

1. How to check if the email id is valid?

importClass(com.sap.gateway.ip.core.customdev.util.Message);
importClass(java.util.HashMap);

function processData(message) {
    //Body
      var emailBody = message.getBody();
      var re = /\S+@\S+\.\S+/;
      var result =  re.test(emailBody);
      message.setProperty("isValid", result);

      return message;
}

2. Use isValid property in router function -> router conditions will create routes to take a decision

for example ${property.isValid} = true -> Take route 1 else route 2

Regards,

Karthik Arjun

SAP CPI | Fiori Senior Specialist