0% found this document useful (0 votes)
80 views2 pages

Attachment Upload

The document outlines a process for uploading files to a SharePoint site using HTTP client methods in ABAP. It includes the construction of URLs, setting HTTP headers, and handling responses for each file in a loop. The uploaded file details are logged into a specified table after a successful upload.

Uploaded by

Bishnu Tosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views2 pages

Attachment Upload

The document outlines a process for uploading files to a SharePoint site using HTTP client methods in ABAP. It includes the construction of URLs, setting HTTP headers, and handling responses for each file in a loop. The uploaded file details are logged into a specified table after a successful upload.

Uploaded by

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

DATA : url_m TYPE string,

url1 TYPE string,


url2 TYPE string,
url TYPE string,
wa_pay TYPE zstr_payload,
it_tab TYPE TABLE OF ztab_log_poatch,
wa_tab TYPE ztab_log_poatch.

DATA : p_http_client TYPE REF TO if_http_client.


DATA : part TYPE REF TO if_http_entity.
DATA : lv_response TYPE string,
* it_tab TYPE TABLE OF ztab_log_poatch,
* wa_tab TYPE ztab_log_poatch,
lv_index TYPE i,
no(2) TYPE c.

LOOP AT it_pay INTO wa_pay.


* lv_index = lv_index + 1.
* no = lv_index.
* CONCATENATE 'PO_DOC' no INTO wa_pay-lv_name.
CONDENSE wa_pay-lv_name NO-GAPS.
url1 = |',overwrite=true)|.
url2 = |')/Files/add(url='|.
* url =
|[Link]
tiveUrl('Attachments/|.

CONCATENATE attach_url i_ekko-bukrs '/' i_ekko-aedat+0(4) '/' i_ekko-zBrand '/'


i_ekko-ebeln url2 wa_pay-lv_name url1 INTO url_m.

CALL METHOD cl_http_client=>create_by_url


EXPORTING
url = url_m
proxy_host = '[Link]' "proxy URL
* proxy_host = 'proxy' "proxy URL
proxy_service = '3128' "proxy port
* ssl_id = ssl_id
IMPORTING
client = p_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.

* lo_http_client->request->set_method( 'POST' ).
p_http_client->request->set_method( 'POST' ).

* CONCATENATE 'Bearer' lv_json-access_token INTO token SEPARATED BY space.


CALL METHOD p_http_client->request->set_header_field(
EXPORTING
name = 'Authorization'
value = token ).

CALL METHOD p_http_client->request->set_header_field


EXPORTING
name = 'content-type'
* value = 'application/json;odata=nometadata'.
value = 'application/json;odata=verbose'.

CALL METHOD p_http_client->request->set_header_field


EXPORTING
name = 'Accept'
* value = 'application/json;odata=nometadata'.
value = 'application/octet-stream'.

p_http_client->propertytype_logon_popup = 0.

CALL METHOD p_http_client->request->set_data


EXPORTING
data = wa_pay-xstream.

CALL METHOD p_http_client->send


EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.

IF sy-subrc = 0.
CALL METHOD p_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 5.

IF sy-subrc = 0.
wa_tab-ebeln = i_ekko-ebeln.
wa_tab-bukrs = i_ekko-bukrs.
wa_tab-attach_name = wa_pay-lv_name.
wa_tab-creat_by = sy-uname.
wa_tab-creat_on = sy-datum.
wa_tab-creat_at = sy-uzeit.
APPEND wa_tab TO iT_tab.
MODIFY ztab_log_poatch FROM TABLE iT_tab.
ENDIF.
lv_response = p_http_client->response->get_cdata( ).

ENDIF.
ENDLOOP.

You might also like