Issue in Download file - If the file name is same

Hi Experts,
I have a requirement to download the company code hierarchy data into a file. On selection screen I am giving the file path along with the file name If I run the report it is downloading the data into the particular file in the file path this is expected result but if i am running the report with same filename which is already exists in the same path then instead of replacing the file with new data it is appending the data to that file.
But my expected result is: If the file name is same, file should be replaced with the Current Data instead of Appending the file.
And this issue is happening for the file formats TXT and CSV and also this issue is happening only when i am saving to the local drive.
I executed  the report by giving the file name Eg: " XXXX.xls" extension even in this case the records getting replaced with the new data, problem is when the file extension is with TXT and CSV formats.
FYI... to download the data i am using the below funtion module and i am passing the below parameters: Please correct me if i am wrong.
   CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       FILENAME                        = G_LFILE
       FILETYPE                        = G_FILETYPE
       APPEND                          = 'X'
       WRITE_FIELD_SEPARATOR           = GC_FIELDSEP    " Passing X
       TRUNC_TRAILING_BLANKS           = GC_TRUNCBLNKS " Passing X
       DAT_MODE                        = GC_DATMODE                 "Passing X
       CODEPAGE                        = G_LCODEPAGE
      TABLES
        DATA_TAB                        = GT_ITAB_HIER1
     EXCEPTIONS
       FILE_WRITE_ERROR                = 1
       NO_BATCH                        = 2
       GUI_REFUSE_FILETRANSFER         = 3
       INVALID_TYPE                    = 4
       NO_AUTHORITY                    = 5
       UNKNOWN_ERROR                   = 6
       HEADER_NOT_ALLOWED              = 7
       SEPARATOR_NOT_ALLOWED           = 8
       FILESIZE_NOT_ALLOWED            = 9
       HEADER_TOO_LONG                 = 10
       DP_ERROR_CREATE                 = 11
       DP_ERROR_SEND                   = 12
       DP_ERROR_WRITE                  = 13
       UNKNOWN_DP_ERROR                = 14
       ACCESS_DENIED                   = 15
       DP_OUT_OF_MEMORY                = 16
       DISK_FULL                       = 17
       DP_TIMEOUT                      = 18
       FILE_NOT_FOUND                  = 19
       DATAPROVIDER_EXCEPTION          = 20
       CONTROL_FLUSH_ERROR             = 21
       OTHERS                          = 22
    IF SY-SUBRC <> 0.
      G_FNAME = G_LFILE.
      MESSAGE E043(ZFI) WITH G_FNAME.
    ENDIF.
Can any one please provide me the solution.
Thanks in advance.
Koushik

Hi all,
Issue got resolve. I have used the class CL_GUI_FRONTEND_SERVICES
and the methods file_delete and file_exist. below is the sample code :
  1)  Write the below code in subroutine “PEFORM FILL_DATA_FILE” to check the given file exists in the directory or not.
DATA: lv_FILENAME TYPE STRING,
           lv_RESULT  TYPE C,
           lv_rc TYPE i.
           lv_FILENAME = g_lfile.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
      EXPORTING
           FILE                 = lv_FILENAME
      RECEIVING
           RESULT               = lv_RESULT
      EXCEPTIONS
           CNTL_ERROR                          = 1
           ERROR_NO_GUI                     = 2
           WRONG_PARAMETER          = 3
           NOT_SUPPORTED_BY_GUI  = 4
           OTHERS                                   = 5.
    IF lv_RESULT = 'X'.
      lV_RC = '1'.
    ELSE.
      lV_RC = '0'.
    ENDIF.
  2)  If the given file is exists in the directory(or in the given file path) delete or modify that file with the current data
      for that add the below code :
         IF lv_rc = 1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
      EXPORTING
        FILENAME             = lv_FILENAME
        CHANGING
        RC                           = lv_RC
      EXCEPTIONS
        FILE_DELETE_FAILED   = 1
        CNTL_ERROR                = 2
        ERROR_NO_GUI           = 3
        FILE_NOT_FOUND       = 4
        ACCESS_DENIED           = 5
        UNKNOWN_ERROR      = 6
        NOT_SUPPORTED_BY_GUI = 7
        WRONG_PARAMETER      = 8
      OTHERS               = 9.
    IF SY-SUBRC <> 0.
       *           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
       *           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.       
   ENDIF.
   ENDIF.
Thanks,
koushik

Similar Messages

  • How do I get a "Details" display--as the default--when downloading a file, in the "Enter name of file to save to..." dialog box?

    When I receive an attachment to an email, and I click it and select "Download", I get the "Enter name of file to save to..." dialog box (because I already set the option to "Always ask me where to save files." But the file display always defaults to a "List". At least recently. I don't recall it always doing that. In any case, I want it to default to a "Details" display, in ascending order, as I can then find things sooo much faster that way. (I often use the "Date Modified" tab to bring to the top the most recent version of a file.) I know that I can go to the "View Menu" icon and select "Details", but each time I go into a sub folder while in this dialog box, I have to do that all over again and it wastes a lot of time and attention.
    I did some internet searches but didn't find a way to fix this.

    Thanks for reaching out, glennr.
    The dialog box you are describing is controlled by Windows, not Firefox, so unfortunately Firefox cannot change what you see by default.
    I think your best bet would be to ask on the [http://answers.microsoft.com/en-us/windows/forum/windows_xp?auth=1 Windows support site].

  • How to create a record based on the name of a file in the file-system?

    Hi,
    With a lot of pictures I want to have a database to gather some information about these pictures.
    First question is how to generate a record based on a file in the file system?
    e.g. the pictures are "c:\fotos\2009\01\disc_001.jpg" to "c:\foto\2009\01\dis_98.jpg" .
    now i want to create records with as one of the attributes the name of the picture (not the picture itself). how to create these records (based on the information of the file-ssytem). i.e. the number of records should be the same as the number of pictures.
    any suggestions?
    any reaction will be appreciated.
    Leo

    Link to Create directory
    http://www.adp-gmbh.ch/ora/sql/create_directory.html
    You can create a list of files in the directory and read the list files from that directory.
    [UTL_FILE Documentation |http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10802/u_file.htm#996728]
    [Solution using Java|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:439619916584]
    SS

  • I was having an issue opening a spreadsheet with the file extension .xlsm. This appears as an attachment from a client which means macros were utilized when creating the spreadsheet. The problem lies in. The iPads ability to open the attachment. I downloa

    I was having an issue opening a spreadsheet with the file extension .xlsm. This appears as an attachment from a client which means macros were utilized when creating the spreadsheet. The problem lies in. The iPads ability to open the attachment. I downloaded the numbers app thinking this would be a default software to open any and all spreadsheets.
    Please Help!
    Ipad 2- iOS5

    You may need a version without macros on it. Unfortunately, pretty much all apps are skinned down versions of their original program, often with less functionality. For example in a word document I can italicize,bold and underline, but I only have a handful of fonts to play with and I don't think I can insert tables or images.
    It is very possible that the app simply cannot run macros, which means that document may never work on an iPad.

  • Dear All, today i am trying to generate a chm in Robohelp 11, by combining two topics under a single book but again and again i am facing same issue  that is "Cannot open the file: mk:@MSITStore: C:\\Users\..\Desktop\filename.chm"

    Dear All, today i am trying to generate a chm in Robohelp 11, by combining two topics under a single book but again and again i am facing same issue  that is "Cannot open the file: mk:@MSITStore: C:\\Users\..\Desktop\filename.chm"
    Amy_WongWoojinDebbieclawsonmghalpinjwarrenJochem van DietenLee Design
    Please help me in solving the same

    HI,
    Thanks for the response.
    I am really tensed for the same...
    Actually the error occurs in the following case:
    1. I am creating a Parent folder in robohelp with the name ABC..
    2. Next Under ABC i have created 2 separate folders say XYZ and EFG.
    3. Under XYZ i have created various Topics say 2 or 3.
    4. Under EFG i have created various Topics say 7 or 8.
    5. Now, i have created a TOC with name for ABC (Parent Folder.)
    6. Next i have dragged and dropped my two sub folders that i have created under ABC in Project Set up wizard that is XYZ and EFG, in order to generate the webhelp first and then the CHM file fo rthe same.
    7. Webhelp is successfully getting generated.
    8. But when i convert the Webhelp to CHM Converter, after few seconds the robohelp gets halt and it shuts up the robohelp, showing a message dialog box that the Adobe Robohelp 11 is Troubleshooting for the error, the Windows manager will get back to you..Someting like this, the .CHM file for the same gets generated on the described path, but when i click on it, it does not open and shows the error as "Cannot open file: mk:@MSITStore: C:\\Users\..\Desktop\filename.chm".
    Please  help me in sorting the above issue.
    According to me:
    I think i am Lacking in the two things:
    1. How to link all the topics with the parent folder.
    2. How to Merge the projects.
    Can you please provide me the link where i can get tutorial to create a TOC for multiple files in a same TOC and to generate a chm for them.
    Actually for single project folder i have worked successfully. But, its first time i have to create a chm with lot many sub folders in it, as like one create a book.
    Please help
    Thanks & Regards,
    dhm

  • HT4059 I got an error message that I should connect to Wi-Fi after trying to download a Book Sample from the iBooks Store. I still get this error message even after I bought, downloaded, and transferred the file to my iPad's iBook thru iTunes. Wi-Fi ain't

    I got an error message that I should connect to Wi-Fi after trying to download a Book Sample from the iBooks Store. I still get this error message even after I bought, downloaded, and transferred the file to my iPad's iBook thru iTunes. Wi-Fi ain't cheap.

    Hi I had a similar issue to you, I could connect to the router but no internet. Here is my explanation of how I sorted it.....I hope this works for you.
    *To anyone that is reading this it appears that the problem lay in the airport setting: IPV6: set to 'Automatically'. I turned it off (after reading someones plight on MacFixIt) & everything is back to normal.*
    *The worrying thing is although my problem was extreme with other computers on the network being locked out nothing was changed, one minute it worked the next it didn't. Reading on other forums it appears to be a problem with laptops (but I could be mistaken). A lot of people on the Macfixit forum are complaining of network just dropping out even when they are next to the router.*
    *I hope this is the fix (although I dont know why it suddenly went to sh*t!) & I hope my hair pulling & trawling the forums can help someone else out.*
    Much Respect
    Lammo

  • I have downloaded, extracted and installed Elements 12 but it will not open nor can I find the Adobe file in the file where I installed it to..  When I've tried to download and install again

    I have downloaded, extracted and installed Elements 12 but it will not open nor can I find the Adobe file in the file where I installed it to..  When I've tried to download and install again it says that the "Object Already Exists."  It may exists, but it is not visible in the file or in my list of programs on the Startup Menu.

    cactisken
    You should not have to uninstall Premiere Elements 12/12.1 in order to install and run Premiere Elements 13 on the same computer unless your computer is overloaded and the computer resources are compromised. Just use one program at a time.
    Can you still use 12/12.1 on this same computer that will not let you use 13?
    What specific Window operating system are you using?
    Let us go through the usual drill...
    1. Does the problem exist with and without the antivirus and firewall(s) disabled?
    2. Are you using a pen and tablet device instead of a mouse?
    3. Did you install the program with antivirus and firewall(s) disabled?
    4. Disable the SLCache Folder found in Windows 7, 8, or 8.1 64 bit
    Local Disk C
    Program Files (x86)
    Common Files
    Adobe
    and in the Adobe Folder should be the SL Cache Folder that you delete or disable by renaming the Folder
    from SLCache to SLCacheOLD.
    5. Are you running the program as Administrator and is the latest version of QuickTime installed on the same
    computer as Premiere Elements 13?
    Let us start here and then decide what next.
    Thank you.
    ATR

  • When downloading, why do I get a message saying "Safari cant open file because the file has moved since it was downloaded?"  I just attempted to download the file from a website.  Thanks.

    When downloading from a website, I get a message that says, "Safari cant open th file--- because the file has been moved since you downloaded it.  How do I correct this problem.  It wont let me open attachments from yahoo email either.  Thanks.

    EDIT:
    After posting I see this question has the tag of "windows". I don't know if this applies to the Windows version or not.
    The only time I see this message is if I download something, trash it, AND empty the trash. If I don't empty the trash, it finds it there. It will find it wherever I move it to, unless it is was in the trash and emptied.
    Using Finder, is the downloaded file in your Downloads folder?
    Maybe if you go to Safari/Preferences/General and change the location for downloads to something else then change it back to Downloads it might correct it.

  • I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    Exactly what do you mean by a 'downloader'?
    Thanks
    Pete

  • TS3212 Trying to download iTunes 10.7 in Windows 7 64-bit. When I click the download now button, it immediately goes to the "Thank you for downloading" screen, but the file has not downloaded. Popups unblocked. Any thoughts? Thanks!

    Trying to download iTunes 10.7 in Windows 7 64-bit. When I click the download now button, it immediately goes to the "Thank you for downloading" screen, but the file has not downloaded. Popups unblocked. Any thoughts? Thanks!

    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/quicktime/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • IPhoto says it cannot import my photos b/c they may be an unrecognized file or the file may not contain valid data. The operation could not be completed. Error code is: ImageCaptureCoreError-9905.

    Unable to download photos from my camera. iPhoto returns an error message that states: The following files could not be imported (they may be an unrecognized file or the files may not contain valid data). FILE NAME: 100_0490.JPG      REASON: com.apple.ImageCaptureCoreError- 9905.  WHAT'S UP WITH THAT?  Did not have a problem importing photos under the LEOPARD OS, however, now that I have upgraded to Yosemite 10.10.3 the iPHOTO app is not performing the imports.

    Are you using Photos, or iPhoto? Maybe you've got a corrupt file on your camera. I would try using the image capture application to import the bad picture to my desktop. If it works and the picture looks ok,  then delete that pic from the camera, then try to import into iphoto again. You can then import the pic it was saying was bad from your desktop.
    Or, try downloading all the pics using image capture and then import from the download folder.

  • Excel cannot open the file because the file format or file extension is not valid

    pls help 

    Hi,
    In regarding of the issue, please provide us more information to assist you better.
    Which Office version are you using? Office 2013 or other.
    Did the issue occur with the special file or every file?
    Then, based on your error message, this problem has been confirmed to be caused by malware on the affected machine. There are now two known variants of malware which causes this problem: Win32/Crilock.A and
    Win32/Buma!rts. They have both been identified as a new family of ransomware.
    In order to clean your machine, run Microsoft Safety Scanner (http://www.microsoft.com/security/scanner/en-us/default.aspx). If infected, Safety Scanner should clean the virus from
    the system, however it will not repair corrupted files. You will still need to restore those from a backup. A detailed analysis of affected files submitted to Microsoft for investigation has revealed the files are encrypted with a private
    and public key. The files cannot be recovered without the private key, which is more than likely held by the attacker. The premise of ransomware is such that if a person pays the ransom the key is provided to "unlock" the files.
    For more detail information, please refer to the following link:
    http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2013/09/07/quot-cannot-open-the-file-because-the-file-format-or-extension-is-invalid-quot-opening-office-files.aspx
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in
    Office programs.

  • Access denied error while writing a file to the file system - myfileupload.saveas() throws system.unauthorizedexception

    hi,
    as part of my requirement , i have to perform read and  write  operations of  few files [ using the file upload control in my custom visual web part] and on submit button click.
    but while writing these files - with the help of  fileupload control - and when i use  myfileupload.saveas(mylocation);
    - i am saving these files into my D:\ drive of my server , where i am executing my code -, am getting access denied error.
    it throws system.unauthorizedexception.
    i have given full control on that folder where i was trying to store my attached files. and also  after following asp.net forums,
    i have added  iusr group added and performed all those steps such that, the file is saved in my D:\ drive.
    but unfortunately  that didnt happen.
    also
    a) i am trying the code with runwithelevatedprivileges(delegate() )  code
    b) shared the drive within the  d :drive where i want o save the files.
    c) given the full privieleges for the app pool identity- in my case , its
    network service.
    the  other strange thing is that, the same code works perfectly in  other machine, where the same sp, vs 2012  etc were installed .
    would like to know, any other changes/ steps i need to make it on this  server, where i am getting the  error.
    help is  appreciated!

    vishnuS1984 wrote:
    Hi Friends,
    I have gone through scores of examples and i am failing to understand the right thing to be done to copy a file from one directory to another. Here is my class...So let's see... C:\GetMe1 is a directory on your machine, right? And this is what you are doing with that directory:
    public static void copyFiles(File src, File dest) throws IOException
    // dest is a 'File' object but represents the C:\GetMe1 directory, right?
    fout = new FileOutputStream (dest);If it's a directory, where in your code are you appending the source file name to the path, before trying to open an output stream on it? You're not.
    BTW, this is awful:
    catch (IOException e)
    IOException wrapper = new IOException("copyFiles: Unable to copy file: " +
    src.getAbsolutePath() + "to" + dest.getAbsolutePath()+".");
    wrapper.initCause(e);
    wrapper.setStackTrace(e.getStackTrace());
    throw wrapper;
    }1) You're hiding the original IOException and replacing it with your own? For what good purpose?
    2) Even if you had a good reason to do that, this would be simpler and better:
    throw new IOException("your custom message goes here", e);
    rather than explicitly invokign initCause and setStackTrace. Yuck!

  • Unable to start Photoshop CS6 - could not open a scratch file because the file is locked (Windows)

    When I first installed Adobe Photoshop CS6 I was unable to run Photoshop or Bridge CS6.  Photoshop would give me an error about "could not open a scratch file because the file is locked.  If I ran either of these programs as an administrator they would run without issue, this led me to believe that there was a permission issue somewhere.  After some digging I found out the both Bridge and Photoshop try to create a temp file (similiar to Photoshop Temp2777223910092) on the c:\ drive of the computer.  In my case the user that I was logged in with did not have access to write to the root of the C:\ drive.  Note that you run the program as the administrator and change the scratch disk location as that changes the preference for the administrator user and not the user that you are currently logged in as.
    To get around this issue I first had to give the user that I was logged on with write permissions to the root of the C:\ drive.  Next try and run Photoshop, you will get an error another error about the scratch disk and about and invalid or missing setting file.  To correct this you need to have run Photoshop as an administrator, next you can go to Users\Admin\AppData\Roaming\Adobe\Adobe Photoshop CS6\Adobe Photoshop CS6 Settings and copy Adobe Photoshop CS6 Prefs and/or Adobe Photoshop X64 CS6 Prefs to Users\<your logged in username>\AppData\Roaming\Adobe\Adobe Photoshop CS6\Adobe Photoshop CS6 Settings.
    Photoshop and bridge should now start up with no issues.
    I hope that this can help others out there as this caused me a great deal of frustration when upgrading to CS6.

    station_two wrote:
    OK, here comes the explanation of what the scratch disk does and why it's optimal to have it on a physically separate internal drive (not partition!) other than your boot drive
    I probably shouldn't say anything since it could complicate this thread, but the rules of thumb can be different under special circumstances when SSD is involved.
    IF you have a LOT of empty space on your SSD-based system drive, then Photoshop can actually work great with it's scratch setting pointed at the system drive.  This is because a) SSD transfers are much faster than spinning hard drives and b) there's no seek time, so simultaneous transfers to/from scratch and swap files aren't devastating to performance, and you can see a net gain because of the increased I/O throughput over what's possible using a separate spinning drive for scratch.
    But if you don't have a huge amount of free space (hundreds of GB) on the system SSD, it's definitely better to use a separate drive, as station_two has said.
    Also, up to about a year or so ago, you had to try to severely limit write activity to your SSD drive, since you could actually wear them out by repeated high data write activity.  That's pretty much a non-issue now with the advent of things like the SandForce in-drive controller that does wear-leveling inside the drive.  Modern drives will last 10 years or more in normal typical use, without special consideration.
    As it turns out, making a RAID array of SSDs is a great way to boost performance across the board, have bunches of free space, and ensure even the heaviest usage doesn't shorten the drive life.  I have done so, creating a 2 TB system drive C: made from 4 SSDs and Photoshop's swap file (and pretty much everything else) pointed to C:.  This system flies, and I can barely tell when Photoshop and/or Windows "goes virtual" and starts using its scratch/swap files heavily.  I don't even notice Photoshop auto-saves.
    Sorry for the SSD diversion.
    Back on topic: 
    Pretty much everyone who's successfully using a computer - Mac and PC users alike - comes to realize after a while that the task of integrating things on their computers and making everything work falls on THEM, not the developers of applications like Adobe.  Some applications pose unique challenges, but to think you can just throw up your hands and try to make it someone else's problem when something goes wrong simply isn't a viable strategy.  Maybe that's how things should be, but it's not how it is.
    For those of you struggling to get Photoshop to run properly, bear in mind that it's on you to get things working.  It works for most folks.  It could be a configuration or setup choice you've made that may need revisiting, or some kind of restorative activity that you need to do, or even something very minor like clearing your Photoshop preferences, but it may well take your learning new things and doing things you didn't think you'd have to do to get back to where you can edit photos.  It's no one's problem but your own.
    So let us here on the forum help you - when we say to do something, try it.  We're not here to jerk you around; we're users just like you who have already found the ways to make things work, and we'd like to help you do the same.
    -Noel

  • I just purchased Photoshop 13 for PC MS Windows 8.1  In trying to install, I get the following message after clicking on the 2nd file.  "The file archive part of Adobe Photoshop Elements 13 is missing.  You need all parts in the same folder in order to ex

    I just purchased Photoshop 13 for PC MS Windows 8.1  In trying to install, I get the following message after clicking on the 2nd file.  "The file archive part of Adobe Photoshop Elements 13 is missing.  You need all parts in the same folder in order to extract Adobe Photoshop Elements 13.  Please download all parts.:  I've also gotten an Exit Code: 7 when trying to install.  I've turned my McAfee virus system off while trying to install. 

    Hi,
    Have you tried downloading Photoshop Elements 13 from here?
    https://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-10-11-downloads.html
    There is only one file to download - which one depends on your system (32-bit or 64-bit).
    These are the trial versions but will convert to the full version when you supply your serial number.
    Brian

Maybe you are looking for

  • I bought a new airport extreme and on the first day, it worked well but the apple tv is lagging behind

    When I got this and hooked it up. it was so easy to connect it to the puter and all but apple tv is lagging behind, so slow and had to wait to catch up to be able to watch movie(s) What can I do about it? ( the previous airport extreme had no problem

  • All user folder icons showing as generic folder icon

    Hi all, I have an issue where all the folders in my User folder are the generic folder icon (e.g. not the pictures, music, desktop specific ones etc). This seems to not just be in my user area, but an issue with Finder, as when viewing my Mac mini's

  • Although AME Generates An Error As An Employee Does Not Have A Supervisors

    Hello, In self service Although AME Generates An Error As An Employee Does Not Have A Supervisors, Users Can Still Submit The Transaction. See the metalink Note Id 567351.1 Patch has been given for 11i But not r12. I m getting the same issue in r12.

  • UCM setup  DR (Disaster Recovery) environment

    Hi all, We did implementation part in production. Now we are planning setup DR (Disaster Recovery) environment.When ever Production will goes down automatically RD will take place to provide continue services to user, But in installation part of RD l

  • Sleep Issues & more!

    When I close the lid on my ibook it will go to sleep like it should, but sometimes it will only stay asleep for a couple minutes and then come out of sleep then go back into sleep, ect. But then other times it will stay asleep like it should. Is ther