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: 

RFC in C++ to SAP doesn t transfer data

Former Member
0 Kudos

Hello,

I make in C++ a RFC call of a function module.

The RFC works but not the data transfer.

The import parameters of the function module in SAP are:

I_MANDT TYPE NUMC3

I_WERKS TYPE CHAR4

I_PROCESS TYPE CHAR10

I_STRING TYPE STRING

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The export definition in the C++ programm is:

exporting[0].name = malloc(7);

memcpy(exporting[0].name,"I_MANDT", 7);

exporting[0].nlen = 7;

exporting[0].type = RFCTYPE_NUM;

exporting[0].leng = 3;

exporting[0].addr = malloc(4);

memset(exporting[0].addr,0,4);

sprintf((char *) exporting[0].addr, "%04d", cst_mandt);

exporting[1].name = malloc(7);

memcpy(exporting[1].name,"I_WERKS", 7);

exporting[1].nlen = 7;

exporting[1].type = RFCTYPE_CHAR;

exporting[1].leng = 4;

exporting[1].addr = malloc(5);

memset(exporting[1].addr,0,5);

sprintf((char *) exporting[1].addr, "%05d", cst_werks);

exporting[2].name = malloc(9);

memcpy(exporting[2].name,"I_PROCESS", 9);

exporting[2].nlen = 9;

exporting[2].type = RFCTYPE_CHAR;

exporting[2].leng = 10;

exporting[2].addr = malloc(11);

memset(exporting[2].addr,0,11);

sprintf((char *) exporting[2].addr, "%11c", cst_process);

exporting[3].name = malloc(8);

memcpy(exporting[3].name,"I_STRING", 8);

exporting[3].nlen = 8;

exporting[3].type = RFCTYPE_CHAR;

exporting[3].leng = 5000;

exporting[3].addr = malloc(5001);

memset(exporting[3].addr,0,5001);

sprintf((char *) exporting[3].addr, "%5001c", chr_line);

rfc_rc = RfcCall( handle, cha_prog,

exporting,

tables);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Does anybody know, where the mistake is, that i don t get the data from the C++ to SAP transferred?

In the debugger in C++ I can see, that the fields are filled.

I would appreciate a quick answer, because the project has to be active in 2 weeks.

Thank you""

best regards

Jasmin Söllner

2 REPLIES 2

Former Member
0 Kudos

I have the same kind of problem. None of my RFC_PARAMETER get passed to my Function. I can see the function is called correctly but the parameter are all set to their corresponding initial values.

Any idea?

0 Kudos

Hello,

I'm not very sure that i understand your problem but using RFC_PARAMETER data structure with export purpose you can not expect any kind of data to be returned by RfcCall().Maybe only you expect some data to be returned on the RFC_TABLE data structure.You just send some parameters to the SAP server.To receive some data you should initialize RFC_PARAMETER data structure for importing purpose and running RfcCallReceive() function.

Another issue is that you don't use one more element in your exporting array which should be initialize with NULL.In the RFC SDK documentation is written that the last element from the array should be NULL. Doesn't matter if is RFC_PARAMETER or RFC_TABLE data structure.

export[4].name=NULL;

I hope this help,

Best Regards,