1

Is there a possibility to load a dynamic shared object/library from a file on the application server and load it's functions (i.e. a Foreign Function Interface) from ABAP?

I am aware that you can call kernel functions with the CALL statement, but perhaps there are functions in the kernel that support loading libraries and calling their functions?

2
  • You did consider that the kernel may run on a Linux, Windows NT, AS/400, Solaris or several other operating systems? :-)
    – vwegert
    Jul 16, 2015 at 9:40
  • @vwegert All the implementations of FFI that I am aware of in various languages (e.g. Ruby, Python, Lua, Red, Haskell etc.) are cross-platform. This depends of course on loading the binary in a platform-specific way. (I used Ruby FFI for example to develop a wrapper around the NW RFC SDK library which works across platforms: github.com/mydoghasworms/nwrfc) Jul 16, 2015 at 19:05

1 Answer 1

2

I'm not aware of a kernel function that would let you do that. There may be one but kernel functions are certainly not publicly documented so you'd need to do your own exploration of the disp+work executable to see if one exists. And if you find one, you'd then need to determine what the parameters are. Not an easy task. If you're up for exploring, I'd probably do it on a Linux system and use objdump and elfsh as my starting toolset.

If I was trying to implement something like what you describe, I'd write a generic "library loader" RFC server in C using the NetWeaver RFC SDK. I'd use C, because it would give the most flexibility loading the external library. You'd need to handle the OS-specific portions of loading the library (eg, using dlopen() on a Unix system, LoadLibrary() / LoadLibraryEx on Windows), but you could then wrap the library functions in generic function module calls (ala, RFC_READ_TABLE) and call them dynamically.

5
  • I am busy poring over an nm dump of disp+work at the moment :-) There are just too many functions, and you are right, without documentation one cannot make sense of most of them, especially if you don't know their signatures. I also think that there is a whitelist of kernel functions somewhere you can invoke with CALL. That means you couldn't get access to LIBC functions directly :-/ Will try though anyway. Jul 16, 2015 at 12:43
  • But thanks for the pointer (NPI) to dlopen(). Going to look at now. Jul 16, 2015 at 12:46
  • 1
    Indeed, there is a whitelist of ABAP-callable kernel functions (contained in sapactab.h in the kernel source).
    – mjturner
    Jul 16, 2015 at 13:15
  • Going to carry on this conversation here if you want to join :-) scn.sap.com/thread/3771698 Jul 16, 2015 at 13:18
  • PS, I did not get your idea about the generic loader RFC service the first time round, but it sounds like quite a smart idea. +1 Jul 16, 2015 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.