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

http_get with wrong text encoding

Former Member
0 Likes
1,721

Hello guys,

I'm using FM http_get to read html from a web page and then i will apply transaformation on it

but I'm having some problems with the encoding.

for example if the webpage apears 'é' in my table apears 'é'

After transformation obviosly the encoding issue continues. The webpage contains turkish characters

in SCN there is several cases but they are all unresolved!!

Code look like this:

CALL FUNCTION 'HTTP_GET'

     EXPORTING

       ABSOLUTE_URI                = URI

       RFC_DESTINATION             = DEST

       USER                        = USER

       PASSWORD                    = PWD

       BLANKSTOCRLF                = BTOCRLF

     IMPORTING

       STATUS_CODE                 = STATUS

       STATUS_TEXT                 = STATUSTEXT

       RESPONSE_ENTITY_BODY_LENGTH = RLENGTH

     TABLES

       RESPONSE_ENTITY_BODY        = RESPONSE

       RESPONSE_HEADERS            = RESPONSE_HEADERS.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
667

Hello guys

I found the solution i tried and it worked

Need to set the headerfield paramters as below

and i can read the turkish chars with no problem

DATA: LV_CLIENT TYPE REF TO IF_HTTP_CLIENT.

*lv_url = 'http://eft.tcmb.gov.tr/bankasubelistesi/bankaSubeTumListe.xml'.


* Create client

   CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL

     EXPORTING

       URL                = IV_URL

     IMPORTING

       CLIENT             = LV_CLIENT

     EXCEPTIONS

       ARGUMENT_NOT_FOUND = 1

       PLUGIN_NOT_ACTIVE  = 2

       INTERNAL_ERROR     = 3

       OTHERS             = 4.

   IF SY-SUBRC NE 0.

     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

   LV_CLIENT->REQUEST->SET_CONTENT_TYPE(

       EXPORTING

         CONTENT_TYPE = 'multipart/mixed; boundary=BOUNDARY'

         ).

   LV_CLIENT->REQUEST->SET_HEADER_FIELD( NAME  = '~request_method'

                                           VALUE = 'GET' ).

   LV_CLIENT->REQUEST->SET_HEADER_FIELD( NAME  = 'Content-Type'

                                         VALUE = 'text/xml; charset=utf-16').

   LV_CLIENT->REQUEST->SET_HEADER_FIELD(

       EXPORTING

         NAME = 'Accept-Charset'

         VALUE = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'

         ).

   CALL METHOD LV_CLIENT->REQUEST->SET_FORMFIELD_ENCODING

     EXPORTING

       FORMFIELD_ENCODING = LV_CLIENT->REQUEST->CO_ENCODING_URL.

* Get request:

   CALL METHOD LV_CLIENT->SEND

     EXCEPTIONS

       HTTP_COMMUNICATION_FAILURE = 1

       HTTP_INVALID_STATE         = 2

       HTTP_PROCESSING_FAILED     = 3

       OTHERS                     = 4.

   IF SY-SUBRC NE 0.

     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

* Prepare client-receive:

   CALL METHOD LV_CLIENT->RECEIVE

     EXCEPTIONS

       HTTP_COMMUNICATION_FAILURE = 1

       HTTP_INVALID_STATE         = 2

       HTTP_PROCESSING_FAILED     = 3

       OTHERS                     = 4.

* Get HTML:

   EV_DATA = LV_CLIENT->RESPONSE->GET_CDATA( ).

Hope this helps to you all guys

1 REPLY 1
Read only

Former Member
0 Likes
668

Hello guys

I found the solution i tried and it worked

Need to set the headerfield paramters as below

and i can read the turkish chars with no problem

DATA: LV_CLIENT TYPE REF TO IF_HTTP_CLIENT.

*lv_url = 'http://eft.tcmb.gov.tr/bankasubelistesi/bankaSubeTumListe.xml'.


* Create client

   CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL

     EXPORTING

       URL                = IV_URL

     IMPORTING

       CLIENT             = LV_CLIENT

     EXCEPTIONS

       ARGUMENT_NOT_FOUND = 1

       PLUGIN_NOT_ACTIVE  = 2

       INTERNAL_ERROR     = 3

       OTHERS             = 4.

   IF SY-SUBRC NE 0.

     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

   LV_CLIENT->REQUEST->SET_CONTENT_TYPE(

       EXPORTING

         CONTENT_TYPE = 'multipart/mixed; boundary=BOUNDARY'

         ).

   LV_CLIENT->REQUEST->SET_HEADER_FIELD( NAME  = '~request_method'

                                           VALUE = 'GET' ).

   LV_CLIENT->REQUEST->SET_HEADER_FIELD( NAME  = 'Content-Type'

                                         VALUE = 'text/xml; charset=utf-16').

   LV_CLIENT->REQUEST->SET_HEADER_FIELD(

       EXPORTING

         NAME = 'Accept-Charset'

         VALUE = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'

         ).

   CALL METHOD LV_CLIENT->REQUEST->SET_FORMFIELD_ENCODING

     EXPORTING

       FORMFIELD_ENCODING = LV_CLIENT->REQUEST->CO_ENCODING_URL.

* Get request:

   CALL METHOD LV_CLIENT->SEND

     EXCEPTIONS

       HTTP_COMMUNICATION_FAILURE = 1

       HTTP_INVALID_STATE         = 2

       HTTP_PROCESSING_FAILED     = 3

       OTHERS                     = 4.

   IF SY-SUBRC NE 0.

     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

* Prepare client-receive:

   CALL METHOD LV_CLIENT->RECEIVE

     EXCEPTIONS

       HTTP_COMMUNICATION_FAILURE = 1

       HTTP_INVALID_STATE         = 2

       HTTP_PROCESSING_FAILED     = 3

       OTHERS                     = 4.

* Get HTML:

   EV_DATA = LV_CLIENT->RESPONSE->GET_CDATA( ).

Hope this helps to you all guys