Is a library (with C programming language interface) callable from within ABAP?
Asked Answered
T

2

6

I have no experience with ABAP programming and I'd like to know whether it's possible to call a 3rd party library with C programming language interface from within an SAP application.

To be more precise, the goal is to use the IBM CPLEX Optimizer (running on local machine) inside an SAP application. The Optimizer is a library and has an API adapted to C++, Java and .NET (C#, VB.NET). I suppose it's a DLL file.

So can you tell me whether it is possible to invoke the functions of an DLL from within an ABAP application?

Threequarter answered 22/2, 2017 at 8:26 Comment(1)
Do you want to have the CPLEX Optimizer run on the client machine or a server=Swahili
L
8

You can use external DLLs directly in a following manner:

 DATA: cmp_dll TYPE ole2_object.
 CREATE OBJECT cmp_dll 'COMPANY.STOCK_DLL'.
 CALL METHOD OF cmp_dll 'check_order' = order
 EXPORTING p_num = 'number'
           p_date = 'date'
           p_vendor = 'vendor'.

Prior to that you should register your DLL in SOLE transaction, it can be registered either on client or on application server (and thus accessible from any client).

The better option may be an RFC wrapper, mentioned by Trixx.
Also it is possible to run C code directly on AS via SXPG_COMMAND_EXECUTE but this is out of the scope of your question.

Lyte answered 22/2, 2017 at 13:34 Comment(2)
Ok, but it looks like this solution requires the DLL to export a COM interface, right? It would not work for any arbitrary DLL, would it?Cleek
Any DLL, COM is not required. Look at this vulnerability proof-of-concept.Lyte
G
4

Yes, that's possible, but only with some own development at external side. For example, you can address and call external programs from ABAP via SAP's RFC protocol. The external program needs to use some SAP Connector SDK for receiving such a Remote Function Call. Then your own program can do whatever you want, of course also use some other programs or libraries.

SAP offers these RFC Connector SDKs for various programming languages and runtime environments:

  • for Java : the SAP Java Connector (JCo)
  • for .NET : the SAP .NET Connector (NCo)
  • for C/C++: the SAP NetWeaver RFC SDK (NW RFC SDK)

Please see https://support.sap.com/connectors for further info.

Gavrielle answered 22/2, 2017 at 10:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.