Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sap.mw.jco.*
- import org.junit.*
- // This is merely a run test which should pass for any successful SAP connection
- // The idea is to retrieve the field system id by calling the function module TR_SYS_PARAMS
- // The result should of course be identical to the SystemID of the connection itself.
- // When using SAP JCo with Groovy, you will need sapjco.jar and, beside it, also jdsr.jar !!!
- // The reason is an internal method lookup which needs to resolve such a reference:
- // It's precisely the problem reported here: http://jira.codehaus.org/browse/GROOVY-2980
- // As always with JCo, the librfc32.dll must be available in one of the PATH directories
- // You will find all these libraries in a SAP Frontend installation ( search in C:\Program Files\SAP )
- class TestSapGroovyConnect {
- JCO.Client conn;
- JCO.Repository repo;
- @Test void test() {
- JCO.Function getSysParams = repo.getFunctionTemplate( "TR_SYS_PARAMS" ).getFunction();
- conn.execute getSysParams
- assert getSysParams.getExportParameterList().getValue( "SYSTEMNAME" ) ==
- conn.getAttributes().getSystemID()
- }
- @Before
- void setup() {
- // Maintain logon data in a Properties file, as documented in
- // http://help.sap.com/javadocs/NW04/current/jc/com/sap/mw/jco/JCO.html
- def sys = new Properties()
- sys.load( new FileInputStream( "h:\\Eigene Dateien\\groovy\\jco\\d12.properties" ) )
- conn = JCO.createClient( sys )
- conn.connect()
- repo = new JCO.Repository( "repo", conn );
- }
- @After
- void teardown() {
- conn.disconnect()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement