GetProcessErrorFileName()
-
- MVP
- Posts: 2832
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
GetProcessErrorFileName()
I've got a process that uses a text file as a data source, with the name of the file to be processed one of the input parameters. If a user provides an incorrect file name the process obviously bombs and produces an error log file. I would like to get the name of that error log file using GetProcessErrorFileName() but it doesn't work. According to the IBM documentation, the value in this variable is only available after the completion of either the prolog, metadata or data tabs. My error is in the prolog but since it is fatal the prolog never finishes and the variable is empty. Does anyone know of a strategy for executing a process and getting the value from GetProcessErrorFileName() when a fatal error occurs in the prolog?
-
- MVP
- Posts: 3652
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: GetProcessErrorFileName()
Can't you just avoid the fatal error? Test for the existence of the source file and if it isn't there set datasource type to null and itemreject to create the error file. Then on the epilog pick up the error file name ...
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
-
- MVP
- Posts: 2832
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: GetProcessErrorFileName()
Thanks for the idea. That's what i was thinking I was going to have to do, I was just wondering if there was some sort of way to get the error log file name without resorting to that.
-
- MVP
- Posts: 2832
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: GetProcessErrorFileName()
How do I set the DataSourceType to null? NULL doesn't exist in TM1. I tried setting it to an empty string and the process just tries to use the file I have specified in the data source tab instead of not trying to open anything. Here is my code:
Code: Select all
sPath = CELLGETS('Global Variables', 'Value', 'Path to Hierarchy Files');
IF(FILEEXISTS(sPath | pFileName) = 0);
DATASOURCETYPE= '';
ITEMREJECT('File is missing');
PROCESSBREAK;
ELSE;
DATASOURCENAMEFORSERVER= sPath | pFileName;
ENDIF;
-
- Posts: 132
- Joined: Thu Oct 23, 2014 10:15 pm
- OLAP Product: tm1, cognos bi
- Version: 10.2
- Excel Version: 2010
Re: GetProcessErrorFileName()
Try this:
sPath = CELLGETS('Global Variables', 'Value', 'Path to Hierarchy Files');
IF(FILEEXISTS(sPath | pFileName) = 0);
DATASOURCETYPE= 'NULL';
ITEMREJECT('File is missing');
PROCESSBREAK;
ELSE;
DATASOURCENAMEFORSERVER= sPath | pFileName;
ENDIF;
sPath = CELLGETS('Global Variables', 'Value', 'Path to Hierarchy Files');
IF(FILEEXISTS(sPath | pFileName) = 0);
DATASOURCETYPE= 'NULL';
ITEMREJECT('File is missing');
PROCESSBREAK;
ELSE;
DATASOURCENAMEFORSERVER= sPath | pFileName;
ENDIF;
-
- MVP
- Posts: 2832
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: GetProcessErrorFileName()
That doesn't work, the process still tries to open the file, even though it doesn't exist. What I ended up doing is this:
Code: Select all
IF(FILEEXISTS(sPath | pFileName) = 0);
DATASOURCETYPE= 'SUBSET';
DATASOURCENAMEFORSERVER= '}Clients';
DATASOURCEDIMENSIONSUBSET= 'All';
ITEMREJECT('File is missing');
PROCESSBREAK;
ELSE;
DATASOURCENAMEFORSERVER= sPath | pFileName;
ENDIF;
- 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: GetProcessErrorFileName()
It didn't work because there's a bug in your logic; when you execute the ItemReject the Prolog stops executing and moves on, exactly as it does if you use the statement on a Data record. Therefore it never hits the ProcessBreak line, therefore it does not bypass the Metadata and Data tabs.tomok wrote: ↑Wed Jun 06, 2018 5:51 pmThat doesn't work, the process still tries to open the file, even though it doesn't exist. What I ended up doing is this:What I am doing is setting the source to be a subset that I know always exists, whenever the file does not exist. The subset never gets processed because I send an error message to the log and then do a break. Not ideal but it does work.Code: Select all
IF(FILEEXISTS(sPath | pFileName) = 0); DATASOURCETYPE= 'SUBSET'; DATASOURCENAMEFORSERVER= '}Clients'; DATASOURCEDIMENSIONSUBSET= 'All'; ITEMREJECT('File is missing'); PROCESSBREAK; ELSE; DATASOURCENAMEFORSERVER= sPath | pFileName; ENDIF;
Because of the restrictive nature of GetProcessErrorFileName(), I never use the thing. Instead I use GetProcessErrorFileDirectory to get the path and append my own (usually more descriptive) file name. I then AsciiOutput that. That allows the ProcessBreak to execute.
"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.
-
- MVP
- Posts: 2832
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: GetProcessErrorFileName()
That makes sense. I changed the logic to this and it works like I want it to now:
Code: Select all
Prolog:
IF(FILEEXISTS(sFile) = 0);
PrologError = 1;
ITEMREJECT('Hierarchy file ' | sFile | ' not found');
ELSE;
DATASOURCENAMEFORSERVER= sFile;
ENDIF;
Code: Select all
MetaData (at the top):
IF(PrologError <> 0);
PROCESSBREAK;
ENDIF;
I realize I could do something with EXECUTEPROCESS to control this stuff but I don't like to use that due to internal issues. Process changes have to go through a lot of red tape because of SOX but I can can change chores any time I want.
-
- MVP
- Posts: 3113
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.0.9.18
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: GetProcessErrorFileName()
Hi Tom,
Related coding can be found here, though it's not using GetProcessErrorFileName() but rahter ExecuteProcess of a generic process that tests the file.
Related coding can be found here, though it's not using GetProcessErrorFileName() but rahter ExecuteProcess of a generic process that tests the file.
Best regards,
Wim Gielis
IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- Posts: 132
- Joined: Thu Oct 23, 2014 10:15 pm
- OLAP Product: tm1, cognos bi
- Version: 10.2
- Excel Version: 2010
Re: GetProcessErrorFileName()
Insetad of ITEMREJECT, I use LOGOUTPUT, which a new TI Function (from Version 10.2.2x) and then I use PROCESSQUITtomok wrote: ↑Wed Jun 06, 2018 5:51 pmThat doesn't work, the process still tries to open the file, even though it doesn't exist. What I ended up doing is this:What I am doing is setting the source to be a subset that I know always exists, whenever the file does not exist. The subset never gets processed because I send an error message to the log and then do a break. Not ideal but it does work.Code: Select all
IF(FILEEXISTS(sPath | pFileName) = 0); DATASOURCETYPE= 'SUBSET'; DATASOURCENAMEFORSERVER= '}Clients'; DATASOURCEDIMENSIONSUBSET= 'All'; ITEMREJECT('File is missing'); PROCESSBREAK; ELSE; DATASOURCENAMEFORSERVER= sPath | pFileName; ENDIF;
IF ( FILEEXISTS ( sDataSourceFile ) = 0 ) ;
sReturnMessage = 'INVALID_DATA_SOURCE_FILE: ' | sDataSourceFile ;
CELLPUTS ( sReturnMessage , cubUserParams , sUserName , elmActionButtonMessage ) ;
LOGOUTPUT ( 'ERROR' , 'Process executed by user ' | sDisplayUserName | ' was teminated with error code: ' | sReturnMessage ) ;
DATASOURCETYPE= 'NULL';
PROCESSQUIT ;
ELSE ;
DATASOURCETYPE = 'CHARACTERDELIMITED' ;
DatasourceASCIIDelimiter = ',' ;
DATASOURCENAMEFORSERVER = sDataSourceFile ;
DATASOURCENAMEFORCLIENT = sDataSourceFile ;
ENDIF ;