on 01-19-2018 1:34 PM
Hi,
Can anyone perhaps help with a blog or an example on how to write a groovy script for a custom iFlow to limit the amount of employees extracted by the CompoundEmployee component by something like payroll area (pay-group)?
Kind Regards
Deon
Hello Deon,
Please find below the script. I am setting a query as a property and later in the channel you can use same parameter to fetch the query.
Script:
def query = "SELECT person,employment_information,job_information FROM CompoundEmployee WHERE COMPENSATION_PAY_GROUP ='ABC' "
message.setProperty("customQuery",query );
so you could use same property customQuery property as query string.
Hope this helps.
regards,
Praveen T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deon,
If you want to send the message in the same format as its coming from SF you need not require that step.
But generally we would do a transformation using mapping and then send it to ERP system.
So it totally depends on your requirement. If you just want to see the message coming from SF you could just use a data store to store the message and can download it later.
Hope this helps.
regards,
Praveen T
Hi Praveen,
Thanks!!
I've built the iFlow as explained and ran into another problem. When I deploy the iFlow I get the following message:
Error Details
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.sap.gateway.ip.core.customdev.util.Message.setProperty() is applicable for argument types: (java.lang.String, java.lang.String) values: [customQuery, SELECT person,employment_information,job_information FROM CompoundEmployee WHERE pay_group ='MM' ]
Possible solutions: hasProperty(java.lang.String), getProperties(), cause: groovy.lang.MissingMethodException: No signature of method: static com.sap.gateway.ip.core.customdev.util.Message.setProperty() is applicable for argument types: (java.lang.String, java.lang.String) values: [customQuery, SELECT person,employment_information,job_information FROM CompoundEmployee WHERE pay_group ='MM' ]
Possible solutions: hasProperty(java.lang.String), getProperties()
My query looks as follow:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
import java.lang.Exception;
//def query = "SELECT person,employment_information,job_information FROM CompoundEmployee WHERE pay_group ='MM' ";
String query = "SELECT person,employment_information,job_information FROM CompoundEmployee WHERE pay_group ='MM' ";
Message.setProperty("customQuery",query);
I tried both def an string and both of the queries give the same error.
My iFlow currently looks as follow:
Hi Deon,
Seems there is an issue with the script.
it should look like below:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.text.SimpleDateFormat;
import java.util.Date;
def Message processData(Message message) {
//def query = "SELECT person,employment_information,job_information FROM CompoundEmployee WHERE pay_group ='MM' ";
String query = "SELECT person,employment_information,job_information FROM CompoundEmployee WHERE pay_group ='MM' ";
message.setProperty("customQuery",query);
return message;
}
User | Count |
---|---|
76 | |
11 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.