1

I am new to Android programming. The task is as follows:

From an Android application (apk) connect remotely to SAP and call BAPI. The option of calling via web-service is not suitable - the security system does not allow.

I need to connect SAP using SAPROUTER.

System:

1) Windows 8.1, - 64-bit

2) Java 1.8.0_201 - 64-bit

3) Android studio - 64-bit

4) SAP JCO libraries for Windows 32-bit (https://support.sap.com/en/product/connectors/jco.html)

In Android Studio: - Created an activity and created a button. - When clicking on the button, the method try connect to SAP.

The code is as follows:

Properties connectProperties = new Properties ();

connectProperties.setProperty (DestinationDataProvider.JCO_ASHOST, "xx.xx.xx.xx");

connectProperties.setProperty (DestinationDataProvider.JCO_SYSNR, "00");

connectProperties.setProperty (DestinationDataProvider.JCO_CLIENT, "200");

connectProperties.setProperty (DestinationDataProvider.JCO_USER, "USER_NAME");

connectProperties.setProperty (DestinationDataProvider.JCO_PASSWD, "USER_PASS");

connectProperties.setProperty (DestinationDataProvider.JCO_LANG, "EN");

connectProperties.setProperty (DestinationDataProvider.JCO_SAPROUTER, "/H/xxx.xxx.xxx.xxx...");

String f_name = createDestinationDataFile (context, DESTINATION_NAME1, connectProperties);

try {

    JCoDestination jcoDestination = JCoDestinationManager.getDestination (DESTINATION_NAME1);

    JCoFunction function = jcoDestination.getRepository().GetFunction ("ZGET_ANLA");

    if (function == null) throw new RuntimeException ("ZGET_ANLA not found in SAP.");

    System.out.println ("ok");

    } catch (JCoException e) {

      e.printStackTrace ();

    }

 static String createDestinationDataFile (Context context, String destinationName, Properties connectProperties)

   {

       PackageManager m = context.getPackageManager ();

       String str = context.getPackageName ();

       try {

           PackageInfo p = m.getPackageInfo (str, 0);

           str = p.applicationInfo.dataDir;

       } catch (PackageManager.NameNotFoundException e) {

           Log.w ("your tag", "Error Package name not found", e);

       }

       System.setProperty ("jco.destinations.dir", str);

       String f_name = String.valueOf (str + "/" + destinationName);

       File destCfg = new File (str + "/" + destinationName + ". JcoDestination");

       try

       {

           FileOutputStream fos = new FileOutputStream (destCfg, false);

           connectProperties.store (fos, "for tests only!");

           fos.close ();

       }

       catch (Exception e)

       {

           throw new RuntimeException ("Unable to create the destination files", e);

       }

       return f_name;

   }

At programm execute, at string:

JCoDestination jcoDestination = JCoDestinationManager.getDestination (DESTINATION_NAME1);

I'm getting the error -> "library" libdl.so.2 "not found"

E / AndroidRuntime: FATAL EXCEPTION: main
    Process: com.z_fi.zinv_fa, PID: 8455
    java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: dlopen failed: library "libdl.so.2" not found

But the library libdl.so.2 is not include in the SAP JCO archive. (I tried and found the file libdl.so.2 in linux archives. But programm requested next file libdl.so.3, etc. indefinitely)

Questions:

  1. What am I doing wrong?

  2. Which version of SAP JCO I should download - for Linux or for Windows? 32-bit or 64-bit?

  3. Where do I need to import the files of the SAP JCO archive? In the Project structure or in the Device File Explorer (c:\Users***\Documents\AndroidStudio**DeviceExplorer**) ?

  4. Do I need to make settings on the SAP server when using SAp JCO? I don't have access to the SAP server at the OS level ...

Perhaps, maybe there is another option connect to the SAP from Android application?

1 Answer 1

0

from your link provided 4) you have to install 32 bit version of java

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .