cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using RFC_READ_TABLE function

Former Member
0 Kudos

Hi all,

I am trying to access COEP table through RFC_READ_TABLE function. But it keeps giving me this error:

EXCEPTION DATA_BUFFER_EXCEEDED RAISED

I have been searching a lot in forums and I've red that the problem is the lenght of each row, not the number of rows (and i've checked this by putting ROWCOUNT = 1 in parameters and still gives the same error). Some people suggest to select fewer fields to solve the lenght problem but i don't know how to do that, maybe someone knows how to do it with SAPRFC and can help me?

This is the error if i execute the function in SAP:

http://i.imgur.com/lg9I1.jpg

And here is the code i am using


//////////////////////

// Connection

$sap = new SAPConnection();
$sap->Connect('logon_data.conf');

if ($sap->GetStatus() == SAPRFC_OK) {
	$sap->Open();
}
else {
	$sap->PrintStatus();
	exit;
}

// Function start
$fce = &$sap->NewFunction ('RFC_READ_TABLE');
if (!$fce) {
	$sap->PrintStatus();
	exit;
}

// Table and parameters
$fce->QUERY_TABLE = 'COEP';
$fce->ROWCOUNT = '1';
$fce->Call();

if ($fce->GetStatus() == SAPRFC_OK) {

	$fce->OPTIONS->Reset();
	$fce->FIELDS->Reset();
	$fce->DATA->Reset();
	while ( $fce->DATA->Next() ) {
		echo $fce->DATA->row['FIELDNAME'];
	}
}
else {
	$fce->PrintStatus();
}

$sap->Close();

Sorry for my poor english.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Flavio
Active Contributor
0 Kudos

Hi Matizagon,

Indeed, Alessandro is right. I just tested it using saprfc_test with successful results.

Here the excerpt of code I used:

$rfc = saprfc_open ($login );
if (! $rfc ) { echo "RFC connection failed"; exit; }
//Discover interface for function module RFC_READ_TABLE
$fce = saprfc_function_discover($rfc,"RFC_READ_TABLE");
if (! $fce ) { echo "Discovering interface of function module failed"; exit; }

//Set import parameters. You can use function saprfc_optional() to mark parameter as optional.
saprfc_import ($fce,"DELIMITER","");
saprfc_import ($fce,"NO_DATA","");
saprfc_import ($fce,"QUERY_TABLE","COEP");
saprfc_import ($fce,"ROWCOUNT","20");
saprfc_import ($fce,"ROWSKIPS","");
//Fill internal tables
saprfc_table_init ($fce,"DATA");
saprfc_table_init ($fce,"FIELDS");
saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"BELNR","OFFSET"=>"0","LENGTH"=>"10","TYPE"=>"C","FIELDTEXT"=>""));
saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"BUZEI","OFFSET"=>"10","LENGTH"=>"3","TYPE"=>"N","FIELDTEXT"=>""));
saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"PERIO","OFFSET"=>"13","LENGTH"=>"3","TYPE"=>"N","FIELDTEXT"=>""));
saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"WTGBTR","OFFSET"=>"16","LENGTH"=>"15","TYPE"=>"P","FIELDTEXT"=>""));
saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"OBJNR","OFFSET"=>"31","LENGTH"=>"22","TYPE"=>"C","FIELDTEXT"=>""));
saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"KSTAR","OFFSET"=>"53","LENGTH"=>"10","TYPE"=>"C","FIELDTEXT"=>""));
saprfc_table_init ($fce,"OPTIONS");
saprfc_table_append ($fce,"OPTIONS", array ("TEXT"=>"KOKRS = 'MSTG' AND GJAHR = 2010"));
//Do RFC call of function RFC_READ_TABLE, for handling exceptions use saprfc_exception()
$rfc_rc = saprfc_call_and_receive ($fce);

Good luck!

Flavio

Former Member
0 Kudos

Hi Flavio,

Sorry my poor English, i'm brazilian.

So I need use the OPTIONS table too, but I didn't know how to use.

When I execute my PHP code:

Warning:  CALDBG: Can't find structure item TEXT for interface OPTIONS, __cal_set() in .....

saprfc_import ($fce,"QUERY_TABLE",$Table);

saprfc_import ($fce,"DELIMITER","/");

saprfc_import ($fce,"NO_DATA","");

saprfc_import ($fce,"ROWSKIPS","");

saprfc_import ($fce,"ROWCOUNT","30");

   

//Pass table parameters

saprfc_table_init ($fce,"DATA");       

saprfc_table_init ($fce,"FIELDS");

saprfc_table_init ($fce,"OPTIONS");

saprfc_table_append ($fce,"OPTIONS", array ("TEXT"=>"PERIODO = '201204'"));

       

//Call and execute the function

$rfcresults = saprfc_call_and_receive ($fce);

Can you help me?

Flavio
Active Contributor
0 Kudos

Hi Willians,

Just to understand the issue, could you please test the FM in SE37 with that options, and see what is the result?

Next step could be to run the saprfc_test, with again the same options, and check again the result.

Hope this could help.

Bye,

Flavio

Former Member
0 Kudos

Hi Flavio,

In first thank you so much for your reply.

Yes, the 'PERIODO' is a field of the table '$Table'. Yes when test the FM in SE37 with the options "PERIODO = '201204' I get sucess.

Other information - others softwares work well with  - VB and SAP in the same table and the same server.

But, I'm trying to use PHP + RFCSAP and it's (clause where) not work.

I tried the below but it shows ALL table records.


.....code.....

saprfc_table_init ($fce,"DATA");      

saprfc_table_init ($fce,"FIELDS");

saprfc_table_init ($fce,"OPTIONS");

saprfc_table_append ($fce,"OPTIONS", array ("0"=>"PERIODO = '201204'"));

OR

saprfc_table_append ($fce,"OPTIONS", array ("TEXT"=>"PERIODO = '201204'")); -> show error!

      

//Call and execute the function

$rfcresults = saprfc_call_and_receive ($fce);

...code....

Sorry my English....and...Thanks,


Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you very much to both of you! I was able to fix the problem. Also i didn't know how to use the OPTIONS table, seeing your code now i know.

Thanks again!

Mati

alespad
Contributor
0 Kudos

Hi Matizagon,

you can specifying the List of Field for the Select Statement in SAP,

filling parameter table FIELDS , field FIELDNAME

examples: FIELDS-FIELDNAME = 'BELNR' "document number

FIELDS-FIELDNAME = 'GJAHR' "fiscal year

However i'm not expert about SAPRFC