我正在使用函数模块通过 RFC 与 PHP 通信。我尝试将中文字符从函数模块发送到 PHP,但在 PHP 端,我以 ###### 的形式获取中文字符,
我不明白问题出在哪一边,PHP 端还是 SAP 端?任何人都给我建议我需要关注哪方面来纠正这个问题?或任何其他方式将汉字发送到PHP?
SAP FM 代码:FN 名称:ZMM_PHP_TO_SAP
t_log-msgty = 'E'.
CONCATENATE p_uname '用户无检料权限' INTO t_log-msgtx SEPARATED BY space.
APPEND t_log.
PHP代码:
$LOGIN = array ("ASHOST"=>$row_login1["sap_server"],
"SYSNR"=>$row_login1["sap_system_number"],
"CLIENT"=>$row_login1["sap_client"],
"USER"=>$row_login1["sap_username"],
"PASSWD"=>$row_login1["sap_password"],
"CODEPAGE"=>"8300");
$rfc = saprfc_open ($LOGIN);
if(!$rfc){
$error=saprfc_error();
return "The RFC connection has failed with the following error:".saprfc_error();
exit;}
$fce = saprfc_function_discover($rfc,"ZMM_PHP_TO_SAP");
if(!$fce){
return "The function module has failed.";
return $rfc;
exit;}saprfc_import ($fce,"P_UNAME","demo-china");
saprfc_table_init ($fce,"T_LOG");
// Call and execute the function
$rc = saprfc_call_and_receive ($fce);
if ($rfc_rc != SAPRFC_OK){
if ($rfc == SAPRFC_EXCEPTION ){
echo ("Exception raised: ".saprfc_exception($fce));
} else {
echo ("Call error: ".saprfc_error($fce));
}
echo "failure";
exit;
}
$data_row = saprfc_table_rows ($fce,"T_LOG");
$log_msg='';
if($data_row != 0 || $data_row != '')
{
for ($i=1; $i<=$data_row; $i++)
{
$DATA = saprfc_table_read ($fce,"T_LOG",$i);
echo $DATA['MSGTX'];
if($DATA['MSGTY'] == "E")
{
$log_msg =$DATA['MSGTX'];
}
if($DATA['MSGNO'] == "D")
{
$log_msg ="D";
}
}
}
尝试打印 $DATA['MSGTX'] 时,输出为 DEMO-CHINA ¥Î###®Æ# ,如何获得准确的汉字。提前致谢。