Skip to Content
0
Former Member
Feb 10, 2009 at 04:32 PM

Simple Restful State Web Service

191 Views

Hey All, (UPDATED WITH DISCOVERIES)

I have this odd problem with a simple restful state web service that I'm putting together. I want the user to be able to post in IE either a variant or a material number. For instance either...

http://devisrv.internal.upsher-smith.com:8000/sap/USL/weeksonhand?

http://devisrv.internal.upsher-smith.com:8000/sap/USL/weeksonhand?

would elicit an xml response. The problem I'm having is that the <variant> one won't work. When I debug it in SAP all looks fine, but when submitting from a browser it cannot find any of the variants. I guess the question is...how do I debug from a browser??? or, is there something obvious in my simple code below that is wrong??? What has me stumped is that the <material#> version works great. ??

I've now discovered that it is the ALPHA characters that is causing the problem. I send in a parameter that is '12345' and it is fine, but I put in a '123R5' and it fails. If I hardcode the alpha characters directly into the program it also has an issue, so it is not how the program is receiving the ~path_info or the ~query_string. I've not encountered an issue with processing alphas in background, then again I've sadly not done much OO programming so this may be the whole issue in the end. Still stuck, but still tryin'.

Any insight would be greatly appreciated.

Greg

METHOD if_http_extension~handle_request.

DATA: path_info TYPE string,

w_body TYPE string,

parameter TYPE string,

variant TYPE variant,

matnr TYPE matnr,

zweeksreturn TYPE TABLE OF zweeksreturn,

type(10) TYPE c,

xml_out TYPE string,

value TYPE string.

FIELD-SYMBOLS: <zweeksreturn> TYPE zweeksreturn.

path_info = server->request->get_header_field( name = '~query_string' ).

parameter = path_info.

SELECT SINGLE variant INTO variant FROM varid

WHERE report = 'ZRPP_WEEKS_ON_HAND'

AND variant = parameter.

IF sy-subrc = 0.

type = 'VARIANT'.

ENDIF.

SELECT SINGLE matnr INTO matnr FROM mara

WHERE matnr = parameter.

IF sy-subrc = 0.

type = 'MATERIAL'.

ENDIF.

CASE type.

WHEN 'VARIANT'.

CALL FUNCTION 'Z_WS_WEEKS_ON_HAND'

EXPORTING

i_variant = variant

TABLES

t_return = zweeksreturn.

CALL TRANSFORMATION id

SOURCE table = zweeksreturn

RESULT XML xml_out.

WHEN 'MATERIAL'.

CALL FUNCTION 'Z_WS_WEEKS_ON_HAND'

EXPORTING

i_material = matnr

i_period = 'Z1'

TABLES

t_return = zweeksreturn.

CALL TRANSFORMATION id

SOURCE table = zweeksreturn

RESULT XML xml_out.

WHEN OTHERS.

CONCATENATE '<html>'

'<head>'

'<title>Parameter is neither a variant nor a material</title>'

'</head>'

'<body>'

'<h1>Parameter&nbsp;'

parameter

'&nbsp;not found</h1>'

'</body>'

'</html>'

INTO xml_out.

ENDCASE.

CALL METHOD server->response->set_cdata( data = xml_out ).

ENDMETHOD.

Edited by: Greg Foss on Feb 11, 2009 9:55 PM

Edited by: Greg Foss on Feb 11, 2009 10:02 PM