Skip to Content
1

Developing HCI Groovy scripts in Eclipse - missing Message class dependency?

Mar 09, 2017 at 12:55 PM

1.1k

avatar image

I am using Eclipse (Mars) and the latest version of the SAP Cloud Platform Integration Tools Plug-in.

When creating a new script in the integration flow and new .groovy file automatically created. By default it opens in a basic (not very helpful) editor.

I have added the Groovy plug in to get content assistance. I have also updated the build path so that the necessary libraries are added for Java and Groovy. However, I still get errors in the editor because of a missing dependency that all the scripts generated by the Integration Designer will have.

The scripts all import

com.sap.gateway.ip.core.customdev.util.Message

which is not on the build path. Where can one download a JARwhich contains this class so that we can use the editor without errors and with content assistance?

I recall similar issues years ago when developing UDFs for SAP PI - back then the solution was to find the necessary JAR on the PI server, but I can't do something similar with a Tenant in the Cloud.

Any advise would be appreciated.

10 |10000 characters needed characters left characters exceeded

Hi Malcolm,

have you tried Maven for getting the artifact? I faced with the same question and haven't succeed yet.

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Morten Wittrock
Mar 09, 2017 at 06:04 PM
2

Hi Malcolm

It's an interesting question. Like Sriprasad, I don't believe a JAR is available. You could, however, create one yourself and add it to the build path. Your code would look something like the following:

package com.sap.gateway.ip.core.customdev.util;

class Message {

   public void setBody(Object newBody) {
      // No actual code needed here, the method signature is the interesting bit
   }
   
   // Other methods go here

}

Compile your class, add it to a JAR and add that JAR to your project's build path. That will take care of the dependency issue.

If you really want to go all in, post the code on Github and write a blog about it here ;-)

Regards,

Morten

Show 7 Share
10 |10000 characters needed characters left characters exceeded

That's a good point. I'd actually thought of doing this - I recall doing something like that back in the XI days. To make it more useful I'd need to find documentation for the methods that should be available for Message and get all the signatures right. It would work and be useful. But of course it misses the opportunity to use code assist/insight on the real class and discover any methods or constants that might be useful. It would so much easier if SAP simply included the necessary JAR either in the plugin or somewhere else to download - after all, I ran into the problem using their recommended procedure to create a script in HCI via Eclipse.

0

Hi Malcolm

Well, with this approach you only need to implement the methods, that you actually call in your code. Eclipse doesn't know about the relationship between the real Message class and the "fake" Message class, so it won't complain about some of the former's methods not being present in the latter.

You can, however, retrieve all the method signatures using reflection. I've actually already done so :-) You can find the list here.

Regards,

Morten

1

That's really helpful Morten - thanks!

1

No problem, glad you found it useful.

0

Message is interface, not class

0

Hi Ilya. Class.forName("com.sap.gateway.ip.core.customdev.util.Message").isInterface() does seem to return false, indicating that Message is in fact a class, not an interface.

0

Thank you, Morton.

I'm sorry for the mistake.

0
Sriprasad Shivaram Bhat Mar 09, 2017 at 05:18 PM
3

Hello Malcolm,

Even I have also tried to find out the jars(similar to SAP PI)which you are asking here but unfortunately no luck.

In alternative way this is what I am following.

Have your input XML and save it as string using below syntax

Def str_input='''<root><test>val1</test></root>'''

Write your logic for the above input for testing use printing when you want to use it in hci set it using setbody().

To test there are 2 ways

1)Groovy web console-you will not be able to add external jars , sometimes I felt it's not that worth using it.

2)download the groovy console from groovy official site(best way to write the groovy where you can import all the required jar files).

3)Even you can use eclipse also with Groovy plugin but I felt it's very easy to follow second method.

To know more about the methods available to use within processedata() method are documented in Java API section of sap hci help which you can use it with core transformation logic written using above 2 methods.

Hope it helps!

Regards,

Sriprasad Shivaram Bhat

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks for the help. I'll proably end up using method 2 if I have anything I need to test extensively. I have not been able to find much documentation on using scripts, mostly just

https://uacp.hana.ondemand.com/http.svc/rc/PRODUCTION/93810d568bee49c6b3d7b5065a30b0ff/1/en-US/frameset.html?03b32eb2c5c249f0a59bcd27c44d1e4e.html

and

https://proddps.hana.ondemand.com/dps/d/preview/93810d568bee49c6b3d7b5065a30b0ff/2015.10/en-US/frameset.html?24bc8bb8fff64c2eab7deadb54715aad.html

Is there anywhere else I should be looking?

The reason I was hoping for the Eclipse editor to provide content assistance is that it would help discover what one can do with a MappingContext or Message. I recall that with PI for instance there were defined constants which represended ContextChange and Suppress in a queue ( String[] ) - I don't know whether that option exists still?

0

Hello Malcolm,

You can refer below JAVA DOC references for SAP HCI which might be helpful and I can see many of the Context related functions are available.

Generic API

Script step API

Adapter Development Kit API

Hope it will help you.

Regards,

Sriprasad Shivaram Bhat

0
avatar image
Former Member
Dec 13, 2017 at 05:00 AM
3

Hello,

Script API JAR has been made available now and it can be downloaded from https://tools.hana.ondemand.com/#cloudintegration

--

Thanks and Regards,

Bhuvan Mehta

Share
10 |10000 characters needed characters left characters exceeded