Linux
Programming
Misc
Linux
Programming
Misc
FUNCTION z_http_rename. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(URI_SOURCE) TYPE STRING *" VALUE(URI_TARGET) TYPE STRING *" EXPORTING *" VALUE(CODE) TYPE I *" VALUE(REASON) TYPE STRING *" EXCEPTIONS *" NO_LOGIN_ACCOUNT_AVAILABLE *" HTTP_COMMUNICATION_FAILURE *" HTTP_INVALID_STATE *" HTTP_PROCESSING_FAILED *" HTTP_SEND_RECEIVE_ERROR *" OTHERS *"---------------------------------------------------------------------- * IperCube 2008 *"---------------------------------------------------------------------- DATA: user TYPE string, pwd TYPE string. * Set User/Password Logon to web server user = 'my_user'. pwd = 'my_password'. * Translate URL Source TRANSLATE uri_source USING ' *'. REPLACE ALL OCCURRENCES OF '*' IN uri_source WITH '%20' IN CHARACTER MODE. * Translate URL Target TRANSLATE uri_target USING ' *'. REPLACE ALL OCCURRENCES OF '*' IN uri_target WITH '%20' IN CHARACTER MODE. * If Source = Target, error IF uri_source = uri_target. code = 409. reason = 'Source and Target must be different'. EXIT. ENDIF. * Copy File CALL FUNCTION 'Z_HTTP_COPY' EXPORTING uri_source = uri_source uri_target = uri_target IMPORTING code = code reason = reason EXCEPTIONS no_login_account_available = 1 http_communication_failure = 2 http_invalid_state = 3 http_processing_failed = 4 http_send_receive_error = 5 OTHERS = 6. * 201 = Created (Target didn't exist), 204 = Created (Target overwritten) IF sy-subrc IS NOT INITIAL OR ( code <> 201 AND code <> 204 ). EXIT. ENDIF. CASE sy-subrc. WHEN 1. RAISE no_login_account_available. WHEN 2. RAISE http_communication_failure. WHEN 3. RAISE http_invalid_state. WHEN 4. RAISE http_processing_failed. WHEN 5. RAISE others. ENDCASE. * Delete Source File CALL FUNCTION 'Z_HTTP_DELETE' EXPORTING uri = uri_source * CONTENT_TYPE = IMPORTING code = code reason = reason EXCEPTIONS no_login_account_available = 1 http_communication_failure = 2 http_invalid_state = 3 http_processing_failed = 4 OTHERS = 5. * Delete Source File - Code = 204 (No Content) it's OK IF sy-subrc IS INITIAL AND code = 204. code = 200. reason = 'OK'. ENDIF. ENDFUNCTION.