05-05-2011 8:29 AM
Hi,
I have to move files from source to a destination directory (AL11)and then remove from Source.
From source 'ISU_M_GET_FILES_OF_DIR' getting all files, then
Loop 'SXPG_COMMAND_EXECUTE' using this FM with 'MV' to move all files once done I am using same FM to Remove from Source.
Before this FM I need to convert UTF16 format files to UTF8 then place in directory.
ECATT_CONV_XSTRING_TO_STRING -> for converting into UTF 08 seems like it wouldnt work.
Thanks
Mohinder
05-05-2011 8:48 AM
Use function ARCHIVFILE_SERVER_TO_SERVER to move files.
If successfully moved then use statement delete dataset <path_name>.
05-05-2011 10:36 AM
Hi Keshav,
Thanks for anwser but that doesnt solves, as for source target its unable to read and throwing an exception.
Approach I am using needs configuration in SM69 or SM49 for commands.
Thanks
Mohinder
Edited by: Mohinder Singh Chauhan on May 5, 2011 11:37 AM
05-05-2011 10:40 AM
It will work fine
What exception you are getting ?
Please check that you have provided the file path correctly. If you debug the fm then you can see the open datast failing.
05-05-2011 12:24 PM
Hi Keshav.
here is the error.
The exception, which is assigned to class 'CX_SY_FILE_IO', was not caught in
procedure "ARCHIVFILE_SERVER_TO_SERVER" "(FUNCTION)", nor was it propagated by
a RAISING clause.
Error text: "Is a directory"
Error code: 21
Thanks Mohinder
05-05-2011 12:36 PM
Are you trying to move a directory (sub-directory ?) and not a file ?
(after ISU_M_GET_FILES_OF_DIR filter XY_FILETAB excluding records with TYPE = 'directory' OR recursively call the FM on subdirectories)
Regards,
Raymond
05-05-2011 2:00 PM
Hi
Yes I am trying to move content of One directory to othe other directory with UTF16 data to be converted in UTF08.
Thanks
Mohinder
05-05-2011 2:44 PM
Hi Ray/Keshav,
Thanks for your suggestion it worked, now I am able to get directory details and then post to other directory and delete source one. One thing which is left data fetched shoudl be converted to UTF08.
Thanks
Mohinder
05-19-2011 11:41 AM
Hi Mohinder,
we can use the following unix commands in abap to move the file from source to destination.
This is a code showing how to create and use COPY command of UNIX in ABAP
PARAMETERS:
Input file path
p_input TYPE localfile,
Processed file path
p_proc TYPE localfile.
Declare the Types to file data
TYPES: BEGIN OF L_X_OUTPUT,
sys(200), " Please note, there are asterisk before and after sys (i.e.sys)
END OF L_X_OUTPUT.
* Internal table to store file data
DATA l_i_output TYPE STANDARD TABLE OF l_x_output WITH HEADER LINE.
* Variable for the UNIX command
DATA: l_v_unix_comm(255) TYPE c.
Copy command of UNIX
CONCATENATE 'cp' p_input p_proc
INTO l_v_unix_comm SEPARATED BY space.
For example the Copy command is stored as below
cp u2018/data/interfaces/input/input_fileu2019 u2018/data/interfaces/processed/processed_fileu2019
Examples of UNIX Command *u2022 mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a *different directory (see below) *u2022 cp filename1 filename2 --- copies a file
Execute the UNIX Copy command.
This command will copy the file from input file path to the processed file path
CALL 'SYSTEM' ID 'COMMAND' FIELD l_v_unix_comm
ID 'TAB'
FIELD l_i_output-sys.
IF sy-subrc eq 0.
write: 'File is copied successfully using UNIX command in ABAP'.
ENDIF.
05-20-2011 9:08 AM
Hi Mohinder,
For converting the XSTRING to STRING and vice versa dont any Function Module other than the below mentioned. Because when you have some special character like ` ~ 3/4 etc... all other Function Modules wont work other than these. Very usefull FMs.
NLS_STRING_CONVERT_FROM_SYS
NLS_STRING_CONVERT_TO_SYS
Thanks,
Bhargav.