ASCIIDelete not deleting files
-
- Regular Participant
- Posts: 269
- Joined: Tue Apr 21, 2009 3:43 am
- OLAP Product: Cognos TM1, Planning
- Version: 9.1 SP3 9.4 MR1 FP1 9.5
- Excel Version: 2003
ASCIIDelete not deleting files
Hi guys..have any of you guys ever experienced when ASCIIDELETE function in TI is not working...I'm using TM1 9.5.1.
- Alan Kirk
- Site Admin
- Posts: 6606
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: ASCIIDelete not deleting files
Sure.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.
(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...
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
- Wastecan
- Posts: 1
- Joined: Mon Jan 04, 2010 7:38 pm
- OLAP Product: TM1
- Version: 9.5.2
- Excel Version: 2003-2007-2010
Re: ASCIIDelete not deleting files
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...
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
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.
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
-
- MVP
- Posts: 3654
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: ASCIIDelete not deleting files
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.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):
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.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
-
- MVP
- Posts: 170
- Joined: Fri Dec 10, 2010 4:07 pm
- OLAP Product: TM1
- Version: [2.x ...] 11.x / PAL 2.0.9
- Excel Version: Excel 2013-2016
- Location: Germany
Re: ASCIIDelete not deleting files
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.
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.