พอดีที่ทำงาน มีโปรเจค โปรเจคหนึ่งที่ต้องใช้ PHP ติดต่อกับ SAP เพื่อไปดึงข้อมูลของ SAP และทำการอับเดตข้อมูลลงไปใน SAP การที่จะใช้ PHP ติดต่อกับ SAP นั้น ต้องใช้ PHP Connector ซึ่งผมเลือกใช้ SAPRFC เป็นตัวติดต่อ
สิ่งจำเป็น สำหรับโปรเจคนี้
1. Appserv (Download Appserv-win32-2.5.10)
2. RFC (Download saprfc-1.4-5.2.0.Win32.zip)
3. Notepad++ (Download)
4. SAP Gui
ขั้นตอน
1. ก่อนอื่น ก็ลง SAP Gui และ Appserv (ถ้ามี SAP Gui แล้วก็ไม่ต้องลง) หลังจากนั้น ไปหา LIBRFC32.dll
ที่ C:\WINDOWS\system32 เอามาใส่ใน C:\AppServ\php5
2. ให้ไปเอา php_saprfc.dll ใน saprfc-1.4-5.2.0.Win32 เอามาใส่ใน C:\AppServ\php5\ext
3. หลังจากนั้นมา set code ที่ php.ini ใน C:\WINDOWS\
3.1 ค้นหา short_open_tag = Off เปลี่ยนค่าเป็น short_open_tag = On
3.2 ค้นหา ;extension = php_xsl.dll เพิ่ม extension=php_saprfc.dll ใต้บรรทัด ;extension = php_xsl.dll
3.3 ค้นหา extension_dir = “./ext” แล้วเปลี่ยนเป็น extension_dir = “C:\AppServ\php5\ext”
4. Restart Apache เป็นอันจบการ Set PHP Connector
ทดสอบ
1. สร้าง Folder phpsap มาไว้ใน C:\AppServ\www
2. นำ Folder saprfc (saprfc-1.4-5.2.0.Win32 Change name is saprfc) มาไว้ใน C:\AppServ\www\phpsap
3. เปิด IE สั่งรัน http://localhost/phpsap/saprfc/example_userlist.php
ถ้า ขึ้น ข้อความตามข้างล่างนี้
SAPRFC-Class: Get List of Users in SAP-System
Errors found during saprfc-Calls:saprfc::login()
Open RFC connection with saprfc_open() failed with error:
RFC Error Info :
Key : rfc system error raised
Status :
Message : for more information: see tracefile dev_rfc
Internal:
แสดงว่า การ config นั้นใช้การได้แล้ว เพียงแต่ ค่า login ที่ส่งให้ SAP ยังไม่ถูกต้อง ให้กลับไปเช็ค code ที่ example_userlist.php ในส่วนของ// Create saprfc-instance $sap = new saprfc(array( "logindata"=>array( "ASHOST"=>"" // application server ,"SYSNR"=>"" // system number ,"CLIENT"=>"" // client ,"USER"=>"" // user ,"PASSWD"=>"" // password ) ,"show_errors"=>false // let class printout errors ,"debug"=>true)) ; // detailed debugging informationหลังจากแก้ไขเรียบร้อยแล้ว ลองสั่งรันไหมอีกครั้ง จะปรากฏข้อความ ชื่อ SAP Name และ User Nummer
SAPRFC-Class: Get List of Users in SAP-System
SAP-Name User-Nummer
DEVSAP01 000000000001
DEVSAP02 000000000002
DEVSAP03 000000000003
DEVSAP04 000000000004
DEVSAP05 000000000005ถ้าขึ้นแบบข้างบนแสดงว่าสามารถติดต่อ SAP ได้แล้วครับ
ผมใช้งาน XAMPP for Windows 5.6.40
Windows 10 (64-bit) ไม่สามารถเชื่อมต่อได้ครับ
มีคำแนะนำอื่นๆ อีกไหมครับ
ขอบคุณครับ
ลองดูข้อมูลจากลิงค์นี้ครับ https://archive.sap.com/discussions/thread/3687454 น่าจะพอช่วยได้
ขึ้น SAPRFC-Extension.dll not loaded. อย่างเดียวเลยหรือผมใช้ Apache ไหม่ไป รบกวนช่วยน่อยคับ