
DATA(url) = 'https://get-geocodes.fdc4fe9.kyma.shoot.live.k8s-hana.ondemand.com/?address='.
LOOP AT im_t_xadrc ASSIGNING FIELD-SYMBOL(<fs_xadrc>).
IF <fs_xadrc>-house_num1 IS NOT INITIAL.
full_address = <fs_xadrc>-house_num1.
ENDIF.
IF <fs_xadrc>-street IS NOT INITIAL.
CONCATENATE full_address <fs_xadrc>-street INTO full_address SEPARATED BY space.
ENDIF.
IF <fs_xadrc>-city1 IS NOT INITIAL.
CONCATENATE full_address <fs_xadrc>-city1 INTO full_address SEPARATED BY space.
ENDIF.
IF <fs_xadrc>-region IS NOT INITIAL.
CONCATENATE full_address <fs_xadrc>-region INTO full_address SEPARATED BY space.
ENDIF.
IF <fs_xadrc>-post_code1 IS NOT INITIAL.
CONCATENATE full_address <fs_xadrc>-post_code1 INTO full_address SEPARATED BY space.
ENDIF.
IF <fs_xadrc>-country IS NOT INITIAL.
CONCATENATE full_address <fs_xadrc>-country INTO full_address SEPARATED BY space.
ENDIF.
REPLACE '#' WITH space INTO full_address.
SHIFT full_address LEFT DELETING LEADING space.
CONDENSE full_address.
CONCATENATE url full_address INTO DATA(final_url).
ENDLOOP.
"create HTTP client by url
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = final_url
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
"error handling
ENDIF.
*** Send the request
lo_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2 ).
*** Receive the respose
lo_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3 ).
*** Read the result
lv_result = lo_http_client->response->get_cdata( ).
IF lv_result NP 'Internal Server Error'.
ls_geocode-mandt = sy-mandt.
ls_geocode-addrnumber = im_address_number.
SPLIT lv_result AT ',' INTO ls_geocode-latitude ls_geocode-longitude.
MODIFY zaddress_geocode FROM ls_geocode.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
27 | |
24 | |
23 | |
19 | |
16 | |
15 | |
10 | |
9 | |
9 | |
8 |