Files in a directory on presentation server
Hello all,
Do you know which FM or class to use to get a list with files from a local directory.
There is a function Z_DIR_GET_FILES, which does this thing but the file name is trucated if it have more than 21 characters.
Thank you!
Bogdan
Check this one.
FORM f9008_f4_hlp_for_pc_file.
DATA: li_filetable TYPE STANDARD TABLE OF file_table,
lv_return TYPE i,
lw_filetable TYPE file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select file for download'
default_extension = '.txt'
initial_directory = 'C:'
CHANGING
file_table = li_filetable
rc = lv_return
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE e006 WITH text-077.
ELSE.
READ TABLE li_filetable INTO lw_filetable INDEX 1.
v_fnam = lw_filetable-filename.
ENDIF.
In adition to that there are
CALL METHOD cl_gui_frontend_services=>DIRECTORY_LIST_FILES
EXPORTING
CALL METHOD cl_gui_frontend_services=>DIRECTORY_GET_CURRENT
EXPORTING
This will Returns the Current Directory
U can have a look into the methods.
Hope this helps.
Similar Messages
-
List all files in a directory on a server that hosts the applet
Hei :)
I have a problem. I want to list all files in a directory on my server. ( http://www.foo.bar/tw )
The applet is in the root folder ( http://www.foo.bar ).
So i tried it like this
File fi = new URL(getCodeBase() + "/all/").getFile();But when I try to list the files, I get a SecurityException.
Can anyone help me out?
Peace!
LoCalhttp://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=%2Blist+%2Bfile+%2Bserver
-
File Upload and Download From Presentation server
I have a requirement to provide a selection option to user to upload a big file from presentation server.
Not sure whther we can a upload the entire file at one short from presentation server. PLease provide some sample code to upload a huge file from presentation server and downlaod a file to presentation server.Hi,
Try this code for download----
TABLES:
kna1. " General Data in Customer Master
TYPES:
BEGIN OF type_s_kna1,
kunnr TYPE kna1-kunnr, " Customer Number
adrnr TYPE kna1-adrnr, " Address
anred TYPE kna1-anred, " Title
erdat TYPE kna1-erdat, " Date on which record created
ernam TYPE kna1-ernam, " Name of Person who Created the
" Object
END OF type_s_kna1.
DATA:
fs_kna1 TYPE type_s_kna1.
DATA:
t_kna1 LIKE
STANDARD TABLE
OF fs_kna1.
" Select-options----
SELECT-OPTIONS:
s_kunnr FOR kna1-kunnr. " Customer Number
AT SELECTION-SCREEN ON s_kunnr.
SELECT kunnr " Customer number
FROM kna1
INTO s_kunnr UP TO 1 ROWS.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE 'No such customer exists' TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
START-OF-SELECTION.
PERFORM customer_selection.
FORM customer_selection .
SELECT kunnr " Customer Number
adrnr " Address
anred " Title
erdat " Date of record creation
ernam " Person who created object
FROM kna1
INTO TABLE t_kna1
WHERE kunnr IN s_kunnr.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\TEMP\CUSTOMER.TXT'
FILETYPE = 'ASC'
write_field_separator = 'X'
HEADER = '00'
WRITE_LF = 'X'
col_select = 'X'
col_select_mask = 'XXXXX'
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
TABLES
data_tab = t_kna1
EXCEPTIONS
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " FORM CUSTOMER_SELECTION.
for upload----
" Table declarations----
TABLES:
bkpf. " Accounting Document Header
TYPES:
BEGIN OF type_s_bkpf,
bukrs TYPE bkpf-bukrs, " Company code
belnr TYPE bkpf-belnr, " Accounting Document Number
gjahr TYPE bkpf-gjahr, " Fiscal Year
blart TYPE bkpf-blart, " Document type
bldat TYPE bkpf-bldat, " Document Date in Document
END OF type_s_bkpf.
DATA:
fs_bkpf TYPE type_s_bkpf.
DATA:
fname(10) TYPE c VALUE 'ACCOUNTING' .
DATA:
t_bkpf LIKE
STANDARD TABLE
OF fs_bkpf.
*" Select-options----
SELECT-OPTIONS:
s_bukrs FOR bkpf-bukrs, " Company code
s_gjahr FOR bkpf-gjahr. " Fiscal year
OPEN DATASET fname FOR OUTPUT IN BINARY MODE .
PERFORM account_selection.
LOOP AT t_bkpf INTO fs_bkpf.
TRANSFER fs_bkpf TO fname.
ENDLOOP. " LOOP T_BKPF
CLOSE DATASET fname.
FORM account_selection .
SELECT bukrs " Company code
belnr " Accounting document number
gjahr " Fiscal year
blart " Document year
bldat " Document date
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr.
ENDFORM. " FORM ACCOUNT_SELECTION
also try
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEMP\CUSTOMER.TXT'
FILETYPE = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = t_kna1
EXCEPTIONS
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc EQ 0.
PERFORM customer_display.
ELSE.
MESSAGE 'No customer file exists'(006) TYPE 'S'.
ENDIF. " IF SU-SUBRC EQ 0
Regards,
jaya
Edited by: Jayapradha Neeli on May 28, 2009 11:38 AM -
How to upload the files of a directory to a server at one time?
in a jsp page ,the user choose a directory ,then I want to upload the files of the directory to a server at one time.How to do this?Thanks!
You create multiple file input fields and you have them select each file they want.
Or tell the user to zip the directory and upload the zip file.
Or use a signed applet to get all the files and send them.
There's no way for the browser to select a directory. -
How to work with files in folders on Application/Presentation Server
Hi,
I am working on interface program in which files are populated in folders in application/presentation server in the format 'ABCsy-datumsy-uzeit.txt'(e.g.ABC20051022161450.txt,ABC20051022161455.txt ) in directory c:\temp.
I want to sort all these files and read in sorted manner.
can anybody help me out in this.
waiting for reply.
thanks & regards,
NitinHi,
This logic will work for files on presentation server,
DATA: l_count TYPE i,
l_filename TYPE string,
t_files TYPE string OCCURS 0 WITH HEADER LINE,
BEGIN OF t_files_sorted OCCURS 0,
file_prefix(3),
file_date LIKE sy-datum,
file_time LIKE sy-uzeit,
file_extension(4),
END OF t_files_sorted,
t_text TYPE TABLE OF w3html.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = 'C:\Temp'
FILTER = '*.txt'
files_only = 'X'
DIRECTORIES_ONLY =
CHANGING
file_table = t_files[]
count = l_count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT t_files.
t_files_sorted = t_files.
APPEND t_files_sorted.
ENDLOOP.
SORT t_files_sorted BY file_date file_time.
LOOP AT t_files_sorted.
CONCATENATE 'C:\Temp\' t_files_sorted INTO l_filename.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = SPACE
HEADER_LENGTH = 0
IMPORTING
FILELENGTH =
HEADER =
changing
data_tab = t_text[]
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
others = 17.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*****Your processing here..
ENDLOOP.
Also, use the FM that MAX has if you have to work with files on application server by replacing code in the above logic at appropriate places, like replace
cl_gui_frontend_services=>directory_list_files
with the corresponding fm
and replace cl_gui_frontend_services=>gui_upload
with OPEN DATASET...
CLOSE DATASET...
logic.
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni -
Generating a XML file and Storing on the Presentation Server
Hi Experts,
I am facing a problem in generating and storing a XML file on Presentation Server.
I am using Call Transformation as follows:
CALL TRANSFORMATION id
SOURCE para = t_xml[]
RESULT XML xml_string.
APPEND xml_string TO xml_tab.
and then using GUID_DOWNLOAD to store the xml file on the PS.
DATA: xml_string type string,
xml_tab type table of string.
now on using GUI_DOWNLOAD, i get the runtime error as Illegal Type Casting.
On the other hand if i give the data declaration as follows, the code works fine.
TYPES: begin of ttab,
line(65535) type c,
end of ttab.
DATA: xml_string type string,
xml_tab type table of ttab.
SInce my data in INternal Table can be very large, 65535 characters are not sufficient for me.
How do i solve this problem???
Please help.
Regards
Gaurav Raghav
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 4:09 PMHey Gaurav,
Can you please tell me how did u solve the problem ..
i am also currently facing the same situation..please help me..
Regards,
Jessica Sam -
Getting files of a directory in app server
Hi,
Is there any FM or method to get all the files of a directory ( in the application server )if its path is given as input.
It should list the file name, creation date and also size.
Thanks,
Nawaz.Hi,
you can use the follow code:
REPORT zdirtest.
DATA lv_dir TYPE rsmrgstr-path VALUE '/usr/sap/trans/data'.
DATA: wa_files TYPE rsfillst,
it_files LIKE TABLE OF wa_files.
START-OF-SELECTION.
CALL FUNCTION 'SUBST_GET_FILE_LIST'
EXPORTING
dirname = lv_dir
filenm = '*'
TABLES
file_list = it_files
EXCEPTIONS
access_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE /1 'Error! :-('.
ELSE.
LOOP AT it_files INTO wa_files.
WRITE: /1 wa_files-name,
wa_files-len.
ENDLOOP.
ENDIF.
However the field <b>MTIME</b> from the structure <b>RSFIILST</b> is not filled correctly with the number of seconds since 1970 because the field is defined to small.
So you can't list the correct modification date and time.
If you really need this, you should take a look in the Report <b>RSWATCH0</b> in the form <b>fill_file_list</b>.
This form fills an internal table with the correctly modification date and time.
Regards,
Stefan -
List of files in a directory of app server
Hi,
I was trying to get the list of all files in a directory using fm "EPS2_GET_DIRECTORY_LISTING". But the date column is empty in the output table. I also tried fm's
SUBST_GET_FILE_LIST
EPS_GET_FILE_ATTRIBUTES
none of the above is giving date.
Can anyone tell me a fm which gives date along with other attributes?
Thanks in Advance.
Satishtry get something from the transaction AL11 source code: RSWATCH0 form -> fill_file_list
Regards,
Vincent -
Can't copy file from SAP-directory to FTP server
Hello,
I can't copy files from the SAP server to the FTP server. The file is created with OPEN DATASET and CLOSE DATASET commands and is placed in the SAP-directory S:\usr\sap\DEV\DVEBMBGS00\work.
I can see and read the file with transaction al11, so I know it's there.
But the FTP command always gives the same error:
S:\usr\sap\DEV\DVEBMBGS00\work\[FILENAME] errno 22: invalid argument
I can connect to the FTP, but the put command keeps failing. Somehow, the file in the SAP directory can't be read, it seems, even when
Any ideas?
Thanks in advance.
DaveOk, I found out that I have to use SAPFTPA as RFC destination type, instead of SAPFTP, otherwise the folders can't be located.
But with SAPFTPA I can't seem to connect to the FTP server. I've tested the connection with sm59 and it works, but for the FTP it doesn't work. When I use SAPFTP as destination type, it still works.
What can I do?
Thanks. -
Use XML files stored in directory of Application server as a input for XI ?
I have a scenario that there is a xml file stored in sap application server for example /inf/ERQ/XML/XXX.xml which i want to use it as an input for XI. I know that there is an adapter in XI for getting xml file stored in normal path but in my situation it's in application server of SAP so i don't know how to do this.
Any solution or example for this? Thank you in advance.
Best regardsHi,
We can read this file through FILE adapter with FTP protocol, before that i think need permission from basis for access. Configure source(according to xml format) and target structure according to your requirement. But one thing should remember in XI/PI sour/target XML formats should contain Message type name & namespace name else it can't work.
Find below link for more information.
Introduction to simple (File-XI-File)scenario and complete walk through for starters(Part2) -
How can I put a file in a directory server extracted by a abap report?
Hi!
I need to extract data from r/3 server by a report and put the output into one file in a directory of the server.
In Abap code someone know how can I do that?
Thanks!Hi,
I post this in the Abap forum but the response are very poor to make this. So, I think to post the message in XI forum because I work with thing of XI and I know that someone know how to put the file in the same server that I take out the data.
Tuhin give me a excellent link to make that!
Thanks! -
File conversion from text to CSV on present server without using GUI FM
Hi Folks,
This question may sound a bit weired but here it is. I have to convert a text file to csv using a SAP ABAP Report.
The file is located on the presentation server and I am using FM's <b>GUI upload</b> and <b>GUI download</b> to do the same as the number of fields change and we perform some operations on the data coming from the text file. Actually, the csv file is supposed to act as a source system for SAP BI.
Now my question is is there any other way by which we can do it without using the above function modules.
Thanks
VarunHi,
You upload the Text file using GUI_UPLOAD and now you will have the records in the internal table and then use GUI_DOWNLOAD to download the file in CSV format.
Thanks
PK -
How to create an EXCEL file in Presentation server
hello experts,
please suggest me a solution for the following problem :
I have an internal table with some data.
how can i create an excel file with that data in Presentation Server.
Thanks & Regards
sasi.hi,
u can use FM: 'DOWNLOAD'.
it will prompt u for destination - just give the requd filename and extension.
Ex:
call function 'DOWNLOAD'
exporting
filename =
filetype = 'DAT'
tables
data_tab = tb_output
fieldnames = tb_fld_nam
exceptions
invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
customer_error = 7
others = 8.
where,
tb_output = internal table having the fields which u want in the O/P
Ex:
data: begin of tb_output occurs 0,
name_1(20) type c,
name_2(20) type c,
end of tb_output.
tb_fld_nam = Field headings :
Ex:
data: begin of tb_fld_nam occurs 0,
name(25) type c,
end of tb_fld_nam.
tb_fld_nam-name = 'Name 1'.
append tb_fld_nam.
tb_fld_nam-name = 'Name 2'.
append tb_fld_nam.
Thanx & Regards,
Ajoy -
Hi Experts,
I need a FM which return all the file names in a specified directory of presentation server. I also need FM which will provide F4 help on presentation server to search directories.
Regards,
JeetuFunction module name Function module description
DOWNLOAD Store Internal Table with Dialog as File on the Presentation Server
WS_DOWNLOAD Save Internal Table as File on the Presentation Server
UPLOAD Load Data from the Presentation Server into an Internal Table / Dialog
WS_UPLOAD Load File from the Presentation Server into Internal Table
WS_FILENAME_GET Call file Selector
WS_EXECUTE Execute an External Program on the Presentation Server
WS_MSG Issue the Presentation Server style message
WS_EXCEL
WS_QUERY Execute query function on the Presentation Server
Reward points if useful..............
Regards
Minal -
How to run a "exe" file that is residing in application server.
Hi,
I have a requirement in which a .exe (Windows executive) file needs to be run through code, which is residing in the application server. That exe file is nothing but a pdf-excel converter that will convert a pdf file to excel. The corresponding pdf file is also in the application server. Is there any function module to make this happen? I have come across the FM GUI_EXEC, but it operates on exe and pdf files that are in the presentation server.HI Anirban
SM49 /SM69 might be of help
Could you please look into the link below.
Re: sm49/sm69
Maybe you are looking for
-
Project Server 2010 - Assigned tasks not visible in PWA
Hi, When I enter an issue on a project site, the assigned issue is not visible in the PWA under Issues & Risks. Based on this link (http://social.technet.microsoft.com/Forums/en-US/f5abd024-3c9a-47f8-a7cb-7743fafebf2b/project-server-2010-cannot-see-a
-
Creation of new merchanize category
Hi, Can some one explain me process of creatiing new merchandize category in IS-RETAIL.
-
Strange spots on the screen.
Anybody who knows what this is and how it can be fixed? http://forum.xda-developers.com/showthread.php?t=2401181 It isn't my post on that forum but I have the same issues. Anyone experiencing the same problem?
-
How to sync video in iphone3gs
i am facing problem in synchronizing video in iphone
-
Frm messages only in status line not as pop-up
How can I tell forms to display the frm-messages like frm-40406 transaction completed... only in the status line without any pop-up window which I have to confirm?