‎2009 Dec 21 5:26 PM
Hi friends. I need some help with dataset operations.
1-How can I move a file using dataset? Is possible do first copying file to target and after "delete dataset filename"?
2-How can I list directory files from unix directory? In windows I was using method "cl_gui_frontend_services=>directory_list_files" but I don't find anything for Unix.
Thanks a lot.
‎2009 Dec 22 12:41 AM
Hi,
1) Yes, of course. There are the ABAP commands OPEN DATASET, CLOSE DATASET, READ DATASET, DELETE DATASET and TRANSFER. Have a look at ABAP documentation.
2) cl_gui_frontend_services=>directory_list_files works on every platform. I guess that you struggle to list files on application server. There are some function modules from SAP which can be used to get a list of files on application server. Have a look here on SDN.
Cheers
‎2009 Dec 22 1:30 AM
Hi Fulvio,
1. Use SXPG_COMMAND_EXECUTE to move your file, e.g. "mv" command in Unix. Refer to that FM Documentation which is clear.
2. Use function module EPS_GET_DIRECTORY_LISTING to get a list of files in your Operating System directory.
Cheers,
Suresh
‎2009 Dec 22 7:49 AM
Hi above mentioned FM: SXPG_COMMAND_EXECUTE is used to execute the external commands in SAP, but the command should
be listed under tcode:SM69-Maintain External OS Commands. So first check whether u have any command like that or not other
wise what u can do is:
1. read the existing file into an internal table and then write(transfer) this into new file.
OR
2. Create ur own command(u can refer any custom commands (if u have) in SM69) for moving the file and then run this
command through the FM mentioned above.
‎2009 Dec 22 10:30 AM
Thanks for helpful answers friends. I tried method and function but don't works for me...
In method I done like this, but don't return anything...:
dir = '/usr/sap/PSD/interfaces/synchro/'
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = dir
filter = '*.TXT'
files_only = 'X'
CHANGING
file_table = it_file_table
count = count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6.In function EPS_GET_DIRECTORY_LISTING I'm tested it on SE37, but returns READ_DIRECTORY_FAILED.
I need some permission to list files in a Unix directory? In this directory I can write, because my program save a file in it using dataset...
Thanks friends!
‎2009 Dec 22 9:27 PM
Hi,
obviously cl_gui_frontend_services=>directory_list_files does not work for your folder because your folder is on application server, not on your desktop. I wrote that it does not depend on OS but it still has to be on user's desktop. So it works for Java GUI on LInux as well SAP Gui for Windows. YOu can debug EPS_GET_DIRECTORY_LISTING in SE37 to see why it's failing.
Cheers
‎2009 Dec 23 12:18 PM
Thanks for reply friends. I don't know why, but this FM don't work here. To try solve this, I search for others FM in SDN and SE37 and I found FM 'F4_DXFILENAME_TOPRECURSION'. This FM is used for search help, but I debugued it to see how its show the directory struture of server. I copy code and it works. I solved the problem, but I still unkwnowing why this FM doesn't worked for me.
Thanks guy!