Skip to Content

First we have to create External command using SM69 for the Deleting file.

Step1: open transaction sm69

By giving Command Nam, OS, OS Command as highlighted below and then save.

Capture.PNG

Same way create external command for Moving file from source folder to target folder by passing mv as Operating System Command.

Step2: Create Program in SE38

CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE ‘ZDELETE_FILE’,
           c_oper     
TYPE syopsys VALUE ‘AIX’.
DATA: v_dir_input      TYPE sxpgcolist-parameters,

v_dir_input   = ‘file name to be deleted(/usr/sap……sample.txt’

CALL FUNCTION ‘SXPG_COMMAND_EXECUTE’
 
EXPORTING
    commandname                   = c_extcom
    additional_parameters         = V_dir_input
    operatingsystem               = c_oper
 
TABLES
    exec_protocol                 = t_result
 
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
    wrong_asynchronous_parameters =
12
    cant_enq_tbtco_entry          =
13
    jobcount_generation_error     =
14.

Step3: go and check al11 file is deleted from folder

Same way for the for the moving

CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE ‘ZMOVE_FILE’,
           c_oper     
TYPE syopsys VALUE ‘AIX’.

DATA: v_dir_input      TYPE sxpgcolist-parameters,

       v_dir_s      type sxpgcolist-parameters,

       v_dir_t      type sxpgcolist-parameters.

Concatenate  v_dir_s ‘&’ v_dir_t into  v_dir_input.

replace ‘&’ with space into v_dir_input.

CALL FUNCTION ‘SXPG_COMMAND_EXECUTE’
 
EXPORTING
    commandname                   = c_extcom
    additional_parameters         = V_dir_input
    operatingsystem               = c_oper
 
TABLES
    exec_protocol                 = t_result
 
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
    wrong_asynchronous_parameters =
12
    cant_enq_tbtco_entry          =
13
    jobcount_generation_error     =
14.

Hope this will help:)

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply