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

Deleting Folders from Application server

Former Member
0 Likes
2,224

Hi Friends,

I have requirement from my client.

When we execute a high volume campaign a folder is generated with a CSV file in it.

This folder is created in "
server\MARKETING_HV\" directory.

For each execution of a campiagn the folder is created in "
server\MARKETING_HV\" directory now we want the folder to be deleted after the execution of the campign.

I debugged the backgroung job of campaign execution and found the below FM that creates the folder

CALL FUNCTION 'SXPG_CALL_SYSTEM'

EXPORTING

commandname = lv_commandname

additional_parameters = lv_additional_parameters

trace = lv_trace

IMPORTING

status = lv_status

exitcode = lv_exitcode

TABLES

exec_protocol = lt_exec_protocol

EXCEPTIONS

no_permission = 1

command_not_found = 2

parameters_too_long = 3

security_risk = 4

wrong_check_call_interface = 5

program_start_error = 6

program_termination_error = 7

x_error = 8

parameter_expected = 9

too_many_parameters = 10

illegal_command = 11

OTHERS = 12.

here in "lv_commandname" parameter a command 'MKTMKDIR" is passed to create the folder.

There is also a table which stores the SAP external commands "SXPGCOTABE" but i am not getting any command for deletion of the folders.

Can any body tell me do we have any function module through which i can delete a folder from the application server or do we have any other way how i can achieve this.?

Thanks Regards,

Sandipan Jena

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,102

Hi,

Please check this Thread:

Regards,

Ernesto.

5 REPLIES 5
Read only

Former Member
0 Likes
1,102

Hello sandipan jena ,

You can make sure of the FTP_CONNECT,, FTP_COMMAND and FTP_DISCONNECT function modules and can use the os level commands to the Function call "FTP_COMMAND.

Or you can use the same fm that you found in your debugging and use the command "RMTMKDIR".

Hope this answers your question.

Thanks,

Greetson

Read only

0 Likes
1,102

Hi Greetson,

I tried using the command ( RMTMKDIR ) but it is giving a message as "COMMAND_NOT_FOUND".

Thanks Regards,

Sandipan Jena

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert
0 Likes
1,102

Hi,

you can create FM for deleting files on server.


*"  IMPORTING
*"     VALUE(IV_FILENAME) TYPE  STRING
" ...
  DATA:
        ls_mess TYPE string.
" ...
  TRY.

      OPEN DATASET IV_FILENAME FOR OUTPUT IN BINARY MODE MESSAGE ls_mess.
      DELETE DATASET IV_FILENAME.

    CATCH CX_SY_FILE_OPEN. " The file is already open
" ...
    CATCH CX_SY_FILE_AUTHORITY. " No authorization to access a file
" ...
    CATCH CX_SY_TOO_MANY_FILES. " The maximum number of open files has been exceeded
" ...
" ...
" ...
    CATCH CX_ROOT.            " Unknown error
" ...
  ENDTRY.

Read only

Former Member
0 Likes
1,102

Hi,

I dont have a FM for you, but you can ask your middle ware to delete that folder if not required.

If you just do not require the data inside a file in the folder. just try writing nothing into the same file. This will delete all the existing data in the files or replaces.

Thanks,

Venkatesh.

Read only

Former Member
0 Likes
1,103

Hi,

Please check this Thread:

Regards,

Ernesto.