Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > อยากรู้วิธีเขียน PHP เชื่อมกับ BAPI ของ SAP ครับ Call หา Web service ได้แล้ว แต่ไม่รู้จะโยนค่าเข้าไปยังไง?



 

อยากรู้วิธีเขียน PHP เชื่อมกับ BAPI ของ SAP ครับ Call หา Web service ได้แล้ว แต่ไม่รู้จะโยนค่าเข้าไปยังไง?

 



Topic : 135469



โพสกระทู้ ( 56 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook



เหมือนผมเรียกมันได้แล้วแต่ไม่รู้จะโยนค่าเข้าไปยังไง ขอบคุณครับ

Code (XML)
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:n1="urn:sap-com:document:sap:rfc:functions" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
<wsdl:documentation>
<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/>
</wsdl:documentation>
<wsdl:types>
<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
...
</xsd:schema>
<xsd:schema xmlns:n0="urn:sap-com:document:sap:rfc:functions" attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
<xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>
<xsd:complexType name="Zk2ReservationHeader">
<xsd:sequence>
<xsd:element name="Plant" type="n0:char4"/>
<xsd:element name="ResDate" type="n0:date10"/>
<xsd:element name="MoveType" type="n0:char3"/>
<xsd:element name="GrRcpt" type="n0:char12"/>
<xsd:element name="CostCtr" type="n0:char10"/>
<xsd:element name="AssetNo" type="n0:char12"/>
<xsd:element name="SubNumber" type="n0:char4"/>
<xsd:element name="OrderNo" type="n0:char12"/>
<xsd:element name="MovePlant" type="n0:char4"/>
<xsd:element name="MoveStloc" type="n0:char4"/>
<xsd:element name="CreatedBy" type="n0:char12"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Bapireturn">
<xsd:sequence>
<xsd:element name="Type" type="n0:char1"/>
<xsd:element name="Code" type="n0:char5"/>
<xsd:element name="Message" type="n0:char220"/>
<xsd:element name="LogNo" type="n0:char20"/>
<xsd:element name="LogMsgNo" type="n0:numeric6"/>
<xsd:element name="MessageV1" type="n0:char50"/>
<xsd:element name="MessageV2" type="n0:char50"/>
<xsd:element name="MessageV3" type="n0:char50"/>
<xsd:element name="MessageV4" type="n0:char50"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Zk2ReservationItems">
<xsd:sequence>
<xsd:element name="MaterialLong" type="n0:char40"/>
<xsd:element name="Plant" type="n0:char4"/>
<xsd:element name="StoreLoc" type="n0:char4"/>
<xsd:element name="Batch" type="n0:char10"/>
<xsd:element name="Quantity" type="n0:quantum13.3"/>
<xsd:element name="Unit" type="n0:unit3"/>
<xsd:element name="ReqDate" type="n0:date10"/>
<xsd:element name="ShortText" type="n0:char50"/>
<xsd:element name="UnloadPt" type="n0:char25"/>
<xsd:element name="FixedQuan" type="n0:char1"/>
<xsd:element name="Movement" type="n0:char1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TableOfBapireturn">
<xsd:sequence>
<xsd:element name="item" type="tns:Bapireturn" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TableOfZk2ReservationItems">
<xsd:sequence>
<xsd:element name="item" type="tns:Zk2ReservationItems" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Zk2BapiIbReservation">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EtReturn" type="tns:TableOfBapireturn" minOccurs="0"/>
<xsd:element name="IHeader" type="tns:Zk2ReservationHeader"/>
<xsd:element name="It_Items" type="tns:TableOfZk2ReservationItems"/>
<xsd:element name="Testrun" type="n0:char1" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Zk2BapiIbReservationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EReservation" type="n0:numeric10"/>
<xsd:element name="EtReturn" type="tns:TableOfBapireturn" minOccurs="0"/>
<xsd:element name="It_Items" type="tns:TableOfZk2ReservationItems"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="Zk2BapiIbReservation">
<wsdl:part name="parameters" element="tns:Zk2BapiIbReservation"/>
</wsdl:message>
<wsdl:message name="Zk2BapiIbReservationResponse">
<wsdl:part name="parameter" element="tns:Zk2BapiIbReservationResponse"/>
</wsdl:message>
<wsdl:portType name="Z_Create_Reservation">
<wsdl:operation name="Zk2BapiIbReservation">
<wsdl:input message="tns:Zk2BapiIbReservation"/>
<wsdl:output message="tns:Zk2BapiIbReservationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Z_Create_Reservation_bln" type="tns:Z_Create_Reservation">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="Zk2BapiIbReservation">
<soap:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:Z_Create_Reservation:Zk2BapiIbReservationRequest" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="Z_Create_Reservation_bln_soap12" type="tns:Z_Create_Reservation">
<wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="Zk2BapiIbReservation">
<wsoap12:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:Z_Create_Reservation:Zk2BapiIbReservationRequest" style="document"/>
<wsdl:input>
<wsoap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsoap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Z_Create_Reservation">
<wsdl:port name="Z_Create_Reservation_bln" binding="tns:Z_Create_Reservation_bln">
<soap:address location="http://test/z_create_reservation_bln"/>
</wsdl:port>
<wsdl:port name="Z_Create_Reservation_bln_soap12" binding="tns:Z_Create_Reservation_bln_soap12">
<wsoap12:address location="http:/test/z_create_reservation_bln"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>



Code (PHP)
$wsdl     = 'test?sap-client=200';
        $SOAP_CONFIG = array(
            'login' => 'test01',
            'password' => '*******',
            'authentication' => SOAP_AUTHENTICATION_BASIC,
            'soap_version' => SOAP_1_1,
            'connection_timeout' => 15,
            'encoding' => 'UTF-8'
        );

$client = new \SoapClient($wsdl, $SOAP_CONFIG);




Tag : PHP, Web Services, Laravel Framework









ประวัติการแก้ไข
2020-08-17 15:33:37
2020-08-17 15:34:11
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2020-08-17 15:32:15 By : popfanta View : 1299 Reply : 2
 

 

No. 1



โพสกระทู้ ( 56 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ได้แล้วนะครับ

Code (PHP)
$client = new \SoapClient($wsdl, $SOAP_CONFIG);
        echo '<pre>';
        var_dump($client->__getFunctions());
        echo '</pre>';
        $head = new \stdClass();
        $head->Plant="1100";
        $head->ResDate="2020-08-17";
        $head->MoveType="241";
        $head->GrRcpt="test";
        $head->CostCtr="3191112";
        $head->AssetNo="000099900001";
        $head->SubNumber="";
        $head->OrderNo="";
        $head->MovePlant="";
        $head->MoveStloc="";
        $head->CreatedBy="";


        $detail = new \stdClass(); 
        $detail->MaterialLong = 'C21-MCAA151';
        $detail->Plant = '2100';
        $detail->StoreLoc = 'F131';
        $detail->Batch = '';
        $detail->Quantity = '5';
        $detail->ReqDate = '2020-08-17';
        $detail->Unit = 'ST';
        $detail->ShortText = 'qweasd';
        $detail->UnloadPt = '';
        $detail->FixedQuan = '1';
        $detail->Movement = '1';

        $de[] = $detail;


        $detail = new \stdClass(); 
        $detail->MaterialLong = 'C21-SWAA001';
        $detail->Plant = '2100';
        $detail->StoreLoc = 'F131';
        $detail->Batch = '';
        $detail->Quantity = '10.00';
        $detail->ReqDate = '2020-08-17';
        $detail->Unit = 'ST';
        $detail->ShortText = 'qweasd';
        $detail->UnloadPt = '';
        $detail->FixedQuan = '1';
        $detail->Movement = '1';

        $de[] = $detail;

        $re = new \stdClass(); 
        $re->item = '';

        $main = new \stdClass();
        $main->IHeader = $head;
        $main->It_Items = $de;
        $main->EtReturn = $re;

        $result = $client->Zk2BapiIbReservation($main);


ประมาณนี้






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2020-08-17 17:31:50 By : popfanta
 


 

No. 2



โพสกระทู้ ( 1,458 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook Blogger

มีหลายวิธีมากครับ...แต่ผมไม่เคยพิสูจน์นะว่าอันไหน ไม่ดี ช้า ซับซ้อน ที่สุด
map object ก็ดีนะครับ ข้อมูลจะได้เป็นระบบระเบียบ
https://www.php.net/manual/en/soapvar.soapvar.php

https://stackoverflow.com/questions/11593623/how-to-make-a-php-soap-call-using-the-soapclient-class

BAPI แบบละเอียด
http://www.planetsap.com/LIST_ALL_BAPIs.htm
http://saptechnical.com/Tutorials/BAPI/BAPIMainPage.htm

การเชื่อมต่อจาก PHP7
https://a.kabachnik.info/how-to-connect-to-sap-from-php7.html



ส่วนตัวชอบ sapRFC แม้จะจัดการได้ไม่ละเอียดเท่า BAPI แต่มีให้ค้นง่าย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2020-08-17 17:42:20 By : PhrayaDev
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากรู้วิธีเขียน PHP เชื่อมกับ BAPI ของ SAP ครับ Call หา Web service ได้แล้ว แต่ไม่รู้จะโยนค่าเข้าไปยังไง?
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่