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,038

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


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

 
Topic : 135469



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



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


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

Code (XML)
001.<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">
002.<wsdl:documentation>
003.<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/>
004.</wsdl:documentation>
005.<wsdl:types>
006.<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
007....
008.</xsd:schema>
009.<xsd:schema xmlns:n0="urn:sap-com:document:sap:rfc:functions" attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
010.<xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>
011.<xsd:complexType name="Zk2ReservationHeader">
012.<xsd:sequence>
013.<xsd:element name="Plant" type="n0:char4"/>
014.<xsd:element name="ResDate" type="n0:date10"/>
015.<xsd:element name="MoveType" type="n0:char3"/>
016.<xsd:element name="GrRcpt" type="n0:char12"/>
017.<xsd:element name="CostCtr" type="n0:char10"/>
018.<xsd:element name="AssetNo" type="n0:char12"/>
019.<xsd:element name="SubNumber" type="n0:char4"/>
020.<xsd:element name="OrderNo" type="n0:char12"/>
021.<xsd:element name="MovePlant" type="n0:char4"/>
022.<xsd:element name="MoveStloc" type="n0:char4"/>
023.<xsd:element name="CreatedBy" type="n0:char12"/>
024.</xsd:sequence>
025.</xsd:complexType>
026.<xsd:complexType name="Bapireturn">
027.<xsd:sequence>
028.<xsd:element name="Type" type="n0:char1"/>
029.<xsd:element name="Code" type="n0:char5"/>
030.<xsd:element name="Message" type="n0:char220"/>
031.<xsd:element name="LogNo" type="n0:char20"/>
032.<xsd:element name="LogMsgNo" type="n0:numeric6"/>
033.<xsd:element name="MessageV1" type="n0:char50"/>
034.<xsd:element name="MessageV2" type="n0:char50"/>
035.<xsd:element name="MessageV3" type="n0:char50"/>
036.<xsd:element name="MessageV4" type="n0:char50"/>
037.</xsd:sequence>
038.</xsd:complexType>
039.<xsd:complexType name="Zk2ReservationItems">
040.<xsd:sequence>
041.<xsd:element name="MaterialLong" type="n0:char40"/>
042.<xsd:element name="Plant" type="n0:char4"/>
043.<xsd:element name="StoreLoc" type="n0:char4"/>
044.<xsd:element name="Batch" type="n0:char10"/>
045.<xsd:element name="Quantity" type="n0:quantum13.3"/>
046.<xsd:element name="Unit" type="n0:unit3"/>
047.<xsd:element name="ReqDate" type="n0:date10"/>
048.<xsd:element name="ShortText" type="n0:char50"/>
049.<xsd:element name="UnloadPt" type="n0:char25"/>
050.<xsd:element name="FixedQuan" type="n0:char1"/>
051.<xsd:element name="Movement" type="n0:char1"/>
052.</xsd:sequence>
053.</xsd:complexType>
054.<xsd:complexType name="TableOfBapireturn">
055.<xsd:sequence>
056.<xsd:element name="item" type="tns:Bapireturn" minOccurs="0" maxOccurs="unbounded"/>
057.</xsd:sequence>
058.</xsd:complexType>
059.<xsd:complexType name="TableOfZk2ReservationItems">
060.<xsd:sequence>
061.<xsd:element name="item" type="tns:Zk2ReservationItems" minOccurs="0" maxOccurs="unbounded"/>
062.</xsd:sequence>
063.</xsd:complexType>
064.<xsd:element name="Zk2BapiIbReservation">
065.<xsd:complexType>
066.<xsd:sequence>
067.<xsd:element name="EtReturn" type="tns:TableOfBapireturn" minOccurs="0"/>
068.<xsd:element name="IHeader" type="tns:Zk2ReservationHeader"/>
069.<xsd:element name="It_Items" type="tns:TableOfZk2ReservationItems"/>
070.<xsd:element name="Testrun" type="n0:char1" minOccurs="0"/>
071.</xsd:sequence>
072.</xsd:complexType>
073.</xsd:element>
074.<xsd:element name="Zk2BapiIbReservationResponse">
075.<xsd:complexType>
076.<xsd:sequence>
077.<xsd:element name="EReservation" type="n0:numeric10"/>
078.<xsd:element name="EtReturn" type="tns:TableOfBapireturn" minOccurs="0"/>
079.<xsd:element name="It_Items" type="tns:TableOfZk2ReservationItems"/>
080.</xsd:sequence>
081.</xsd:complexType>
082.</xsd:element>
083.</xsd:schema>
084.</wsdl:types>
085.<wsdl:message name="Zk2BapiIbReservation">
086.<wsdl:part name="parameters" element="tns:Zk2BapiIbReservation"/>
087.</wsdl:message>
088.<wsdl:message name="Zk2BapiIbReservationResponse">
089.<wsdl:part name="parameter" element="tns:Zk2BapiIbReservationResponse"/>
090.</wsdl:message>
091.<wsdl:portType name="Z_Create_Reservation">
092.<wsdl:operation name="Zk2BapiIbReservation">
093.<wsdl:input message="tns:Zk2BapiIbReservation"/>
094.<wsdl:output message="tns:Zk2BapiIbReservationResponse"/>
095.</wsdl:operation>
096.</wsdl:portType>
097.<wsdl:binding name="Z_Create_Reservation_bln" type="tns:Z_Create_Reservation">
098.<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
099.<wsdl:operation name="Zk2BapiIbReservation">
100.<soap:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:Z_Create_Reservation:Zk2BapiIbReservationRequest" style="document"/>
101.<wsdl:input>
102.<soap:body use="literal"/>
103.</wsdl:input>
104.<wsdl:output>
105.<soap:body use="literal"/>
106.</wsdl:output>
107.</wsdl:operation>
108.</wsdl:binding>
109.<wsdl:binding name="Z_Create_Reservation_bln_soap12" type="tns:Z_Create_Reservation">
110.<wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
111.<wsdl:operation name="Zk2BapiIbReservation">
112.<wsoap12:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:Z_Create_Reservation:Zk2BapiIbReservationRequest" style="document"/>
113.<wsdl:input>
114.<wsoap12:body use="literal"/>
115.</wsdl:input>
116.<wsdl:output>
117.<wsoap12:body use="literal"/>
118.</wsdl:output>
119.</wsdl:operation>
120.</wsdl:binding>
121.<wsdl:service name="Z_Create_Reservation">
122.<wsdl:port name="Z_Create_Reservation_bln" binding="tns:Z_Create_Reservation_bln">
123.<soap:address location="http://test/z_create_reservation_bln"/>
124.</wsdl:port>
125.<wsdl:port name="Z_Create_Reservation_bln_soap12" binding="tns:Z_Create_Reservation_bln_soap12">
126.<wsoap12:address location="http:/test/z_create_reservation_bln"/>
127.</wsdl:port>
128.</wsdl:service>
129.</wsdl:definitions>



Code (PHP)
01.$wsdl     = 'test?sap-client=200';
02.        $SOAP_CONFIG = array(
03.            'login' => 'test01',
04.            'password' => '*******',
05.            'authentication' => SOAP_AUTHENTICATION_BASIC,
06.            'soap_version' => SOAP_1_1,
07.            'connection_timeout' => 15,
08.            'encoding' => 'UTF-8'
09.        );
10. 
11.$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 : 1499 Reply : 2
 

 

No. 1



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



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

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

Code (PHP)
01.$client = new \SoapClient($wsdl, $SOAP_CONFIG);
02.        echo '<pre>';
03.        var_dump($client->__getFunctions());
04.        echo '</pre>';
05.        $head = new \stdClass();
06.        $head->Plant="1100";
07.        $head->ResDate="2020-08-17";
08.        $head->MoveType="241";
09.        $head->GrRcpt="test";
10.        $head->CostCtr="3191112";
11.        $head->AssetNo="000099900001";
12.        $head->SubNumber="";
13.        $head->OrderNo="";
14.        $head->MovePlant="";
15.        $head->MoveStloc="";
16.        $head->CreatedBy="";
17. 
18. 
19.        $detail = new \stdClass();
20.        $detail->MaterialLong = 'C21-MCAA151';
21.        $detail->Plant = '2100';
22.        $detail->StoreLoc = 'F131';
23.        $detail->Batch = '';
24.        $detail->Quantity = '5';
25.        $detail->ReqDate = '2020-08-17';
26.        $detail->Unit = 'ST';
27.        $detail->ShortText = 'qweasd';
28.        $detail->UnloadPt = '';
29.        $detail->FixedQuan = '1';
30.        $detail->Movement = '1';
31. 
32.        $de[] = $detail;
33. 
34. 
35.        $detail = new \stdClass();
36.        $detail->MaterialLong = 'C21-SWAA001';
37.        $detail->Plant = '2100';
38.        $detail->StoreLoc = 'F131';
39.        $detail->Batch = '';
40.        $detail->Quantity = '10.00';
41.        $detail->ReqDate = '2020-08-17';
42.        $detail->Unit = 'ST';
43.        $detail->ShortText = 'qweasd';
44.        $detail->UnloadPt = '';
45.        $detail->FixedQuan = '1';
46.        $detail->Movement = '1';
47. 
48.        $de[] = $detail;
49. 
50.        $re = new \stdClass();
51.        $re->item = '';
52. 
53.        $main = new \stdClass();
54.        $main->IHeader = $head;
55.        $main->It_Items = $de;
56.        $main->EtReturn = $re;
57. 
58.        $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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





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