2006 Oct 10 1:11 AM
Hi,
how to move the file from original folder
in application server to backup folder.
2006 Oct 10 1:30 AM
You must copy this file and delete the old one. Here is an example program.
report zrich_0001.
Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
data: itab type table of string.
data: wa type string.
start-of-selection.
* Read file
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
append wa to itab.
enddo.
endif.
close dataset d1.
* Copy to new file
open dataset d2 for output in text mode.
loop at itab into wa.
transfer wa to d2.
endloop.
close dataset d2.
* Delete the first
delete dataset d1.
Regards,
Rich Heilman
Hi,
how to move the file from original folder
in application server to backup folder.
2006 Oct 10 1:30 AM
You must copy this file and delete the old one. Here is an example program.
report zrich_0001.
Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
data: itab type table of string.
data: wa type string.
start-of-selection.
* Read file
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
append wa to itab.
enddo.
endif.
close dataset d1.
* Copy to new file
open dataset d2 for output in text mode.
loop at itab into wa.
transfer wa to d2.
endloop.
close dataset d2.
* Delete the first
delete dataset d1.
Regards,
Rich Heilman
2006 Oct 10 1:38 AM
Hi Guys,
in the following way i am writing a file for my customer. now i want to take back up. for that i am thinking of file to another directory.
is it possible. if so can you suggest somechangs inth efollowing code.
appreciate your timely help.
form writefile.
data: msg(100).
data: todir like rsmrgstr-path value '/apps/MQBridge/idocproc/'.
data: tofile like edi_path-pthnam.
clear msg.
concatenate todir 'amkor4b2' sy-datum sy-uzeit w_seqno '.xml'
into tofile.
open dataset tofile for output in text mode encoding default
message msg.
if sy-subrc ne 0.
message e168(j4) with tofile.
else.
write:/ 'File transferred:', tofile.
endif.
loop at wlines.
transfer wlines to tofile.
endloop.
close dataset tofile.
endform. "WriteFile
2006 Oct 10 1:57 AM
2006 Oct 10 4:19 AM
Hi rich,
is it possible to copy the file without deleting the source file?
2006 Oct 10 2:07 PM
2006 Oct 10 1:30 AM
Hi Nihi,
If you have the authority to execute Unix command then this is what you should write in your ABAP prg.
DATA: COMMAND(200).
DATA: BEGIN OF TABL OCCURS 0,
LINE(255),
END OF TABL.
command ='cat > /hodarchlogs/outbound/testfile.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND ID 'TAB' FIELD TABL-SYS.
if sy-subrc = 0.
write : 'Success'.
endif.
and if you do have this authority then there is a workaround method...
You have to create a command "zmv" throught t-code SM69... this command should be tested using t-code SM49 ...
and then in you ABAP code you should call the following FM :-
Internal table to store the move to directory.
DATA : T_MOVETODIR LIKE BTCXPM OCCURS 0 WITH HEADER LINE.
DATA : ARCH_DIR TYPE SXPGCOLIST-PARAMETERS.
CONSTANTS : C_CMD_TEST LIKE SXPGCOLIST-NAME VALUE 'ZMV'.
(This ZMV is the command defined in SM69).
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = C_CMD_TEST
ADDITIONAL_PARAMETERS = ARCH_DIR
OPERATINGSYSTEM = SY-OPSYS
TARGETSYSTEM = SY-HOST
DESTINATION =
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE =
IMPORTING
STATUS =
EXITCODE =
TABLES
EXEC_PROTOCOL = T_MOVETODIR
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
OTHERS = 15
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
hope this helps you.