SAP RESTFUL API

SPAN { font-family: "黑体"; font-size: 10pt; color: #F8F8F2; background: #111217; } .L0S32 { color: #F1FA8C; } .L0S33 { color: #50FA7B; } .L0S52 { color: #8BE9FD; } .L0S55 { color: #BD93F9; } .L0S70 { color: #BD93F9; } METHOD if_http_extension~handle_request.

DATA: l_json TYPE string.

DATA(l_request) = server->response->get_header_field( name = 'requst_method' ).

CHECK l_request = 'GET'.

SELECT * UP TO 10 ROWS
INTO TABLE @DATA(lt_makt)
FROM makt
WHERE spras = '1'.

CALL METHOD /ui2/cl_json=>serialize
EXPORTING
data = lt_makt
RECEIVING
r_json = l_json.

server->response->set_status( code = 200 reason = 'OK' ).
server->response->set_content_type('application/json' ).
server->response->set_cdata( data = l_json ).

ENDMETHOD.