Skip to Content

Function over RFC Call

Hi.

I try to call an Function in SAP over a RFC Call in C++.

I established a connection via RFC and can send the call.

This is my request:

rfc_rc = RfcCall( handle, cha_prog,exporting, tables);

The function i called in SAP requires an importing parameter. So tried to put the format into the exporting parameter but i don`t know how?

My field definition in SAP is:

Parametername: I_IM_ID

TYPE: CHAR(4)

How do i call the RFC correctly with an exporting paramter?

I tried the follwing code

exporting[0].name = "I_IM_ID";

exporting[0].nlen = 7;

exporting[0].type = RFCTYPE_CHAR;

but it doesn`t work.

Where have my value stand, which i want to export to the function?

Is it the "exporting[0].addr" field?

The value i want to export is put in a CString variable called cst_over;

Can someone post the correctly code for an correct RFC call?

I don`t know, if this is the right forum, if not i am sorry.

Greetz

Stefan

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Aug 16, 2004 at 05:09 PM

    Hi Stefan,

    You need to allocate space for the parameter value to be received into, on exporting[0].addr:

    Something like:

    exporting[0].addr = malloc(<parm len> + 1);

    memset(exporting[0].addr,0, <parm len> + 1);

    Cheers.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi thanks,

      and in which parameter is the value itself set?

      The length of my parameter i want to export is always 4

      so the coding have to look like

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

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

      What is missed?

      Perhaps you can post an correctly RFC Call Coding?

      With my parameters.

      I am looking forward to your answer thank you!

      Greetz

      Stefan

  • avatar image
    Former Member
    Aug 17, 2004 at 07:19 AM

    Hi Stefan,

    Can you go into SE37 and display the source code of your RFC, and cut-n-paste the comment section at the top that describes the interface of the Function Module, into your next post on the Forum. Then I'll code up the interface for you.

    Cheers,

    Piers Harding.

    Add comment
    10|10000 characters needed characters exceeded

    • For all here is a code that works.

      The error was that i dont send the "exporting[1].name = (char *)0;" value which shows that this is the last export parameter....

      here a full working coding

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

      memcpy(exporting[0].name,"I_RACKID", 8);

      exporting[0].nlen = 8;

      exporting[0].type = RFCTYPE_NUM;

      exporting[0].leng = 4;

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

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

      int_racid = value->get_racid();

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

      exporting[1].name = (char *)0;

      Thanks for all!