Foros del Web » Programando para Internet » PHP » Configuración PHP »

Conectar PHP con SAP a traves de RFC

Estas en el tema de Conectar PHP con SAP a traves de RFC en el foro de Configuración PHP en Foros del Web. Hola amigos. Les escribo a ver si alguien me puede ayudar: Necesito Conectarme con SAP a traves de RFC,estoy trabajando con el php 5.0.5 y ...
  #1 (permalink)  
Antiguo 20/01/2010, 07:23
 
Fecha de Ingreso: diciembre-2008
Mensajes: 84
Antigüedad: 15 años, 4 meses
Puntos: 0
Conectar PHP con SAP a traves de RFC

Hola amigos.
Les escribo a ver si alguien me puede ayudar:
Necesito Conectarme con SAP a traves de RFC,estoy trabajando con el php 5.0.5 y Apache/2.0.54 (Win32)
  • El php_saprfc.dll, lo puse en c.../php/ext/ y tambien en c.../php (a sugerencia de algunos amigos de la red).
  • aumente la siguiente linea de codigo en el php.ini: extencion = php_saprfc.dll
  • tambien puse el librfc32.dll en la carpeta system del window.

¿RFC funciona con php 5.0.5?
Alguien tiene un ejemplo , el ejemplo es este pero me falta la configuracion del php.ini ,cambiar de version seria un parto , ya que hay sistema que utilizan la version de php 5.0.5.


<html>
<head>
<title> Get the user list (SM04) using RFC and SOAP</title>
</head>
<body>
This is an example of getting the user list similar to the transaction SM04.
<p>
The example first get the data using SAPRFC and then using the PHP5 SOAP extension.
<?php
// Create the login data for the RFC Connection
$login = array (
"ASHOST"=>"ld0108.wdf.sap.corp",
"SYSNR"=>"18",
"CLIENT"=>"220",
"USER"=>"ASTILL",
"PASSWD"=>"Password",
"R3NAME"=>"LSR",
"GROUP"=>"PUBLIC",
"LANG"=>"EN",
"CODEPAGE"=>"1100");

// Open the connection to the R/3 Server
$rfc = saprfc_open ($login );

if (! $rfc ) {
echo "<b>RFC connection failed</b><br>";
} else {
//Discover interface for function module TH_USER_LIST
$fce = saprfc_function_discover($rfc,"TH_USER_LIST");
if (! $fce ) { echo "Discovering interface of function module failed"; exit; }

//Fill internal tables
saprfc_table_init ($fce,"LIST");

//Do RFC call of function TH_USER_LIST, for handling exceptions use saprfc_exception()
$rfc_rc = saprfc_call_and_receive ($fce);
if ($rfc_rc != SAPRFC_OK) {
if ($rfc == SAPRFC_EXCEPTION ) {
echo ("Exception raised: ".saprfc_exception($fce));
} else {
echo (saprfc_error($fce));
exit;
}
}

//Retrieve export parameters
$rows = saprfc_table_rows ($fce,"LIST");

echo "<p><table border='1'>";
echo "<tr><td>Count</td><td>Client</td><td>Username</td><td>TID</td><td>Time</td><td>Terminal</td><td>Type</td></tr>";

for ($i=1;$i<=$rows;$i++) {
$LIST[] = saprfc_table_read ($fce,"LIST",$i);
}

// Get a key value pair for each row
while(list($num,$row) = each($LIST)) {
// Extract the variables from the array into the current symbol table
extract($row);
echo "<tr><td>$num</td><td>$MANDT</td><td>$BNAME</td><td>$TID</td><td>$ZEIT</td><td>$TERM</td><td>$TYPE</td></tr>";
}
echo "</table>";

saprfc_function_free($fce);
saprfc_close($rfc);
}
flush();

echo "<p>Now use SOAP to make the call to the Web Service<br>";
// Same call using the PHP Web Service
try {
$client = new SoapClient("wsdl11.xml",
array( "login" => "ASTILL",
'trace' => 1,
"password" => "Password") );

// Create the complex array to match the structure defined in the WSDL.
// The function __getTypes() can help describe this structure.
$res = array( "LIST" => array( "UINFO"=>array("TID"=>"",
"MANDT"=>"",
"BNAME"=>"",
"TCODE"=>"",
"TERM"=>"",
"ZEIT"=>"",
"MASTER"=>"",
"HOSTADR"=>"",
"TRACE"=>"",
"EXTMODI"=>"",
"INTMODI"=>"",
"TYPE"=>"",
"STAT"=>"",
"PROTOCOL"=>"",
"GUIVERSION"=>"",
"RFC_TYPE"=>"")));
$res = $client->TH_USER_LIST($res);

// At this point we have an object.
$lst = $res->LIST->item;

echo "<br><table border='1'>";
echo "<tr><td>Count</td><td>Client</td><td>Username</td><td>TID</td><td>Time</td><td>Terminal</td><td>Type</td></tr>";

// Get a key value pair for each row
while(list($num,$row) = each($lst)) {
// Extract the variables from the array into the current symbol table
echo "<tr><td>$num</td><td>$row->MANDT</td><td>$row->BNAME</td><td>$row->TID</td><td>$row->ZEIT</td><td>$row->TERM</td><td>$row->TYPE</td></tr>";
}
echo "</table>";
} catch (SoapFault $exception) {
echo "<p>Exception<br>";
echo $exception;
echo "<p>Request :<br>", htmlspecialchars($client->__getLastRequest()), "<br>";
echo "Response :<br>", htmlspecialchars($client->__getLastResponse()), "<br>";
}
?>
<p>
If both calls were successful you will see that the connection for the user differs in type. Type 32 for the RFC call and type 202 for the Web service.
</body>
</html>
  #2 (permalink)  
Antiguo 20/01/2010, 09:52
 
Fecha de Ingreso: enero-2009
Mensajes: 455
Antigüedad: 15 años, 2 meses
Puntos: 11
Respuesta: Conectar PHP con SAP a traves de RFC

Ok, ya te respondi rápidamente por MP, pero vamos por partes lcisternas para ver si podemos encontrar el error, siguiendo un pequeño manual que hice hace tiempo para la instalación xD, dice mas o menos:

1. Se deberá contar con el siguiente DLL. “php_saprfc.dll” en cual deberá ser agregado a la carpeta C:/xampp/php/ext

aqui uso xampp lcisternas

2. De manera similar, dentro de C:/xampp/php y C:/xampp/apache/bin se deberá de editar el archivo php.ini y agregar la siguiente línea:

extension=php_saprfc.dll

3. Reiniciar el servicio de apache con la ayuda de XAMPP

hasta este punto si le das un info a tu php te debería de mostrar que ya tienes instalada la extensión de SAP

si?

Cita:
aumente la siguiente linea de codigo en el php.ini: extencion = php_saprfc.dll
ahi tienes una c por una s, igual y puede ser eso
  #3 (permalink)  
Antiguo 25/03/2010, 01:08
 
Fecha de Ingreso: enero-2002
Mensajes: 88
Antigüedad: 22 años, 3 meses
Puntos: 0
Respuesta: Conectar PHP con SAP a traves de RFC

Ha pasado tiempo desde tu post, pero si no lo has solucionado quizá podamos ayudarnos.
La parte de tu código referente al RFC funciona sin problemas.
Si ejecutas un "<? phpinfo() ?>" en la configuración de PHP ¿te muestra que tengas cargado el módulo "saprfc"?.
Si no es así, quizá debamos empezar por ahí.
En otro caso, debemos analizar el error que te pueda dar esta página. Yo tengo alginas rutinas para leer tablas y no me dan problemas.

Y ahora para mí; ¿me podrías pasar el fichero "wsdl11.xml" de tu ejemplo?

Saludos,
-ArtuAgui-
  #4 (permalink)  
Antiguo 11/06/2010, 14:12
 
Fecha de Ingreso: junio-2010
Mensajes: 2
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Conectar PHP con SAP a traves de RFC

me da este error la funcion de arriba
This is an example of getting the user list similar to the transaction SM04.
The example first get the data using SAPRFC and then using the PHP5 SOAP extension.
Fatal error: Call to undefined function saprfc_open() in C:\AppServ\www\CODIGO\Cap06\test_conectar_sap.php on line 23

en phpinfo() no aparece saprfc. por donde sigo?
Gracias
  #5 (permalink)  
Antiguo 11/06/2010, 18:28
 
Fecha de Ingreso: marzo-2010
Ubicación: Lima, Perú
Mensajes: 136
Antigüedad: 14 años, 1 mes
Puntos: 2
Respuesta: Conectar PHP con SAP a traves de RFC

Cita:
Iniciado por edkon Ver Mensaje
me da este error la funcion de arriba
This is an example of getting the user list similar to the transaction SM04.
The example first get the data using SAPRFC and then using the PHP5 SOAP extension.
Fatal error: Call to undefined function saprfc_open() in C:\AppServ\www\CODIGO\Cap06\test_conectar_sap.php on line 23

en phpinfo() no aparece saprfc. por donde sigo?
Gracias
has corregido lo de la c por la s

EXTENSION
  #6 (permalink)  
Antiguo 11/06/2010, 23:49
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Tema movido desde PHP orientado a objetos a Configuración PHP
  #7 (permalink)  
Antiguo 14/06/2010, 09:54
 
Fecha de Ingreso: junio-2010
Mensajes: 2
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Conectar PHP con SAP a traves de RFC

Gracias ya configure el saprfc ahora aparece en el pinfo()
pero la funcion de arriba me da ahora

This is an example of getting the user list similar to the transaction SM04.
The example first get the data using SAPRFC and then using the PHP5 SOAP extension.
Warning: RFC Error Info : Group : 101 Key : RFC_ERROR_PROGRAM Message : Open file 'C:\WINDOWS\sapmsg.ini' failed in C:\AppServ\www\CODIGO\Cap06\test_conectar_sap.php on line 23
RFC connection failed


Now use SOAP to make the call to the Web Service

Fatal error: Class 'SoapClient' not found in C:\AppServ\www\CODIGO\Cap06\test_conectar_sap.php on line 72

el archivo sapmsg.ini no lo tengo en windows
saludos

Etiquetas: php, rfc, sap
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:17.