on 08-20-2012 12:10 AM
Hi Friends,
I have begun working with the SOAP interface and using PHP to pass data to SAP function modules. I am new to SOAP, but I have had success with passing and returning single variables and single lines of structures to and from the web service enabled function module. The problem is passing and returning table data. At first PHP said it was returning an empty generic object, I have tried everything on the client side to return a table from the module. No data is being passed backed according to some PHP debugging (__getLastResponseHeaders()). My question is, is this possible to return complex types of tables from function modules through SOAP. If so could there be some configuration I am missing. I can get it to work just fine with single variables and lines and I also tested the function module in SAP and it is working. What am I missing?
Thanks,
sifter
Success at last!
SAP note 876795 directed me in the right path.
For the configuration of the webservice in SE80->Enterprise Services->Service Definitions->(MYMODULE), one needs to go to the "External View" Module as change the configuration for the input and output tables by selecting these objects and accessing the configuration on the right of the screen.
When an internal table is optional, ABAP has a check to test if it is going to be exported in the function call without additional specifications. However in SOAP this is not the case. Since I was not exporting a table to the webservice (only want the import), I needed to UNSELECT "expose" in the configuration for the input table mentioned in the first paragraph. This tells the web service it will not be expecting an imported table and thus not cause an error in the web service when the table is exported.The expose option appears to be SOAP's method of checking whether the table is to accept or return values.
Atleast this is what I make of all this. My function is now working properly. If anyone has further explanations or experiences of these findings please add. I would also like to sincerely thank all those who responded especially Nageshwar Reddy who actively helped me solve this problem.
Thanks and Regards,
sifter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I went into SE80(tcode)->EnterpriseServices->ServiceDefinitions->MYMETHOD . Ithen Clicked on the "External View" tab, and then selected my table from the output and input nodes. In the "External" properties to the right of these I checkmarked optional even though my function table was optional, these were not checked and activated the service. I re created and the same thing happened just to be sure this was the case. Anyways, in the SOAP PANDA utility I still receive the same message The results do not show up in the response column, but when I check the response XML MY RESULTS ARE NOW THERE that should be for the OUTTABLE.
I can still get nothing but an empty object returned in PHP though. Why would these optional selections not be checked and why would selecting them give me some results? Could this have some bearing on why I am not seeing results in the PHP code as well?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You requirement can be achieved very much, i worked on similar requirements many times and it worked.
Make sure that PHP request is valid(dont miss formating number),define import /export parameters in table format.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raja,
What do you mean define import export parameters in table format? I am importing only a single variable, but I want to export a table with multiple lines of information. So for this, in my function in the import tab I have a variable (which is working). and for the tables tab I have
OUTPUT TABLE LIKE MYTABLE | (optional) |
The source code populates the table based on the import parameter. I have tested this function and it works well. I just seems the populated table object is not being returned through the web service. I have been looking into a utility where I can test this web service withou PHP. Unfortunately we do not have a Java Stack to test it in SOAMANAGER. Thanks for your response.
Thanks
sifter
Why don't you try using SoapUI to test the web service? That should tell you if the web service is working properly. I believe that if the function module is working properly for table data, then web service also should be working. It could be with how you are handling the response in PHP.
Unfortunately we do not have a Java Stack to test it in SOAMANAGER.
It is definitely possible to pass complex types from FM web services.
My question is, is this possible to return complex types of tables from function modules through SOAP.
Hi Nageshwar,
Thanks for the tip, unfortunately I had some trouble installing Soap Ui, but I did find SOAP PANDA. It is a very nice, easy to use, and free tool. I recommend it to anyone just learning SOAP.
The results with the utility were the same. The table types were not returned while single arrays are. I do get an error message with Soap Panda when I first click on my method saying the constructor for mytable type[] was not found if this means anything to anyone. Thanks for the response Nageshwar.
Thanks,
sifter
Hi Sifter,
I just tried with a RFC web service that takes a table as input and returns a table as output. I was able to test it successfully using SoapUI. Did you face any issues during generation of web service? Are you using a standard FM or is it a custom FM? How complex is the table that you are using? What is the version of ECC/ABAP you are working on?
Hi Nageshwar,
I am on ECC 6.0. Here are the steps I did in implementing the webservice.
1. I created a custom function Module via SE37.
A. Importing parameters -- INVALUE TYPE MATNR (pass value)
B. Tables Tab -- OUTTABLE LIKE CUSTOMTABLE (optional)
(simple custom table 4 colums)
C. Source Code Tab -- Select Data into OUTTABLE.....
2. Function Tested and table is populated -- Function Activated
3. From menu Utilities --> More Utilities --Create Webservice through function module.
A. Follow the steps and give my webservice a name.
B. Select Profile "LOW" (not sure what this means)
4. Go to transaction SOAMANAGER and use the Open WSDL document for selected binding""
A. Use the URL for the SOAP Call
5. Empty Object Returned
I activated the relevant SOAP paths in SICF. I do not know. Like I said I am new to SOAP, but since you guys say it is possible I know it is something that I am missing. So I will keep trying and learn more of SOAP. Do my steps and function look ok.
Thanks,
sifter
I think all the steps you are doing are fine.
The difference in what you are doing and what i have done is with respect to table parameter declaration. I did not use like. Instead i used type / table type instead of like/table. Can you try the same?
I did a quick test with like and type. Like did not yield results whereas type provided the results. Check and let me know.
Moreover, table parameters are not recommended any more. You should use export parameters with table types. That also worked for me.
Hey Nageshwar
I created a table type for the table and used the type table for parameters but still nothing. I really appreciate your efforts with me on this.
The error message from SOAP PANDA is "Constructor on type 'dsf.Mytable[]&' not found." .
PHP only resturns an empty stdClass Object.
stdClass Object( [OUTTABLE] =>stdClass Object())
Here is a snippet of the XML response:
</Outline>
values....
<Outtable></Outtable>
</n0:ZtableResponse>
</soap-env:Body>
</soap-env:Envelope>
Where outline is my test of returning a line type (which is working) but OUTTABLE is empty. I can assure you the table is being populated and has been tested.
Hi,
are you using table section in the RFC or export/import parameters with table type ?
in most cases I always used table section with a simple table and relationship to another table in case we needed to send some subtable tables - like line and subline level, this always worked with any SOAP calls,
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
Yes I am using the tables section. OUTPUT TABLE LIKE MYTABLE (optional). Like I said, the function works fine. Even to SOAP call it is working and returning my OUTTABLE, but it is returning it as an empty stdClass Object(). For the line data though it returns all the correct valures in an array. I have tried adding a map class in the parameters but it is still being returned empty. Thanks for the response.
Thanks
sifter
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.