I try to connecting ANDROID with SAP (RFC). .....Is that possible ? I think its possible because this video shows de connection but i dont know why jco version ( he uses strange classes) https://www.youtube.com/watch?v=hJSkqS-dxkw
I am working on Windows 7 (x86) and ECLIPSE IDE.
I have added sapjco.jar to the library project,
added these files to SYSTEM32 FOLDER( sapjcorfc.dll, librfc32.dll )
That´s my code:
package com.example.jco32;
import android.app.Activity; import com.sap.mw.jco.*; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;
import android.widget.Toast;public class MainActivity extends Activity {
JCO.Client client = null;
JCO.Function funcion = null;
JCO.Table t_spfli = null;
IRepository repositorio = null;
IFunctionTemplate ftemplate = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button clickButton = (Button) findViewById(R.id.button1);
clickButton.setOnClickListener( new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
ejecutarjco();
}
});
}
public void ejecutarjco() {
System.out.println("i entered to hte method");
try {
client = JCO.createClient("100",
"USER",
"PASS",
"EN",
"/H/111.22.52.198/W/TESTING/H/172.25.10.21",
"02");
//abre la conexion
System.out.print("BEFORE CONNECT()");
client.connect();
Toast.makeText(getApplicationContext(),
"connected", Toast.LENGTH_LONG).show();
System.out.print("connected");
} catch (Exception e) {
System.out.println("Error:" +e.getMessage());
}
}
}
Unfortunately i got the next ERROR:
09-26 02:03:48.934: E/AndroidRuntime(670): FATAL EXCEPTION: main 09-26 02:03:48.934: E/AndroidRuntime(670): java.lang.ExceptionInInitializerError 09-26 02:03:48.934: E/AndroidRuntime(670): at com.example.jco32.MainActivity.ejecutarjco(MainActivity.java:46) 09-26 02:03:48.934: E/AndroidRuntime(670): at com.example.jco32.MainActivity$1.onClick(MainActivity.java:34) 09-26 02:03:48.934: E/AndroidRuntime(670): at android.view.View.performClick(View.java:3511) 09-26 02:03:48.934: E/AndroidRuntime(670): at android.view.View$PerformClick.run(View.java:14105) 09-26 02:03:48.934: E/AndroidRuntime(670): at android.os.Handler.handleCallback(Handler.java:605) 09-26 02:03:48.934: E/AndroidRuntime(670): at android.os.Handler.dispatchMessage(Handler.java:92) 09-26 02:03:48.934: E/AndroidRuntime(670): at android.os.Looper.loop(Looper.java:137) 09-26 02:03:48.934: E/AndroidRuntime(670): at android.app.ActivityThread.main(ActivityThread.java:4424) 09-26 02:03:48.934: E/AndroidRuntime(670): at java.lang.reflect.Method.invokeNative(Native Method) 09-26 02:03:48.934: E/AndroidRuntime(670): at java.lang.reflect.Method.invoke(Method.java:511) 09-26 02:03:48.934: E/AndroidRuntime(670): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 09-26 02:03:48.934: E/AndroidRuntime(670): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 09-26 02:03:48.934: E/AndroidRuntime(670): at dalvik.system.NativeStart.main(Native Method) 09-26 02:03:48.934: E/AndroidRuntime(670): Caused by: java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC' 09-26 02:03:48.934: E/AndroidRuntime(670): null 09-26 02:03:48.934: E/AndroidRuntime(670): at com.sap.mw.jco.JCO.(JCO.java:776) 09-26 02:03:48.934: E/AndroidRuntime(670): ... 13 more
I hope your help. Regards