Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

External program communication

Former Member
0 Kudos

Hi all,

For a SAP project I need to establish an connection to an existing Delphi program (Delphi 7), send and receive data in various formats.

After searching the web for info ( I am new to ABAP programming ) I could not find very much info on how to realize this.

I believe that I need to write a RFC-server to handle the RFC's from SAP.

I found the site: http://www.bapi.is-here.de/ which is recommended by a couple of people, but this site only provides the components and examples for connecting to SAP from a Delphi application (or am I missing something?).

An other site I found was http://www.shareit.com/programs.html?productid=192748&language=English where it is possible to obtain components to write external client- as well as server apllications. With the trial version components, I succeeded to write a server which connects to SAP, receives a function call with parameters and returns some parameters.

Before we purchase the licence for the components I would like to know if this is the way to go, or if there is an other way to realise this.

Greetings Fred.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Fred,

Actually there are many methods to get data from or send it to an SAP system. You're very close to one of the solutions.

SAP knows many BAPI's and RFC enabled function modules. For instance the function module RFC_READ_TABLE can be used to extract data from any (allowed) SAP table.

Now if you are inside SAP (via SAP GUI) you can call transaction SE37 and fill in the name of the BAPI or Function module.

Try it with the fm RFC_READ_TABLE.

Pres the button Display.

In the menu follow the path: Utillities --> RFC Interface --> Generate

In the dialog you can choose for C or Visual Basic interfaces for client or server based programs.

If the Java extensions have been implemented, Java is also possible.

As you can see, not for Pascal (or Delphi).

However, the VB versions give you a pretty good idea on how to build your interface.

Keep in mind, that you will need the RFCLIB32 library to make use of this type of interface.

Oh, and your interface communicates with the application server of SAP, but the functions inside the library can be based on any machine, providing you set the correct connection details.

Of course you can write your own function module, but you need some more knowledge on SAP to do so.

Hope this gives you a start,

Regards,

Rob.

7 REPLIES 7

Former Member
0 Kudos

Hi Fred,

Actually there are many methods to get data from or send it to an SAP system. You're very close to one of the solutions.

SAP knows many BAPI's and RFC enabled function modules. For instance the function module RFC_READ_TABLE can be used to extract data from any (allowed) SAP table.

Now if you are inside SAP (via SAP GUI) you can call transaction SE37 and fill in the name of the BAPI or Function module.

Try it with the fm RFC_READ_TABLE.

Pres the button Display.

In the menu follow the path: Utillities --> RFC Interface --> Generate

In the dialog you can choose for C or Visual Basic interfaces for client or server based programs.

If the Java extensions have been implemented, Java is also possible.

As you can see, not for Pascal (or Delphi).

However, the VB versions give you a pretty good idea on how to build your interface.

Keep in mind, that you will need the RFCLIB32 library to make use of this type of interface.

Oh, and your interface communicates with the application server of SAP, but the functions inside the library can be based on any machine, providing you set the correct connection details.

Of course you can write your own function module, but you need some more knowledge on SAP to do so.

Hope this gives you a start,

Regards,

Rob.

0 Kudos

Hi Fred, if you want to use the method recommended by Rob, I have an already generated RFC_read_table component that I can give to you. It is a C++ COM object which means you can also reference it in any COM compliant application (delphi, VB, etc).

Let me know if you want the component and sample source code on how to use it.

It is actually quite simple. I can also post the code to the forum if others are itnerested...

Regards,

Sam

0 Kudos

Samuel,

I'm interested, of course ..

So if you could post it for me and other members of this forum, would be much obliged.

Gteetz,

Rob.

0 Kudos

OK. The only way I know on how to attach a document (I will zip the component) for the forum is to submit it to the contribution center. I will package the content tonight and try to figure it out tommorow on how to pass it to the forum.

Please standby...

Regards,

Sam

0 Kudos

Hi Sam,

It would be great if you could post the code, I believe that (including me) there will be a lot of people who are interested.

@Rob: I can not find the path you specified in the menu when I display the function module. Does it matter which version I am using? I am using SAPBasis 6.2 and SAP version 4.7. If I can find this RFC-interface generate function it would help me a lot.

The answers until now are about connecting from an external application (in my case written in Delphi) and using an interface to use an SAP function. This is an functionality we also want to use and I thank you for that.

But the RFC-server I mentioned in my question is to be written in Delphi and I want to connect from SAP to my Delphi server application and use an function inside my Delphi application.

I was already succesfull with that with the trial-components I mentioned in my question, but I want to know if there is an other way to realise this. The components create some sort of wrapper to communicate with the RFC-library (written in the c-language) which is in the RFCSDK.

I found quite a collection of ActiveX components in the RFCSDK as well, but I do not believe they will allow me to communicate from SAP to Delphi.

I have installed SAPLogon components and SAPFunctions components and am able to (I repeat myself) call an function in the SAP system, but not the other way around.

When I connect to the SAP system with the ActiveX comps I can see the connection in the Gateway Monitor as an active connection and as an connected client.

My other server application (with trial comps) is not visible as an active connection, but only as an connected client. This client connection has an register status WAITING in contrast to the ActiveX connection which has no register info at all.

Can anyone explain these differences to me?

Thanx,

Fred

0 Kudos

Fred,

Here's the link to download the sample code written in VB for reading SAP data using RFC. Like you said, you are already able to achieve this, but this code might be beneficial to other.

http://www.samsole.com/dev2dev.html#SAPRFC

Now with regards to calling RFC servers from SAP, this is actually quite easy to do.

The steps are fully documented in the SAP DCOM Connector documentation under "COM4ABAP" (sorry I am antiquated. .Net connector is more up to date, but I only have experience doing this in DCOM connector 6.40) Sample codes also provide in the documentation.

In general you need:

<b>librfc32.dll</b> :RFC communication with com4abap

<b>com4abap.exe</b>: you can run this as a client or service on the application server

<b>typemap.exe</b>: Type mapping between ABAP and COM data types

<b>DCOM Connector 4.6D or higher</b>.

<b>R/3 version 4.6B or higher</b> (not sure about anything higher than 4.7.)

<b>Steps:</b>

(0) First apply a special transport to your system. This transport contains a function group necessary for outbound communications. It is available on request from SAP.

(1) Configure com4abap.exe with rfc connection info.

(2) Install com4abap.exe as a service or just run it.

(3) Do type mapping between your COM component and ABAP data types.

(4) Create an RFC destination in SAP (SE59)

(5) Write ABAP code to call your COM component. (see sample code in the documentation)

Try this out and let me know how it works for you...

Good luck,

Sam

0 Kudos

Fred,

I've searched through 4.7 but could not find it. Maybe others know where to find this.

However here are some usefull links (from SAP Help).

If you need more try searching on RFC API within the help.

RFC Tutorial:

http://help.sap.com/saphelp_47x200/helpdata/en/72/90fd343603c95ee10000009b38f844/frameset.htm

The RFC API:

http://help.sap.com/saphelp_47x200/helpdata/en/22/04280f488911d189490000e829fbbd/frameset.htm

Hope this helps you a bit,

Regards,

Rob.