0% found this document useful (0 votes)
39 views1 page

Smartform Through API

The document outlines a method for handling HTTP requests in an ABAP program. It processes GET requests by retrieving a customer identifier, calling a function to get data associated with that customer, and setting the response data and HTTP status. Additionally, it sets the content type for the response based on a database query for PDF MIME type.

Uploaded by

Haseeb Zia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

Smartform Through API

The document outlines a method for handling HTTP requests in an ABAP program. It processes GET requests by retrieving a customer identifier, calling a function to get data associated with that customer, and setting the response data and HTTP status. Additionally, it sets the content type for the response based on a database query for PDF MIME type.

Uploaded by

Haseeb Zia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

method IF_HTTP_EXTENSION~HANDLE_REQUEST.

DATA: LR_REQUEST TYPE REF TO IF_HTTP_REQUEST,


LR_RESPONSE TYPE REF TO IF_HTTP_RESPONSE,
LV_VALUE TYPE STRING,
LV_REASON TYPE XSTRING,
LV_DATA TYPE XSTRING,
ERROR_MESSAGE TYPE STRING,
EP_XSTRING TYPE XSTRING,
KUNNR TYPE KUNNR.
LR_REQUEST = SERVER->REQUEST.
LR_RESPONSE = SERVER->RESPONSE.
IF LR_REQUEST->GET_METHOD( ) EQ 'GET'.
LV_VALUE = LR_REQUEST->GET_FORM_FIELD( 'CUSTOMER' ).
KUNNR = LV_VALUE.
IF KUNNR IS NOT INITIAL.
CALL FUNCTION 'ZHZ_SF'
EXPORTING
KUNNR = KUNNR
IMPORTING
EP_XSTRING = EP_XSTRING
ERROR_MESSAGE = ERROR_MESSAGE
.
LV_DATA = EP_XSTRING.
LR_RESPONSE->SET_DATA( LV_DATA ).
LR_RESPONSE->SET_STATUS( CODE = 200 REASON = ' ' ).
SELECT SINGLE MIMETYPE FROM TDWP INTO LV_VALUE WHERE DAPPL = 'PDF'.
IF SY-SUBRC EQ 0.
LR_RESPONSE->SET_HEADER_FIELD( NAME = 'Content-Type' Value = LV_VALUE )
.
ENDIF.

ENDIF.
ENDIF.

endmethod.

You might also like