cancel
Showing results for 
Search instead for 
Did you mean: 

RfcRegisterServer exited with error

Former Member
0 Kudos

Hi!

My problem is as follows. I am using NW RFC SDK 64bit to create my own RFC Server application. I have installed SAP ABAP Trial 7.03 for testing and have created destination with name "TestRFC" which uses TCP/IP Connection. in my sapnwrfc.ini file I have saved the following text:

DEST=TestRFC
TYPE=R
GWSERV=3300
GWHOST=192.168.3.73

PROGRAM_ID=TestRFCSERVERID


In my source code I have prepared structure RFC_CONNECTION_PARAMETER in the following maner:

RFC_CONNECTION_PARAMETER m_oGatewayParams[1];

m_oGatewayParams[0].name = cU("DEST");

m_oGatewayParams[0].value = cU("TestRFC");


After that I call RfcRegisterServer function:

m_hRFCConn = ::RfcRegisterServer(m_oGatewayParams,1,&Err);


When I debug my application and reach the line with

RfcRegisterServer, the result of its execution is the error with the following description:

RFC_INVALID_PARAMETER

Parameter ASHOST, GWHOST or MSHOST is missing.


How can I fix this error?
P.S. I am using Visual Studio 2010 in Windows7 x64, SAP gateway is launched in virtual machine with IP-address 192.168.3.73, which is available. Moreover, I succeded to register my server using rfcexec.exe tool with the following command line:

rfcexec -a TestRFCSERVERID -g 192.168.3.73 -x 3300

Accepted Solutions (0)

Answers (2)

Answers (2)

isaias_freitas
Advisor
Advisor

Hello,

To me it worked. I could see my program registered at the transaction SMGW -> goto -> logged on clients.

Here is the complete code of my program:

#include <stdio.h>
#include <unistd.h>
#include "c:\path\to\rfc\nwrfcsdk\include\sapnwrfc.h"

int main(int argc, SAP_UC** argv) {
    RFC_CONNECTION_PARAMETER m_oGatewayParams[1];
    RFC_ERROR_INFO Err;
    m_oGatewayParams[0].name = cU("DEST");
    m_oGatewayParams[0].value = cU("TestRFC");
    RFC_CONNECTION_HANDLE m_hRFCConn;

    RfcInit();
    m_hRFCConn = RfcRegisterServer(m_oGatewayParams,1,&Err);
    if (m_hRFCConn == NULL) {
        printf("Error when opening an RFC connection!");
        RfcCloseConnection(m_hRFCConn, &Err);
        return 1;
    }
    
    //sleep 5s so I can see the program registered at SMGW
    sleep(5);
    printf("It worked.");
    RfcCloseConnection(m_hRFCConn, &Err);

    return 0;
}

And here the contents of my "sapnwrfc.ini" file:

DEST=TestRFC
TYPE=R
GWSERV=3330
GWHOST=<IP of my VM>
PROGRAM_ID=TestRFCSERVERID
<blank line at the end>

What I did differently:

  1. I first just declared the handle (RFC_CONNECTION_HANDLE m_hRFCConn;);
  2. I called the function "RfcRegisterServer()" only after RfcInit();
  3. I removed a blank line between "GWHOST" and "PROGRAM_ID" at the "ini" file;
  4. My "ini" file has a blank line at the end.


I hope this helps.

Best regards,
Isaías

isaias_freitas
Advisor
Advisor
0 Kudos

OK, calling RfcInit() is not required, actually.

isaias_freitas
Advisor
Advisor
0 Kudos

PS: about the tags you used at this question, please change it to "ABAP Connectivity". Only now I have realized that you used the CST tag 🙂 thanks!

isaias_freitas
Advisor
Advisor
0 Kudos

Hello,

Can you please provide the complete sample code?

Regards,

Isaías

Former Member
0 Kudos

RFC_CONNECTION_PARAMETERm_oGatewayParams[1];
RFC_ERROR_INFO Err;
m_oGatewayParams[0].name = cU("DEST");
m_oGatewayParams[0].value = cU("TestRFC");
RFC_CONNECTION_HANDLE m_hRFCConn = RfcRegisterServer(m_oGatewayParams,1,&Err);

Former Member
0 Kudos

I have even tried to build my version of rfcexec from existing source code and the error is the same, regardless to the fact that the use of "rfcexec.exe" from NW RFC SDK is correct.