Call RFC SAP Erp to display Vietnamese UTF-8


To connecting to ERP SAP with Php Programming, we can use saprfc / sapclass Download here .

When data contain Vietnamese languange, the display is unreadable. Cause a HTML tag needs charset UTF-8.

To call SAP RFC using saprfc with UTF-8, you can add a function SetCodePage($codepage)

example file php connect SAP ERP with sapclasses

<? 
include_once("sapclasses2/sap.php"); 
$sap = new SAPConnection(); 
$sap->Connect("sapclasses2/logon_data_qa.conf");
//Change Unicode to UTF-8
$sap->SetCodePage(4110);

		if ($sap->GetStatus() == SAPRFC_OK ){
			$sap->Open ();
		}else{
			echo "Failed to connect SAP";
		}
		$fce = $sap->NewFunction ("Z_ZCSD_SHIPTO");
		if ($fce == false ) {
		   $sap->PrintStatus();
		   exit;
		}

		//Header Entry		
		$fce->ZKTOKD1 = "ZTL1"; 
		$fce->ZKTOKD2 = "ZTL2"; 
		$fce->ZKUNNR = "0000060004";

		$fce->Call();
		if ($fce->GetStatus() == SAPRFC_OK ) {		
			$fce->RETURN_DATA->Reset();
			while ( $fce->RETURN_DATA->Next() ){
				print_r($fce->RETURN_DATA->row);
				echo "";
}
}else $fce->PrintStatus();

$fce->Close();
$sap->Close();

?>

in simple Php programming without call RFC SAP, you can use :

<?

header(‘Content-Type: text/html; charset=utf-8’);

?>

Example Vietnamese sentence :

WordPress là một phần mềm mở và miễn phí để làm blog cá nhân, trang web cá nhân nổi tiếng. WordPress được xây dựng trên sự tiện dụng, cùng với các định dạng chuẩn của web. WordPress sẽ luôn miễn phí và vô giá!

Needs TTF Font? download here

Hope this helpfull😀

BlackPhp

About blackphp

All about programming php, ajax, jquery, mysql, etc, tips n trick. Now, i'm concern in php programming with codeigniter framework n also training my design skill with photoshop or corel... wish me luck! ('o')

Posted on June 20, 2013, in ABAP, PHP, SAP and tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: