Method 1: create a file in the target directory, copy the content of the source file, and delete the source file to achieve the goal of moving the file in disguise:
Form move_file_to_folder using p_from_path
P_to_path
P_file_name
P_ztype.
Data: lv_str type string.
Data: p_file_n_f like rlgrap-filename,
P_file_f like rlgrap-filename,
P_file_n_t like rlgrap-filename,
P_file_t like rlgrap-filename.
If ST01 EQ 'x '.
Clear: p_file_n_f, p_file_f, p_file_n_t, p_file_t.
"To File
* Concatenate p_ztype p_file_n_t
* Into p_file_n_t separated '_'.
P_file_n_t = p_file_name.
Concatenate p_to_path p_file_n_t
Into p_file_t separated '\'.
"From file
Concatenate p_from_path p_file_name
Into p_file_f separated '\'.
"Open to file, and trans data to it
Open dataset p_file_t for output in text mode encoding UTF-8.
If sy-subrc EQ 0.
Close dataset p_file_f.
Open dataset p_file_f for input in text mode encoding UTF-8.
If sy-subrc EQ 0.
Do.
Clear lv_str.
Read dataset p_file_f into lv_str.
If sy-subrc Ne 0.
Exit.
Endif.
Transfer lv_str to p_file_t.
Enddo.
Endif.
Close dataset p_file_f.
* "Delete original file
If sy-subrc EQ 0.
Delete dataset p_file_f.
Endif.
Endif.
Close dataset p_file_t.
Endif.
Endform. "move_file_to_err_folder
Method 2: Call External commands for processing
Form move_file tables p_table
Using p_delete_file
P_flag.
Data: in_file (255) type C,
Out_file (255) type C.
Data: Cmnd like SXPGCOLIST-NAME,
Parm like SXPGCOLIST-PARAMETERS.
Data: Begin of out_data occurs 50.
Include structure btcxpm.
Data: End of out_data.
Data: rtn_ch.
* <1> * Call LHA command
* Create System Command
Cmnd = 'zmove '. "<-- system command name. Refer" sm69"
**************************************** ****************
* Configuration *
* Operating System Command: "cmd "*
* Parameters for operating system command: "/C move "*
**************************************** ****************
* Move need parameter "<source file >_< target File>"
Move p_delete_file to out_file.
If move_succ = 'x '.
Concatenate I _path '\ complete \ 'into in_file.
Endif.
If move_err = 'x '.
Concatenate I _path '\ noncomplete \ 'into in_file.
Endif.
Concatenate out_file in_file into parm separated by space.
* Call System Command
Clear rtn_ch.
Call function 'sxpg _ call_system'
Exporting
Commandname = Cmnd
Additional_parameters = parm
* Importing
* Status = rtn_ch
Tables
Exec_protocol = out_data
Exceptions
No_permission = 01
Command_not_found = 02
Parameters_too_long = 03
Security_risk = 04
Wrong_check_call_interface = 05
Program_start_error = 06
Program_termination_error = 07
X_error = 08
Parameter_expected = 09
Too_many_parameters = 10
Illegal_command = 11.
Endform.