Page 1 of 1

ASCIIDelete not deleting files

Posted: Tue Jul 05, 2011 7:56 am
by appleglaze28
Hi guys..have any of you guys ever experienced when ASCIIDELETE function in TI is not working...I'm using TM1 9.5.1.

Re: ASCIIDelete not deleting files

Posted: Tue Jul 05, 2011 8:01 am
by Alan Kirk
appleglaze28 wrote:Hi guys..have any of you guys ever experienced when ASCIIDELETE function in TI is not working...I'm using TM1 9.5.1.
Sure.

(a) If you specify the wrong name or path, even if you're 100% convinced that you haven't.
(b) If you specify a file on a path that the account under which the TM1 server is running doesn't have the necessary permissions for.

I'm sure that others can think of more instances...

Re: ASCIIDelete not deleting files

Posted: Thu Nov 12, 2015 8:03 pm
by Wastecan
For what it's worth, here is a case where ASCIIDELETE does not work, when I EXPECTED it would (along with a workaround that will delete the file):

Data Source is Text.

In the Prolog you create a file via EXECUTECOMMAND (wait=TRUE) running in CMD.EXE where the output is redirected creating this file. Then at the end of the Prolog, you set DatasourceNameForServer to this newly created file.

In Data, you process the file created as part of the Prolog.

In Epilog, you want to clean up afterwards and delete this newly created file, so you try to ASCIIDELETE it... It does not delete because the file is in use.

Specifically...

Code: Select all

# Clean Up - Delete Redirected Output File
IF (FILEEXISTS( TM1RunOutput ) = 1);
     # This doesn't work as the file is being used!
     ASCIIDELETE( TM1RunOutput );

     IF (FILEEXISTS( TM1RunOutput ) = 1);
          TM1RunCmd = 'CMD.EXE /C "DEL ' | TM1RunOutput | '"';
          # EXECUTECOMMAND ( |Command|, |Wait|);
          nReturnCode = EXECUTECOMMAND ( TM1RunCmd , No);
     ENDIF;
ENDIF;

Code: Select all

14120   [10]   ERROR   2015-11-12 19:46:42.451   TM1.Server   sf_DeleteFile: Error on file "d:\tm1\prodx_logs\TM1RunCmd.txt". Error = error code:32  reason:"The process cannot access the file because it is being used by another process.
So the CMD.EXE creates and closes the file. Then the TM1 Process opens the file to read and processes it, but cannot delete it, because itself is not letting go before the Epilog. Maybe there is a way to get the TM1 Process to Close the file as a part of the Epilog so that the ASCIIDELETE in the Epilog would work...

This was all done in TM1 10.2.2

The workaround is shown in the code... Use EXECUTECOMMAND (wait=FALSE) running CMD.EXE /C DEL 'thefile', works.

- wastecan

Re: ASCIIDelete not deleting files

Posted: Thu Nov 12, 2015 9:47 pm
by lotsaram
Wastecan wrote:For what it's worth, here is a case where ASCIIDELETE does not work, when I EXPECTED it would (along with a workaround that will delete the file):
What you are seeing is normal and expected behaviour. For any file used as a data source the process will retain a read lock on the file until after the process commits at the conclusion of the Epilog tab. Therefore it is not possible for a process to delete it's own data source. This is I think commonly known.

The solution is to either delete from another later process or a wrapper process or to do as you have and delete via command line with a wait sufficient to ensure that the commit has happened and the process has closed.

Re: ASCIIDelete not deleting files

Posted: Fri Nov 13, 2015 9:08 am
by Gabor
Most 9.5.x had a problem with multiple data folder specified in tms.cfg, ASCIIDELETE didn't work properly in such a case.
The APAR pointed 10.x, I haven't rechecked 9.5.2 FP3 & Hotfixes. If this is your problem, you may try to write/delete your files in the last folder.