Answer the question
In order to leave comments, you need to log in
Importing data into SAP (sap rfc), how to do it?
There is a site that has already configured export from SAP to the site database for several modules.
Getting data from SAP is something like this for these modules:
$data = $this->authorize_sap()->execute_function('МОДУЛЬ');
$data->Call();
$arr = $data->LIST->Export();
private function authorize_sap(){
try{
$this->sap = new SAPConnection;
$this->sap->connectToApplicationServer($this->sap_host, "00");
$this->sap->Open($this->sap_client, $this->sap_login, $this->sap_password, "ru");
if($this->sap->GetStatus() != SAPRFC_OK)
throw new Exception('Connection problem(SAP).');
} catch(Exception $e){
echo $e->getMessage();
}
return $this;
}
private function execute_function($f){
return $this->sap->NewFunction($f);
}
object(SAPFunction)#3 (11) {
["rfc"]=>
resource(7) of type (saprfc handle)
["fce"]=>
resource(8) of type (saprfc function module)
["name"]=>
string(22) "ИМЯ МОДУЛЯ"
["exception"]=>
string(0) ""
["server"]=>
bool(false)
["bapi"]=>
bool(false)
["def"]=>
array(1) {
[0]=>
array(4) {
["name"]=>
string(4) "LIST"
["type"]=>
string(5) "TABLE"
["optional"]=>
int(0)
["def"]=>
array(18) {
[0]=>
array(5) {
["name"]=>
string(5) "MATNR"
["abap"]=>
string(1) "C"
["len"]=>
int(18)
["dec"]=>
int(0)
["offset"]=>
int(0)
}
[1]=>
array(5) {
["name"]=>
string(9) "SERV_CODE"
["abap"]=>
string(1) "C"
["len"]=>
int(10)
["dec"]=>
int(0)
["offset"]=>
int(18)
}
[2]=>
array(5) {
["name"]=>
string(9) "SERV_NAME"
["abap"]=>
string(1) "C"
["len"]=>
int(40)
["dec"]=>
int(0)
["offset"]=>
int(28)
}
[3]=>
array(5) {
["name"]=>
string(9) "SERV_TYPE"
["abap"]=>
string(1) "C"
["len"]=>
int(10)
["dec"]=>
int(0)
["offset"]=>
int(68)
}
... дальше описание полей ...
}
}
}
["status"]=>
int(0)
["statusInfos"]=>
string(0) ""
["debug"]=>
bool(false)
["LIST"]=>
object(SAPTable)#4 (9) {
["fce"]=>
resource(8) of type (saprfc function module)
["name"]=>
string(4) "LIST"
["row"]=>
array(0) {
}
["rowNum"]=>
int(0)
["rowStruct"]=>
array(18) {
[0]=>
string(5) "MATNR"
[1]=>
... перечисление полей ...
}
["rowLast"]=>
int(0)
["status"]=>
int(0)
["statusInfos"]=>
string(0) ""
["debug"]=>
bool(false)
}
}
object(SAPFunction)#3 (10) {
["rfc"]=>
resource(7) of type (saprfc handle)
["fce"]=>
resource(8) of type (saprfc function module)
["name"]=>
string(14) "ИМЯ МОДУЛЯ"
["exception"]=>
string(0) ""
["server"]=>
bool(false)
["bapi"]=>
bool(false)
["def"]=>
array(3) {
[0]=>
array(4) {
["name"]=>
string(3) "NUM"
["type"]=>
string(6) "EXPORT"
["optional"]=>
int(0)
["def"]=>
array(1) {
[0]=>
array(5) {
["name"]=>
string(0) ""
["abap"]=>
string(1) "C"
["len"]=>
int(10)
["dec"]=>
int(0)
["offset"]=>
int(0)
}
}
}
[1]=>
array(4) {
["name"]=>
string(5) "RCODE"
["type"]=>
string(6) "EXPORT"
["optional"]=>
int(0)
["def"]=>
array(1) {
[0]=>
array(5) {
["name"]=>
string(0) ""
["abap"]=>
string(1) "b"
["len"]=>
int(1)
["dec"]=>
int(0)
["offset"]=>
int(0)
}
}
}
[2]=>
array(4) {
["name"]=>
string(4) "DATA"
["type"]=>
string(6) "IMPORT"
["optional"]=>
int(0)
["def"]=>
array(34) {
[0]=>
array(5) {
["name"]=>
string(5) "MANDT"
["abap"]=>
string(1) "C"
["len"]=>
int(3)
["dec"]=>
int(0)
["offset"]=>
int(0)
}
[1]=>
array(5) {
["name"]=>
string(6) "WI_NUM"
["abap"]=>
string(1) "C"
["len"]=>
int(10)
["dec"]=>
int(0)
["offset"]=>
int(3)
}
[2]=>
array(5) {
["name"]=>
string(5) "ERDAT"
["abap"]=>
string(1) "D"
["len"]=>
int(8)
["dec"]=>
int(0)
["offset"]=>
int(13)
}
.. дальше остальные поля ..
}
}
}
["status"]=>
int(0)
["statusInfos"]=>
string(0) ""
["debug"]=>
bool(false)
}
Answer the question
In order to leave comments, you need to log in
Hello, I understand that the question was asked a very long time ago and perhaps it is no longer relevant, but the answer will most likely be of interest to many specialists who are starting their work with SAP systems.
SAP has a number of restrictions on the technologies used, for example, for an RFC call to a functional module (functional modul) or BAPI, the module must have certain properties. Roughly speaking, it must be available for remote calling.
In addition, the module must have a structure or a response table. So, in order to correctly call the module from SAP, it is advisable to talk with a programmer or at least a SAP consultant. If this is not possible, then you need to go into SAP itself and check the called module in transaction se37.
In short, something like this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question