cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP PHP Tables

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Dear James,

Thanks for the helpful comment... works fine..It was the "exposed" flag as you mentioned.

Regards,

Mohammed Mohsen

Answers (3)

Answers (3)

Former Member
0 Kudos

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?

rajasekhar_reddy14
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

nageshwar_reddy
Contributor
0 Kudos

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.

Former Member
0 Kudos

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

nageshwar_reddy
Contributor
0 Kudos

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?

Former Member
0 Kudos

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


nageshwar_reddy
Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

nageshwar_reddy
Contributor
0 Kudos

Can you specify the exact error message that you see when you use SOAP PANDA? Do you see the same error message from PHP debugging and SOAP PANDA?

Former Member
0 Kudos

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.

Former Member
0 Kudos

Nageshwar,

I believe I may have figured it out, please standby while I do some testing. I do not want to waste more of your time if there is something I can try first. I will post my results what I think is the case.  Thanks for all your help so far.

MichalKrawczyk
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Michal,

I'm using table for export in PHP SOAP, how to get in PHP?

thanks