cancel
Showing results for 
Search instead for 
Did you mean: 

PHP + IDocs

Former Member
0 Kudos

Hi !

im new in this forum and i was reading about php integration with SAP, its amazing, i had loved PHP a few years ago when i rolled as a web developer, but i never did any integration between this fantastic web tech and SAP!

Today i have no problem to get an integration with RFC's and IDocs(through tRFC protocol) with .NET(and the FrameWork SAP .NET Connector) and Java(JCo)...i a saw that PHP seems work pretty well with RFC's, but, can i create or receive an IDoc from a PHP aplication ?

Where can i get more info about this issue ?

Grettings !

Andre

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi andre,

with recent netweaver releases PHP is perfectly suited to interoperate with it.

if you are familiar with RFC you can use the PHPRFC libraries mentioned elsewhere.

But actually you don't even need that. Recent PHP versions come with full webservices/soap support (e.g. 5.1.1, the version I work with). On the other side, Netweaver automatically exposes each RFC function as a webservice. Netweaver also offers a handy tool, a BSP application called WEBSERVICEBROWSER.

The URL looks something like this : http://yourserver:yourport/sap/bc/bsp/sap/webservicebrowser/search.html

(I am not quiet sure about the URL, but you can start it from SE80).

On the webpage appearing you can search for IDOC* and find all RFC enabled function modules for that subject. You might know a number of them.

From the SAP documentation <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/dc/6b7eee43d711d1893e0000e8323c4f/frameset.htm">found here</a> you could deduce that IDOC_INBOUND_SINGLE is your service of choice.

If you wish to use the PHPRFC libraries you could install them and call this function module the RFC way.

If you decide to give the webservice approach a try, you'll find a 'wsdl'-link on the WEBSERVICEBROWSER page next to the Service named IDOC_INBOUND_SINGLE.

Clicking that link you get the webservice description of that service. I'll add it at the end of this post. This WSDL can be use in almost any contemporary programming environment to generate a client for this service. This holds true for your .NET env as well as for PHP.

So, just create a client object, fill in the data as described in the WSDL and there you go.

Inspecting the WSDL, you'llfind a description of the input, that is message (or operation) IDOC_INBOUND_SINGLEInput and you'll also find a description what is being returned.

Give it a try and have fun )

regards, anton

(a note for the WSDL following: the leading '-'ses do not belong to the XML, and I collapsed some nodes - those with the +es in front - to keep the whole thing shorter)

  <?xml version="1.0" encoding="UTF-8" ?> 
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:s0="urn:sap-com:document:sap:rfc:functions"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
 targetNamespace="urn:sap-com:document:sap:rfc:functions">

- <types>
- <xsd:schema targetNamespace="urn:sap-com:document:sap:rfc:functions">
- <xsd:element name="IDOC_INBOUND_SINGLE">
- <xsd:complexType>
- <xsd:all>
- <xsd:element name="PI_DO_COMMIT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
  <xsd:element name="PI_IDOC_CONTROL_REC_40" type="s0:EDI_DC40" /> 
- <xsd:element name="PT_IDOC_DATA_RECORDS_40">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="s0:EDI_DD40" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:all>
  </xsd:complexType>
  </xsd:element>
- <xsd:element name="IDOC_INBOUND_SINGLE.Response">
- <xsd:complexType>
- <xsd:all>
- <xsd:element name="PE_ERROR_PRIOR_TO_APPLICATION">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="PE_IDOC_NUMBER">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="16" /> 
  <xsd:pattern value="d*" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="PT_IDOC_DATA_RECORDS_40">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="s0:EDI_DD40" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:all>
  </xsd:complexType>
  </xsd:element>
- <xsd:complexType name="EDI_DC40">
- <xsd:sequence>
- <xsd:element name="TABNAM" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MANDT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="3" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="DOCNUM" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="16" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="DOCREL" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="4" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="STATUS" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="DIRECT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="OUTMOD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="EXPRSS" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="TEST" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="IDOCTYP" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="30" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="CIMTYP" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="30" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESTYP" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="30" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESCOD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="3" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MESFCT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="3" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="STD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="STDVRS" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="6" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="STDMES" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="6" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SNDPOR" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SNDPRT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SNDPFC" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SNDPRN" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SNDSAD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="21" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SNDLAD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="70" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="RCVPOR" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="RCVPRT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="RCVPFC" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="RCVPRN" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="RCVSAD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="21" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="RCVLAD" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="70" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
  <xsd:element name="CREDAT" minOccurs="0" type="s0:date" /> 
  <xsd:element name="CRETIM" minOccurs="0" type="s0:time" /> 
- <xsd:element name="REFINT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="14" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="REFGRP" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="14" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="REFMES" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="14" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="ARCKEY" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="70" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SERIAL" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="20" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
+ <xsd:complexType name="EDI_DD40">
- <xsd:sequence>
- <xsd:element name="SEGNAM" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="30" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="MANDT" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="3" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="DOCNUM" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="16" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SEGNUM" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="6" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="PSGNUM" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="6" /> 
  <xsd:pattern value="d*" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="HLEVEL" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
- <xsd:element name="SDATA" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="1000" /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:element>
  </xsd:sequence>
  </xsd:complexType>
+ <xsd:simpleType name="date">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  <xsd:pattern value="....-..-.." /> 
  </xsd:restriction>
  </xsd:simpleType>
+ <xsd:simpleType name="time">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="8" /> 
  <xsd:pattern value="..:..:.." /> 
  </xsd:restriction>
  </xsd:simpleType>
  </xsd:schema>
  </types>
- <message name="IDOC_INBOUND_SINGLEInput">
  <part name="parameters" element="s0:IDOC_INBOUND_SINGLE" /> 
  </message>
- <message name="IDOC_INBOUND_SINGLEOutput">
  <part name="parameters" element="s0:IDOC_INBOUND_SINGLE.Response" /> 
  </message>
- <portType name="IDOC_INBOUND_SINGLEPortType">
- <operation name="IDOC_INBOUND_SINGLE">
  <input message="s0:IDOC_INBOUND_SINGLEInput" /> 
  <output message="s0:IDOC_INBOUND_SINGLEOutput" /> 
  </operation>
  </portType>
- <binding name="IDOC_INBOUND_SINGLEBinding" type="s0:IDOC_INBOUND_SINGLEPortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <operation name="IDOC_INBOUND_SINGLE">
  <soap:operation soapAction="http://www.sap.com/IDOC_INBOUND_SINGLE" /> 
- <input>
  <soap:body use="literal" /> 
  </input>
- <output>
  <soap:body use="literal" /> 
  </output>
  </operation>
  </binding>
- <service name="IDOC_INBOUND_SINGLEService">
  <documentation>SAP Service IDOC_INBOUND_SINGLE via SOAP</documentation> 
- <port name="IDOC_INBOUND_SINGLEPortType" binding="s0:IDOC_INBOUND_SINGLEBinding">
  <soap:address location="http://usai2air.wdf.sap.corp:50010/sap/bc/soap/rfc" /> 
  </port>
  </service>
  </definitions>

Message was edited by: Anton Wenzelhuemer

Message was edited by: Anton Wenzelhuemer (manually added line breaks)

Message was edited by: Anton Wenzelhuemer

Former Member
0 Kudos

Hi Anton !

i was watching your post right now, sweat information..i do love work with WebServices concepts, it can be amazing with flexibility.

Your post shows pretty well how to start an inbound idoc, was a nice shoot..ill take some time with it.

tks !

Andre

Former Member
0 Kudos

cool. have fun and tell us how it worked. and don't hesistate to ask if you're stuck. would love to see it work

)

former_member583013
Active Contributor
0 Kudos

I would like to see the example too! I don't have that much experience with Web Services...So your example will very helpfull.

Greetings,

Blag.

Former Member
0 Kudos

WOW! I must be out of practice, I remember the day when everyone said they had to refresh before posting to be careful "Craig hasn't already posted" now I guess I need to watch out for Anton.

Excellent answer Anton!!!

Former Member
0 Kudos

Mister Cmehil,

knowing who's 'da bozz in da PHP hood' I've of course been respectfully waiting until you issued your first two statements before I dared to get rid of my marginal account to the matter. ))

Just kidding Craig. I would just love to see this forum become a lively place and create some cool solutions together.

kind regards,

anton

Former Member
0 Kudos

One thing I really love about SDN, everyone has a sense of humor )

Guys (everyone) in here anytime you want to try to get together and create something I'm <b>IN!</b>

Former Member
0 Kudos

Hi Welcome to the forums!

If there is a FM or BAPI remote enabled inside your SAP system that you can call with JCo or the .NET connector then you can call it with SAPRFC as well. Or you can use Webservices.

Short answer - YES.

Former Member
0 Kudos

Thats the main problem, it depends from company's policy...i got a situation that we cant develop a RFC to make this "bridge" between a Standard IDoc and our .NET web application, the customer didnt want any ABAP (or Z) development..just using standards ways, in SAP .NET Connector and JCo we've good improvements to do this, and with PHP, just using a RFC (Function / BAPI) ?

thank you !

Andre

Former Member
0 Kudos

Not using custom (Z) development should not be too much of a problem. It's just a matter of finding the FM's/BAPI's that the system itself uses.

For that though you'd probably need to ask in one of the other forums. Once you know which ones to use and have trouble moving forward then this would be a good place to come back to.

Former Member
0 Kudos

ok craig, im also an ABAP developer and several std. functions used for creation an in/outbound IDoc are not remote, this was the main difficult to us...it was very hard to make something w/out a Z development

do u've any sample with PHP and a creation / receiving of an IDoc ? it'd be great !

tks again,

Andre