Getting problem in file name
hi ,
i have to get the filename while uploading into one variable ,
for eg
suppose file name is sivakumar.txt
1.if i upload from desktop C:\Documents and Settings\sivakumar\Desktop\sivakumar.txt
2. if from c: c:\sivakumar.txt
i have to get only sivakumar.txt in the both case ....
i should upload the file from any where but i should get filename in my variable
right now i am using split command for desktop file could any one can help me
Hi
here check this program i am spliting the record depend upon ',' and dont use ws_upload etc fm's are obsolete....
data: begin of itab_string occurs 0,
record type char255,
end of itab_string.
data: L_FILETABLE TYPE FILETABLE,
L_FILETAB_H TYPE FILETABLE WITH HEADER LINE.
data: p_file1 type string.
selection screen .
PARAMETERS: P_FILE TYPE LOCALFILE.
initialization.
at selection-screen on value-request for P_FILE.
IF THE USER SELECT EXTENTION BUTTON IT WILL OPEN THE LOCAL DIRECTORY FOR SELECTING THE FILE LOCATION.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION = 'CSV'
DEFAULT_FILENAME = 'C:\Documents and Settings\196093\Desktop\STATUS.csv'
FILE_FILTER =
INITIAL_DIRECTORY = 'C:\Documents and Settings\196093\Desktop\'
MULTISELECTION =
WITH_ENCODING =
CHANGING
FILE_TABLE = L_FILETABLE
RC = RC
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
IF SY-SUBRC <> 0.
ELSE.
LOOP AT l_filetable INTO L_FILETAB_H.
P_FILE = L_FILETAB_H-FILENAME.
move p_file to p_file1.
EXIT.
ENDLOOP.
ENDIF.
passing the selected file name to gui_upload for loading the data
into internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab_string
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 I000(Z00) WITH 'PLEASE PROVIDE CORRECT FILE NAME'.
ENDIF.
loop at itab_string.
now split the statuses
split itab_string at ',' into itab_status-aufnr itab_status-asttx itab_status-asttx1.
and move one internal table
append itab_status.
clear itab_status.
endloop.
reward points to all helpful answers
kiran.M
Similar Messages
-
Ecxpert Problem in getting the original file name submitted by FTP
hai,
when i use the scheduled FTP Application receive mode to receive files from the remote machine, i am not able to get the original file name, Ecxpert itself maintaining it's own file name,
Even i query the tracking table also i am not able to find the original filename.
If anybody know how i can able to get the original file name?
thanks....I don't think there is an easy to capture this information. We ended up writing our own FTP tool so we could gather better data. The other problem we had seemed to be sporadic downloads from sites where setting Passive was required.
-
How to get the SQL file name in SQL*plus
hi all,
I have created two sql file at C drive as "c:\Createtable.sql" and "c:\Deletetable.sql"
afterwards i open
C:\>sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 30 11:37:10 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: scott/tiger
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> @C:\Createtable.sql'
Table created.
SQL> @'C:\Deletetable.sql'
Table dropped.
SQL>My problem is to get the name of the file as "c:\createtable.sql" and "C:\Deletetable.sql" in sql*plus enviornment.
Thanks & Regards
SinghDear Damorgan,
>>your version number to three decimal places
My Oracle DB Version i have already stated in my previous post is 10.2.0.1.0
Actually my problem is to get the sql files name we run in sqlplus enviornment with @ symbol. like
i have created one sql file in c drive as
"C:\Createtable.sql"
afterwords i have connected to sqlplus as
sql> conn scott/tiger
sql>@c:\createtable.sql
Now i want some query to get the name of the file which is run.
In actual my problem is as
i have suppose 10 or more SQL files in some folder ( sql1.sql, sql2.sql, sql3.sql ....).
i created one file to call all the 10 sql files (main.sql)
i have also one track_table which will keep track that which sql file is runned.
I want some automated script which will insert the record in that track_table....... for that i need the name of sql file which is runned.
Hope this will help you.
Thanks & Regards
Singh -
How to get the Output File Name as One of the Field Value From Payload
Hi All,
I want to get the Output file name as one of the Field value from payload.
Example:
Source XML
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_TEST xmlns:ns0="http://sample.com">
- <Header>
<NAME>Bopanna</NAME>
</Header>
</ns0:MT_TEST>
I want to get the Output file name as " Bopanna.xml"
Please suggest me on this.
Regards
BopannaHi,
There are couple of links already available for this. Just for info see the below details,
The Output file name could be used from the field value of payload. For this you need to use the UDF DynamicFile name with below code,
// Description: Function to create dynamic Filename
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
conf.put(key,a);
return "";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
conf.put(key,a);
return "";
With this udf map it with the MessageType as
(File Name field from Payload) > DynamicFileConfiguration>MTReceiver
Thanks
Swarup -
Getting the Source File name Info into Target Message
Hi all,
I want to get the Source file name Info into Target message of one of the fields.
i followed Michal BLOG /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
Requirement :
1) I am able to get the Target file name as same as the source file name when i check the ASMA in Sender & Receiver Adapter , with out any UDF...............this thing is OK
2) I took One field extra in the target structure Like "FileName" & I mapped it Like
Constant(" " )--UDF-----FileName
I Checked the Option ASMA in Both Sender & Receiver Adapters
Here iam getting the Target File name as same as Source file name + Source File name Info in the Target Field " FileName".
I Dont want to get the Target File name as same as Source file name. I want like Out.xml as Target file name.
If i de-select the Option ASMA in Adapters means it is showing " null" value in the target field "FileName".
Please Provide the Solution for this
Regards
BopannaHi All,
Iam able to do this by checking the Option ASMA in only sender adapter itself
Regards
Bopanna -
Getting error logical file name not maintained adequtely
Hi,
when i execute a z report and press the download botton getting error logical file name not maintained adequtely,see long text.
Below code i wriien. Please somebody help..
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'DOWNL'.
Determine and construct OS specific file name *
PERFORM get_file_name_for_os.
in the above perform , i wriien
FORM build_file_name USING pf_os
pf_with_file_extension
pf_param_1
pf_format
pf_fname.
DATA: lf_para1(20) TYPE c.
pf_param_1 hold the materialnr with leading zeros not prefered in *
download file name *
WRITE pf_param_1 TO lf_para1.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
logical_filename = 'Z_MATERIAL_BOM_FILE'
operating_system = pf_os
parameter_1 = lf_para1
PARAMETER_2 = ' '
PARAMETER_3 = ' '
USE_PRESENTATION_SERVER = ' '
with_file_extension = pf_with_file_extension
USE_BUFFER = ' '
IMPORTING
EMERGENCY_FLAG =
file_format = pf_format
file_name = pf_fname
EXCEPTIONS
file_not_found = 1
OTHERS = 2
Error handling.
CASE sy-subrc.
WHEN '1'.
MESSAGE e014(ba) WITH 'Z_MATERIAL_BOM_FILE'. "error message i am getting LEAVE.
WHEN '2'.
MESSAGE e213(ky) WITH 'Z_MATERIAL_BOM_FILE'.
LEAVE.
ENDCASE.Hi.
In file txn,
click on "Logical File Name Definition, Cross-Client" from the left.
Then click position and check for your logical file name.
If you dont get it, it means you need to create it. You can click on New Entries to create.
Thanks
Mani -
FM for getting the logical file name
Hi,
is there any FM for getting the logical file name.
Thanks
VikranthHi,
CONSTANTS: c_mask TYPE char9 VALUE ',.,..'.
Pick up the file path from the application server
FORM f1001_browse_appl_file .
DATA: lcl_directory TYPE char128.
lcl_directory = p_direct.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = lcl_directory
filemask = c_mask
IMPORTING
serverfile = p_f2 " Parameter File
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e000(zmm) WITH text-039.
flg_app = 'X'.
ENDIF.
Then use OPEN DATASET for data reading
Hope this Helps.
Manish
Message was edited by:
Manish Kumar -
How to get list of file names from a directory?
How to get list of file names from a directory?
Please helpIn addition, this:
String filename = files;Should be this:
String filename = files;
That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized. -
Problems getting just the file name using an upload component
Hi everyone, I'm using an upload component on my page and I need to get just the name of the image/file in order to store it in a database, I used the code of the tutorial and It works fine on mozilla but the problem comes when I use Internet Explorer because I get the whole path of the image/file and not just the name of it. I believe the browser is the cause of the problem, I already checked the http://jakarta.apache.org/commons/fileupload/, but I don't understand how to use anything, and not even the code of the tutorial works eventhough it is specified in comments:
// some browsers return complete path name, some don't
// make sure we only have the file name
String justFileName = uploadedFileName.substring
( uploadedFileName.lastIndexOf(File.separatorChar) + 1 );If anybody could helpme solve this problem I'd appreciate it so much
Regards
Yes
Message was edited by:
YeseniaLet's walk through the code...
File.separatorChar is the system-dependent default hame-separator charac tor. This field is initialized to contain the first character of the system property file.separator. On UNIX systems, the value of this field is '/'; on Microsoft Windows systems it is '\\'.
String justFileName =
// get the substring of uploadedFileName
// that starts after the last separator (\ or /)
uploadedFileName.substring
uploadedFileName.lastIndexOf(File.separatorChar) + 1
You say that this statement is returning the complete path name, for example:
C:\Documents and Settings\All
Users\Documentos\Mis im��genes\Im��genes de
muestra\Puesta de sol.jpgSo, we can make an assumption that the File.separatorChar must not be \, or else the statement would return Puesta de sol.jpg.
We know that it works for you on Solaris/Mozilla.
We also know that Misha has tested the statement in IE and it works for him.
(And I know that this tutorial was tested by a software engineer and a quality engineer, and it worked for both of them, as well as the tutorial author and a peer).
So, what is different here??????
Can you print out File.separatorChar and see if it is '\\' (I think the first \ is an escape char, that is \\ (escape-escape) is the equivalent of \ (backslash)) or '\'?
When you run it on another machine, how are you deploying it on the other machine? Is it deployed to Solaris and running on Windows?
Have you tested to see if it works on a Windows machine using Mozilla?
Thanks in advance for any light you can shed on the problem. -
How to Get Albums in File-Name-Order Photo
When I updated my iPod Touch to V4.0 and iTunes (V9 on Windows XP) re-synced it, I found that my photo albums were now in Picture Date order rather than PC file name order. I tried several things that didn't work.
What worked was using the Photoshop Essentials Organizer to change the picture date on all the photos in an album to the same date and time (this can be done to all selected photos in one operation).
I did the sync in two steps. First I moved the album out of the iTunes photos directory and then synced my iPod which deleted the album. Then I moved it back and re-synced.
Does anyone know of an easier trick? I’ve already submitted a feedback item to Apple that they should make file-name-order an option in iTunes
Andy…The trick that I used is to append the URL with the name of the file. So if your url is "http://domain.com/attach", use "http://domain.com/attach/filename.doc". IE and Netscape parse the URL to determine what the filename is, so by placing this text at the end, you essentially let the browsers know what the filename is. :)
I have design a program to get the attach file from an
attachment. But when I click the link to save the
file, the default name of the file is 'attach'
whenever I get different files. Who know what is the
problem, please tell me the truth.
Here are some codes of the program.<< snip >> -
How to get the long file name from an 8.3 name in Windows.
Because of a legacy string limitation, I have a list of files in 8.3 format. The actual files are saved with long names. How can I get the long name from the short name?
In JavaScript, I would get a file system object and get the file object from there with the short name. Then it's no problem to get the full name. But I don't see anything in Java that matches that. ???
Ideas?
Frank Perry, MSEEHere is what I did.
String displayName = "somefi~1.txt";
File fO = new File("c:\\"); // I have a more involved path but that's not important here.
String stPath = fO.getPath() + displayName;
File fD = new File(stPath); // get the file using the short name.
File fDc = new File(fD.getCanonicalPath()); // get another file using the cononical name
String FulldisplayName = fDc.getName(); // get the long name from there.
It's roundabout but it works. Since getName() on the file read with the short name only returns the name used to get the file, I open it twice. The alternative is to parse the cononical name for the file name but that's clumbsy too.
Frank -
How to get the right file name in an attachment
I have design a program to get the attach file from an attachment. But when I click the link to save the file, the default name of the file is 'attach' whenever I get different files. Who know what is the problem, please tell me the truth.
Here are some codes of the program.
download.jsp
<%="test.doc"%>
web.xml
<servlet-mapping>
<servlet-name>AttachmentServlet</servlet-name>
<url-pattern>attachment</url-pattern>
</servlet-mapping>
AttachmentServlet.java
public void doGet
Message msg = folder.getMessage(msgNum);
// the message I get is right and the name of the file in
// the attach in this message is right too.(I have printed)
Multipart multipart = (Multipart)msg.getContent();
Part part = multipart.getBodyPart(partNum);
ContentType ct = new ContentType(sct);
response.setContentType(ct.getBaseType());
InputStream is = part.getInputStream();
int i;
while ((i = is.read()) != -1) {
out.write(i);
out.flush();
out.close();The trick that I used is to append the URL with the name of the file. So if your url is "http://domain.com/attach", use "http://domain.com/attach/filename.doc". IE and Netscape parse the URL to determine what the filename is, so by placing this text at the end, you essentially let the browsers know what the filename is. :)
I have design a program to get the attach file from an
attachment. But when I click the link to save the
file, the default name of the file is 'attach'
whenever I get different files. Who know what is the
problem, please tell me the truth.
Here are some codes of the program.<< snip >> -
How to get the target file name from an URL?
Hi there,
I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
System.out.println("Opening connection to " + url + "...");
// Copy resource to local file
InputStream is = url.openStream();
FileOutputStream fos=null;
String fileName = null;
StringTokenizer st=new StringTokenizer(url.getFile(), "/");
while (st.hasMoreTokens())
fileName=st.nextToken();
System.out.println("The file name will be: " + fileName);
File localFile= new File(System.getProperty("user.dir"), fileName);
fos = new FileOutputStream(localFile);
try {
byte[] buf = new byte[1024];
int i = 0;
while ((i = is.read(buf)) != -1) {
fos.write(buf, 0, i);
} catch (Throwable e) {
e.printStackTrace();
} finally {
if (is != null)
is.close();
if (fos != null)
fos.close();
}Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
System.out.println("Opening connection to " + url + "...");
// Copy resource to local file
InputStream is = url.openStream();
FileOutputStream fos=null;
String fileName = null;
StringTokenizer st=new StringTokenizer(url.getFile(), "/");
while (st.hasMoreTokens())
fileName=st.nextToken();
System.out.println("The file name will be: " + fileName);
File localFile= new File(System.getProperty("user.dir"), fileName);
fos = new FileOutputStream(localFile);
try {
byte[] buf = new byte[1024];
int i = 0;
while ((i = is.read(buf)) != -1) {
fos.write(buf, 0, i);
} catch (Throwable e) {
e.printStackTrace();
} finally {
if (is != null)
is.close();
if (fos != null)
fos.close();
}Do you know how I can do that.
Thanks for your help
// JB
Edited by: jb-from-sydney on Feb 9, 2010 10:37 PMThanks for your answer.
By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
* Download locally a file from a given URL.
* @param url - the url.
* @param destinationFolder - The destination folder.
* @return the file
* @throws IOException Signals that an I/O exception has occurred.
public static final File downloadFile(URL url, File destinationFolder) throws IOException {
URLConnection urlC = url.openConnection();
InputStream is = urlC.getInputStream();
FileOutputStream fos = null;
String fileName = getFileName(urlC);
destinationFolder.mkdirs();
File localFile = new File(destinationFolder, fileName);
fos = new FileOutputStream(localFile);
try {
byte[] buf = new byte[1024];
int i = 0;
while ((i = is.read(buf)) != -1) {
fos.write(buf, 0, i);
} finally {
if (is != null)
is.close();
if (fos != null)
fos.close();
return localFile;
* Returns the file name associated to an url connection.<br />
* The result is not a path but just a file name.
* @param urlC - the url connection
* @return the file name
* @throws IOException Signals that an I/O exception has occurred.
private static final String getFileName(URLConnection urlC) throws IOException {
String fileName = null;
String contentDisposition = urlC.getHeaderField("content-disposition");
if (contentDisposition != null) {
fileName = extractFileNameFromContentDisposition(contentDisposition);
// if the file name cannot be extracted from the content-disposition
// header, using the url.getFilename() method
if (fileName == null) {
StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
while (st.hasMoreTokens())
fileName = st.nextToken();
return fileName;
* Extract the file name from the content disposition header.
* <p>
* See <a
* href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
* //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
* information regarding the headers in HTML.
* @param contentDisposition - the content-disposition header. Cannot be
* <code>null>/code>.
* @return the file name, or <code>null</code> if the content-disposition
* header does not contain the filename attribute.
private static final String extractFileNameFromContentDisposition(
String contentDisposition) {
String[] attributes = contentDisposition.split(";");
for (String a : attributes) {
if (a.toLowerCase().contains("filename")) {
// The attribute is the file name. The filename is between
// quotes.
return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
// not found
return null;
} -
How to Get OHD's file name of last run?
Hi Experts,
I am currently generating a file, through a Process chain, from OHD that contains the BW system timestamp as part of its logical filename. There is a requirement to log the file name generated along with the number of rows..
Is there anyway of getting this informaiton.. Are there any logs that are created for OHDs when they are run that contain this info?
Thanks in advance.
Vjhi,
please see below threads
how to generate the open hub file format as .txt ?
Open HUB Destination
Open Hub Destination
hope this will be helpful to you
regards
laksh -
Get path and file name from Bfile
Hi,
I'm using Bfile to store images in a database. Is there a way to get the path and file name of the image from Bfile, because I need to pass that information into an image processing function.
Many thanks.
SheldonCan you use FILEISOPEN in the DBMS_LOB package?
See http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl03prg.htm#281893
-- CJ
Maybe you are looking for
-
Unusual Error in G/L account creation because of "Post Automatically only"
Hi, While creating G/L account, I am facing typical Error. Please find below sequence of activities I did. 1) Given G/L account number and company code on first pop Up 2) Went to Create/Bank/Interest Tab and gave Field status group 3) Came to Type/De
-
Merge iphoto libraries onto an external HDD
We have 3 macs at the house and they all have different Iphoto libraries. I would like to merge them all onto the one Library of the Imac with an External HDD. The problem is that a bunch of the pictures are on more than one of the computers. I was h
-
Best way to transfer DVD videos from laptop to ipad air
Best way to transfer DVD videos from laptop to ipad air
-
Hi while doing po system allowing me to print PO before releasing it i want to prevent it How please guide Regards kailas
-
Making a correct, "Approval Templates Setup, Terms Tab"
Hello, I'm trying to make an Approval Template for the u201CGoods Receipt POu201D and u201CA/P Invoiceu201D windows user. I need that they ask for authorization when u201CItem/Service typeu201D is in u201CServiceu201D mode. I try by making a query b