Product:
Planning Analytics 2.0.9.19
Microsoft Windows 2019 server
Issue:
How can i find data path to TM1 session?
Solution:
Search the internet and use the code to build something like this, it will check if the TM1S.CFG file is in the data or a \config\ folder, and then load the data from TM1S.CFG file to a dimensions, that you later can ask in your code for information from.
#Section Prolog
#****Begin: Generated Statements***
#****End: Generated Statements****
# -- get the data folder if the logs folder is logs or logfiles ---
sLogDirName1 = LOWER ('Logfiles\' ) ;
sLogDirName2 = LOWER ('Logs\' ) ;
sConfigDirName = LOWER ('Config\') ;
sDataDirName = LOWER ( 'Data\' ) ;
sBackupDirName = LOWER ( 'Backup\' );
sLogDirPath = LOWER( GetProcessErrorFileDirectory );
nLScan1 = SCAN (sLogDirName1, sLogDirPath) ;
nLScan2 = SCAN (sLogDirName2, sLogDirPath) ;
IF ( nLyckadScan1 <> 0 );
# sDataDirPath = DELET (sLogDirPath, nLScan1, LONG (sLogDirName1)) | sDataDirName;
# sBackupDirPath = DELET (sLogDirPath, nLScan1, LONG (sLogDirName1)) | sBackupDirName;
sConfigDirPath = DELET (sLogDirPath, nLScan1, LONG (sLogDirName1)) ;
ELSEIF ( nLyckadScan2 <> 0 );
# sDataDirPath = DELET (sLogDirPath, nLScan2, LONG (sLogDirName2)) | sDataDirName;
# sBackupDirPath = DELET (sLogDirPath, nLScan2, LONG (sLogDirName2)) | sBackupDirName;
sConfigDirPath = DELET (sLogDirPath, nLScan2, LONG (sLogDirName2)) ;
ELSE;
# the log folder can be the same as the datafolder
sConfigDirPath = sLogDirPath ;
ENDIF;
CFGpath = sConfigDirPath ;
pParamsList=UPPER(':adminhost:ServerName:DataBaseDirectory:PortNumber:ClientMessagePortNumber:ServerCAMURI:LoggingDirectory:MTQ:HTTPPortNumber:IntegratedSecurityMode');
Dlmtr=';';
LenDtr=LONG(Dlmtr);
DataSourceType='CHARACTERDELIMITED';
# -- change the folder options to match your setup ---
sAfolder = 'config\' ;
ConfigFile = 'Tm1s.cfg';
IF (FileExists(CFGpath | sAfolder | ConfigFile ) = 1 ) ;
DatasourceNameForClient= CFGpath | sAfolder | ConfigFile;
DatasourceNameForServer= CFGpath | sAfolder | ConfigFile;
ELSEIF (FileExists(CFGpath | ConfigFile ) = 1 ) ;
DatasourceNameForClient= CFGpath | ConfigFile;
DatasourceNameForServer= CFGpath | ConfigFile;
ELSE;
# -- will use tm1s.cfg in the data folder --
DatasourceNameForClient= 'Tm1s.cfg';
DatasourceNameForServer= 'Tm1s.cfg';
ENDIF;
DatasourceASCIIDelimiter='=';
DatasourceASCIIHeaderRecords=1;
DimName='SYS_ServerParameters';
IF( DimensionExists(DimName) = 0 );
DimensionCreate( DimName );
ENDIF;
IF( CubeExists( '}ElementAttributes_'|DimName )=0 );
AttrInsert( DimName , '' , 'Value' , 'S' );
ENDIF;
IF( CubeExists( '}ElementAttributes_'|DimName )=1 );
IF(DIMIX( '}ElementAttributes_'|DimName , 'Value' )=0 );
AttrInsert( DimName , '' , 'Value' , 'S' );
ENDIF;
ENDIF;
#Section Metadata #****Begin: Generated Statements*** #****End: Generated Statements**** #Section Data #****Begin: Generated Statements*** #****End: Generated Statements**** IF( SUBST( Param , 1 , 1)@<>'#' & Param @<>'' & SCAN(UPPER(Param) , pParamsList)>0 ); IF( SCAN( ';' , Value )>0 ); CurPos=1; ValueList=Value|Dlmtr; ParamNum=''; i=0; WHILE(CurPos>0&LONG( ValueList )>0); CurPos=SCAN( Dlmtr , ValueList ); Value=SUBST( ValueList , 1, CurPos-1); ValueList=DELET( ValueList, 1, CurPos+LenDtr-1); #LOGOUTPUT( 'INFO' , Param | ParamNum |' = '| Value ); DimensionElementInsertDirect(DimName, '', Param | ParamNum ,'N'); AttrPutS(Value, DimName, Param | ParamNum , 'Value' ); i=i+1; ParamNum=NUMBERTOSTRING(i); END; ELSE; #LOGOUTPUT( 'INFO' , Param |'='| Value ); DimensionElementInsertDirect(DimName, '', Param ,'N'); AttrPutS(Value, DimName, Param , 'Value' ); ENDIF; ENDIF; #Section Epilog #****Begin: Generated Statements*** #****End: Generated Statements****
More Information:
https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=trf-delet-1
https://www.ibm.com/docs/en/planning-analytics/2.1.0?topic=pctf-getprocesserrorfiledirectory
https://www.ibm.com/docs/en/cognos-tm1/10.2.2?topic=chores-running-chore-server-startup