cancel
Showing results for 
Search instead for 
Did you mean: 

Read Cookies in SAP Gateway Methods

former_member191660
Participant

when implementing a SAP Gateway Service (using DPC_EXT Classes), I'd like to access some custom cookies.

But I dont seem to be able to access them...

Using following code

lo_faqcade = /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
lo_facade->get_request_header( ).

I get all the HTTP Request headers (Except the Cookie Header, which always seems to be empty here)

Accepted Solutions (0)

Answers (3)

Answers (3)

deepakduhan
Discoverer

Well, i finally got it working for me.

IF_HTTP_EXTENSION~HANDLE_REQUEST is called everytime when you make call with the HTTP/S requests of any type with SAP. you can implement this in the sicf service handler to store the cookie to user memory or do your logic.

Second way is to use the call stack and get the object variable: server from the standard IF_HTTP_EXTENSION~HANDLE_REQUEST implementation. then you can use the object to get it: some code:

DATA: lo_server TYPE REF TO cl_http_server_net.
FIELD-SYMBOLS: <server> TYPE any.
ASSIGN ('(SAPLHTTP_RUNTIME)server_accepted') TO <server>.
CHECK: <server> IS ASSIGNED.
lo_server ?= <server>.
lo_server->request->get_cookie( EXPORTING name = 'USERCOOKIE' IMPORTING value = rv_cookie ).

Sschlegel
Participant
0 Kudos

Ugly as hell - but seems to work 🙂

Thank you!

deepakduhan
Discoverer
0 Kudos

Hi Sergei/Sreehari,

Did you guys manage to do this?

former_member191660
Participant
sreehari_vpillai
Active Contributor
0 Kudos

Hay,

Were you able to get a solution ?

I was also trying to read/write cookies in OData context. Ended up nowhere .

Sreehari

former_member191660
Participant

No, unfortunately not. you could upvote the question, maybe it gets a higher awareness...