Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with Web Service

Former Member
0 Likes
3,005

Hi Experts,

I am facing a strange problem.

I have exposed a function module as a web service. It returns a list of material numbers.

When I execute it in SAP, it works fine. But when the external application (a ruby program) calls the web service it returns the table as blank.

I have used the structure “BAPIMATLST” and passing the data under the Tables tab of function module.

Regards,

Gopal

1 ACCEPTED SOLUTION
Read only

former_member197425
Active Participant
0 Likes
2,106

Hi Gopal,

Whenever we create any web service for Material no,Sales Order no,PO no etc based search scenarios,if such a web services are used by other systems like JAVA,.NET in your case Ruby the leading zeros also need  to be passed to those fields in external system .

For example  lets take Material no in SAP D.B as '000000000000001111'  if we run web service inside SAP system and pass MATNR as '1111', internally web service will automatically convert '1111' into '000000000000001111'  because of conversion routines which are inside R/3.

But where as in external system consuming web service if we pass just '1111' the Web service will not automatically convert into leading zeros format so we need to pass MATNR along with leading zeros as input parameter to webservice as '000000000000001111' then it will execute.

Try again your web service passing leading zeros.If it works then handle adding leading zeros functionality by calling conversion routines for MATNR inside the F.M itself..

Thanks,

Nandi.

10 REPLIES 10
Read only

former_member213275
Contributor
0 Likes
2,106

Hi,

Try to check and replace your RFC in below

class SapMaterial < SAP4Rails::NW::Base

  function_module :RFC_READ_TABLE

  class << self

    def find_stock(options={})

      material = options[:material]

      return nil if material.blank?

      rfc = self.RFC_READ_TABLE.new_function_call

      rfc.QUERY_TABLE = "yourtable"

      rfc.DELIMITER = "|"

      rfc.OPTIONS = [{'TEXT' => "MATNR EQ '#{material}'"}]

      # optional set of fields to return from the table

      #rfc.FIELDS = [{'FIELDNAME' => 'MATNR'}, {'FIELDNAME' => ...}]

      rfc.invoke

      rfc.DATA

    end

  end

end

Read only

former_member197425
Active Participant
0 Likes
2,107

Hi Gopal,

Whenever we create any web service for Material no,Sales Order no,PO no etc based search scenarios,if such a web services are used by other systems like JAVA,.NET in your case Ruby the leading zeros also need  to be passed to those fields in external system .

For example  lets take Material no in SAP D.B as '000000000000001111'  if we run web service inside SAP system and pass MATNR as '1111', internally web service will automatically convert '1111' into '000000000000001111'  because of conversion routines which are inside R/3.

But where as in external system consuming web service if we pass just '1111' the Web service will not automatically convert into leading zeros format so we need to pass MATNR along with leading zeros as input parameter to webservice as '000000000000001111' then it will execute.

Try again your web service passing leading zeros.If it works then handle adding leading zeros functionality by calling conversion routines for MATNR inside the F.M itself..

Thanks,

Nandi.

Read only

0 Likes
2,106

Hi Nandi,

The web service is called using leading zeros. moreover I have also added a conversion routine before i query the table. I am able to debug it through external break point. The data is in the table till it leaves the function module.

Regards,

Gopal

Read only

0 Likes
2,106

The data is in the table till it leaves the function module.

Hello Gopal,

'Tables' tab in FM builder is SAP design for handling tables. It may be possible that your third party system Ruby is not identifying it.

Try it : Remove parameter from Tables tab and add a Table type parameter under 'Export' tab.

Many Thanks,

Jitendra

Read only

0 Likes
2,106

Hi Jitendra,

Yes this works. Thanks a lot.

Regards,

Gopal

Read only

0 Likes
2,106

Hello Gopal,

If you got the answer , please mark the question Answered.

Read only

jitendra_it
Active Contributor
0 Likes
2,106

Hello Gopal S,

Check for the leading zeros as suggested by Nandi.

For tracking what is coming in SAP and what is going out of SAP , you can use transaction

SRT_UTIL. here you will get all the calls to SAP via Web service(Provider + Consumer).

Many Thanks,

Jitendra Soni

Read only

0 Likes
2,106

I am facing this issue even after putting the table as export parameter...please help

Read only

0 Likes
2,106

Hi Unnati,

Please test your webservice with tooll like SOAP UI.

Read only

0 Likes
2,106

Hi Ranjana ,

                    Until now i had been testing the web service from SOAP UI in our corporate network which gets the response as required.

A third party , trying to test it  using chrome poster , get the following error :

I then decided to test it from  an external network (on SOAPUI) and below is the error i am receiving

I tried a lot to search about this error. Cant find what the problem is .

Also , id like to mention , previously there was a similar web service which has been consumed and is working fine , but receives the same response if tested from  SOAP UI from an external network.

Any suggestions?

Thanks,

Unnati