2009 Jun 04 1:52 PM
Hi Champs,
I need integerate UNIX application in my ABAP program. Below are the list of requirements for which UNIX will be required:
1) Need to move a file from one directory to another in Application server.UNIX command can be
MV Source Target
2) Need to search for a file in certain Directory.UNIX command can be
LS <file> Directiories where in files to be search.
Please can you help me out how to integerate UNIX code with ABAP report.
Regards,
Nishant Khimesra
2009 Jun 04 4:50 PM
Nishant,
To move a file from one directory to another in Application server.
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'mv /tmp/file1.txt /usr/tmp/file1.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.To search for a file in certain Directory.
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'ls /tmp/file1.txt '.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.Regards
Sabu
Hi Champs,
I need integerate UNIX application in my ABAP program. Below are the list of requirements for which UNIX will be required:
1) Need to move a file from one directory to another in Application server.UNIX command can be
MV Source Target
2) Need to search for a file in certain Directory.UNIX command can be
LS <file> Directiories where in files to be search.
Please can you help me out how to integerate UNIX code with ABAP report.
Regards,
Nishant Khimesra
2009 Jun 04 1:55 PM
hi,
you can do all the things by using the below commands..
FTP_CONNECT "Connect to FTP server
FTP_COMMAND "Execute FTP Command--here by passing you cammand you can do
FTP_DISCONNECT " Disconnect from FTP server
Prabhu
2009 Jun 04 2:00 PM
Thanks Prabhu.
Can you explain me with an example.
Thanks in advance
2009 Jun 04 4:50 PM
Nishant,
To move a file from one directory to another in Application server.
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'mv /tmp/file1.txt /usr/tmp/file1.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.To search for a file in certain Directory.
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'ls /tmp/file1.txt '.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.Regards
Sabu
2009 Jun 05 1:04 PM
Hi Sabu,
First of all thanks o ton for your help.....:)
"mv" command is working fine......
but "ls" command is not working upto my requirement.
My requirement is search a file named "abc.txt" in all the directories starting with "/usr/feeder/ " and to list all the directories in a table .
Can you help me out with this.
Thanks
Nishant
2009 Jun 05 3:26 PM
Nishant
Try the below code for searching a file:
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'find /usr/feeder/ -name abc.txt -print'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.This will search for a file named abc.txt in the directory /usr/feeder and all its sub-directories.
Let me know if you need more info.
Regards
Sabu.
2009 Jun 08 5:52 AM
Thanks a lot Sabu, it really worked......and fully marks rewarded to you for help
but one more thing, if I don't want to print the directories in my output screen.
I tried to remove the -print from the code but still the directory name are being output on the output screen.
Below is the code I am using with -print removed.
CONCATENATE 'find /usr/feeders -name' file1 INTO command SEPARATED BY SPACE.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-sys.
If you can further help me with this problem, that will be great.
Thanks a lot..
Regards,
Nishant
2009 Jun 04 5:24 PM
Alternative ways of doing the same is:
Moving Files:
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_SERVER'
EXPORTING
sourcepath = dir1
targetpath = dir 2
EXCEPTIONS
error_file = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF
Searching Files:
CALL FUNCTION 'SUBST_GET_FILE_LIST'
EXPORTING
dirname = p_p_fname
filenm = p_c_fname
pattern = p_c_pattern
TABLES
file_list = p_i_files
EXCEPTIONS
access_error = 1
OTHERS = 2.
IF p_i_files[] IS INITIAL.
' Error Message
ENDIF
2009 Jun 05 1:08 PM
write ur unix code
then execute it from ABAP using FM SXPG_COMMAND_EXECUTE
2009 Jun 05 1:25 PM
You can use the transaction SM69 to create your own unix commands and can use them in programs.
You can use the transactions to CG3Z and CG3Y to move the files to/from application server to presentation server.
Thanks,
Srinivas
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |