Application Development 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: 

FM HTTP_POST - Request_entity_body X Response_entity_body

joo_gaia
Explorer
0 Kudos

Hi All

There is a Z program that sends a XML using fm HTTP_POST.

There is a request to include a new field in the XML.

After including the field, the fm runs OK, but the new field is not appearing in the server and the parameter response entity body is not returning with the new field.



CONCATENATE tmp_datos

               receptor-rutrecep '|'

               receptor-cdgintrecep '|'

               receptor-rznsocrecep '|'

               receptor-girorecep '|'

               receptor-contacto '|'

               receptor-dirrecep '|'

               receptor-cmnarecep '|'

               receptor-ciudadrecep '|'

               receptor-ciudadpostal '|' " <== new field

               receptor-fin

     INTO tmp_datos.


....



CALL FUNCTION 'HTTP_POST'

     EXPORTING

       absolute_uri                = urisrv

       rfc_destination             = 'SAPHTTPA'

       request_entity_body_length  = tamano_mensaje

     IMPORTING

       status_code                 = codigo_http

       status_text                 = estatus_http

       response_entity_body_length = tamano_respuesta

     TABLES

       request_entity_body         = request_entity_body

       request_headers             = request_headers

       response_entity_body        = response_entity_body

       response_headers            = response_headers

     EXCEPTIONS

       connect_failed              = 1

       timeout                     = 2

       internal_error              = 3

       tcpip_error                 = 4

       system_failure              = 5

       communication_failure       = 6.



Is there some mapping that should be applied? If yes, where?

Is there something that should be changed on the server side?

Could you please advise?

Thanks in advance.

João Gaia

2 REPLIES 2

custodio_deoliveira
Active Contributor
0 Kudos

Hi Joao,

I can't see where you set the request_entity_body. You should convert variable tmp_datos  into an internal table. are you doing this?

Regards,

Custodio

0 Kudos

Hi Custodio

Yes, I am doing it. 

I have a string with all the fields, and after this I split the string creating an internal table - each line of the internal table with 200 character.


DATA: BEGIN OF request_entity_body OCCURS 50,   <==

            default(200) TYPE c,

         END OF request_entity_body.

   DATA: BEGIN OF response_entity_body OCCURS 10,

            default(200) TYPE c,

         END OF response_entity_body.

   DATA: BEGIN OF response_headers OCCURS 50,

            default(200) TYPE c,

         END OF response_headers.

   DATA: BEGIN OF request_headers OCCURS 10,

            default(200) TYPE c,

         END OF request_headers.

.

.

.

request_headers = 'Content-Type: application/x-acepta-message'.

   APPEND request_headers.

   tamano_mensaje = STRLEN( mensaje ).

   chars_todo = tamano_mensaje.

   DO.

     IF chars_todo = 0.

       EXIT.

     ENDIF.

     IF chars_todo > 200.

       chunk_size = 200.

     ELSE.

       chunk_size = chars_todo.

     ENDIF.

     request_entity_body = mensaje+chunk_pos(chunk_size).

     APPEND request_entity_body.

     chunk_pos = chunk_pos + 200.

     chars_todo = chars_todo - chunk_size.

   ENDDO.

   CALL FUNCTION 'HTTP_POST'

     EXPORTING

       absolute_uri                = urisrv

       rfc_destination             = 'SAPHTTPA'

       request_entity_body_length  = tamano_mensaje

     IMPORTING

       status_code                 = codigo_http

       status_text                 = estatus_http

       response_entity_body_length = tamano_respuesta

     TABLES

       request_entity_body         = request_entity_body

       request_headers             = request_headers

       response_entity_body        = response_entity_body

       response_headers            = response_headers

     EXCEPTIONS

       connect_failed              = 1

       timeout                     = 2

       internal_error              = 3

       tcpip_error                 = 4

       system_failure              = 5

       communication_failure       = 6.

   lsubrc = sy-subrc.

   IF codigo_http <> '200'.

     RAISE error_protocolo_http.

     EXIT.

   ENDIF.

   IF lsubrc <> 0.

     CASE lsubrc.

       WHEN 1. RAISE connect_failed.

       WHEN 2. RAISE timeout.

       WHEN 3. RAISE internal_error.

       WHEN 4. RAISE tcpip_error.

       WHEN 5. RAISE system_failure.

       WHEN 6. RAISE communication_failure.

     ENDCASE.

     EXIT.

   ENDIF.

In the abap program I just added a new field

|QUILICURA|8710085|}||AV. PDTE

but it is not appearing on the server - Only this new field is not appearing.

Thanks in advance.

Joao Gaia