Application Development and Automation 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: 
Read only

Get data with rfc-sdk language c

Former Member
0 Likes
687

Good morning all,

Me was given a task to develop a simple data read between C and SAP. To foreshadow my prerequisites: I did not work with SAP and only have the possibilities of the NW7.01 Trial with a MaxDB database.

I will use the RFC_READ_TABLE and the RfcCallReceive function. The error handling and opening the rfchandle runs.

Using the RFC_READ_TABLE requires to fill the export parameters and handle the 3 tables, FIELDS, OPTIONS and DATA.

Handling the tables throws the error:

RFC Call/Exception: SYSTEM_FAILURE

Group Error group 104

Key RFC_ERROR_SYSTEM_FAILURE

Message Incorrect field length for 'Remote Function Call'.

After searching here this problem I place 3 structs to define the maximum length, which is returnd by the rfc:


typedef struct tDATA
{	SAP_CHAR	WA[512];
}tDATA;

typedef struct tFIELDS
{	SAP_CHAR	Fieldname[30];
	SAP_CHAR	Offset[6];
	SAP_CHAR	Length[6];
	SAP_CHAR	Type;
	SAP_CHAR	Fiedltext[60];
}tFIELDS;

typedef struct tOPTIONS
{	SAP_CHAR	WA[72];
}tOPTIONS;

Now using the size of these structs the error still stays the same.

So how do I initialise the tables and export parameters, to receive a useable data returned in the DATA table?

The declaration of the export and table structs is left out for now, I will post them immediatly if necessary.

Thanks & Regards

H.Fischer

Edited by: HFischer on Aug 12, 2009 4:09 PM

1 ACCEPTED SOLUTION
Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
619

Well, I'm not familar with C, but I noticed that some of the field names you use are different than the ones in the RFC interface definition.

Table OPTIONS has a field called TEXT, not WA... and table FIELDS has a field called FIELDTEXT, not Fiedltext. May be a typo only.

Again, not sure if this is relevant, just thought it may be related to the error.

4 REPLIES 4
Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
620

Well, I'm not familar with C, but I noticed that some of the field names you use are different than the ones in the RFC interface definition.

Table OPTIONS has a field called TEXT, not WA... and table FIELDS has a field called FIELDTEXT, not Fiedltext. May be a typo only.

Again, not sure if this is relevant, just thought it may be related to the error.

Read only

0 Likes
619

Hi,

thank you for your answer. I changed it but the error is still thrown. During some searches in a C header of the SDK I wondered, if i had to change the datatype because of the unicode implementation I use. But I don't have any idea in which way it could be done.

Thanks for the help.

H.Fischer

Read only

0 Likes
619

Hi all,

I returned to my mind that there was a function embedded in the SDK which generates a headerfile which could be implemented easily. Now I have the structs necessary for the tables but the problem is still the same. I tried some configurations on the termination of the parameter list and I observe that the rfc does not handle with 5 export parameter tables. Here is the parameter declaration I try to use.

At last the tables are terminated with NULL, here I placed it at index 5 but with this the RFC throws an error about the RFC length mentioned in the first post. If I terminate at index 3 the "rfccallreceive" runs without error but returns two empty tables.

Or is it a problem in the declaration of ROWSKIPS and ROWCOUNT?


exporting[0].name = cU("QUERY_TABLE");
exporting[0].nlen = strlen(cU("QUERY_TABLE"));
exporting[0].addr = cU("SPFLI");
exporting[0].leng = strlen(cU("SPFLI"));
exporting[0].type = RFCTYPE_CHAR;
exporting[1].name = cU("DELIMITER");
exporting[1].nlen = strlen(cU("DELIMITER"));
exporting[1].addr = cU(" ");
exporting[1].leng = strlen(cU(" "));
exporting[1].type = RFCTYPE_CHAR;
exporting[2].name = cU("NO_DATA");
exporting[2].nlen = strlen(cU("NO_DATA"));
exporting[2].addr = cU(" ");
exporting[2].leng = strlen(cU(" "));
exporting[2].type = RFCTYPE_CHAR;
exporting[3].name = cU("ROWSKIPS");
exporting[3].nlen = strlen(cU("ROWSKIPS"));
exporting[3].addr = cU("0");
exporting[3].leng = strlen(cU("0"));
exporting[3].type = RFCTYPE_CHAR;
exporting[4].name = cU("ROWCOUNT");
exporting[4].nlen = strlen(cU("ROWCOUNT"));
exporting[4].addr = cU("0");
exporting[4].leng = strlen(cU("0"));
exporting[4].type = RFCTYPE_CHAR;
exporting[5].name = NULL; /*position I mean*/
importing[0].name = NULL;
tables[3].name = NULL;

Read only

0 Likes
619

Hi all again,

after solving the problem I will not keep the solution secret

I used instead of strlen sizeof for the tablename and so it threw an field exception.

Thanks for your help an readings.

If you have further questions about the same problem ask me, maybe I can help you now

Kind regards

HFischer