Skip to Content
0

SCPI CompoundEmployee Groovy Script (Query)

Jan 19 at 01:34 PM

98

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Praveen Tirumareddy
Jan 22 at 01:29 PM
1

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


test.jpg (17.1 kB)
Show 7 Share
10 |10000 characters needed characters left characters exceeded

Hi Praveen,

Thank you so much for your feedback! I am very new to creating custom iFlow so excuse me if I am asking obvious questions.

Where in my iFlow do I put the script component? Do I need to do a request-and-reply component first? Or do I just put it in the middle?

Thanks in advance!

Deon

0

Hi Deon,

A very valid question. you could start as mentioned below.

Timer --> content Modifier --> Script --> request reply to SF(receiver)--> Message mapping --> End --> ERP(receiver)

e.g:

Hope this helps!!

regards,

Praveen T

answer1.jpg (44.3 kB)
1

Hi Praveen,

Thank you so much for taking the time to help me in such detail. I really appreciate it! It helps so much!

Do I need to specify a mapping for the message mapping or will it automatically pass the compound employee xml structure as is back to the ERP system?

Kind Regards

Deon

0

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

1

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:

0

I could not get the other images uploaded:

Thank you so much for the help!

0

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;
}


1