ASCIIOUTPUT file locking/unlocking

Post Reply
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

ASCIIOUTPUT file locking/unlocking

Post by fleaster »

Hi all,
as you are probably aware, when calling an ASCIIOUTPUT function, TM1 will open the file for writing during the duration of the Prolog/Meta/Data/Epilog tab, then close it when proceeding to the next tab or exiting the process.

Question: Is there any way to force TM1 to close the file without needing to move to the next tab or exit the process?

...the context is I am creating a set of files that requires header+detail+footer sections. The header/details are written during the Data tab, and the footer files are written during the Epilog tab.

The next step is to merge all the detail+footer files together - however I have found I cannot do this during the Epilog tab of the original process (presumably because the footer files are still open) - hence I would need to create a whole new process just to merge the files.
Note: calling another process (to executecommand) from the Epilog also didnt seem to work - it appears that you have to exit the Epilog of the original process entirely.

Anyway, if anyone has any tips or workarounds for this it would be much appreciated.. otherwise I'll just have to go the long way around :p

Cheers,

Matt
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: ASCIIOUTPUT file locking/unlocking

Post by rmackenzie »

Are you aware of the command line operators that allow you to write/ append to file?

Usage in TI per this example:

Code: Select all

# setup
sFile = 'd:\data\temp.txt';

# test prolog output
sOutput = 'red lorry';
sCommand = 'cmd /c "echo ' | sOutput | ' >> ' | sFile | '"';
ExecuteCommand ( sCommand, 0 );

# ... skip to Epilog now
# test epilog output
sOutput = 'yellow lorry';
sCommand = 'cmd /c "echo ' | sOutput | ' >> ' | sFile | '"';
ExecuteCommand ( sCommand, 0 );
I've spread the examples over 3 lines for readability but you could squeeze them into one-liners to replace your AsciiOutputs. Then, you won't need to worry about how TI obtains and releases the file handles, or worry about the file-merging logic.
Robin Mackenzie
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Re: ASCIIOUTPUT file locking/unlocking

Post by fleaster »

thanks for the tip :)

fyi in the end I used this in conjunction with the echo command to write directly to the file (saves creating a separate file) e.g. something like :

Code: Select all

echo   this-is-my-footer  >>  "datafile.txt"
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: ASCIIOUTPUT file locking/unlocking

Post by BariAbdul »

fleaster wrote:thanks for the tip :)

fyi in the end I used this in conjunction with the echo command to write directly to the file (saves creating a separate file) e.g. something like :

Code: Select all

echo   this-is-my-footer  >>  "datafile.txt"
fleaster,Could you please post your complete code.Thanks
"You Never Fail Until You Stop Trying......"
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Re: ASCIIOUTPUT file locking/unlocking

Post by fleaster »

Hi BariAbdul,

Please see below:

Code: Select all

    # execute command to append footer string to end of each output file    
    # e.g.    cmd /c echo 97020130920000.....  >> "\\TM1\DataUser\Working\ProofOutput-70.txt"

    CommandAppend = 'cmd /c echo ' | FooterString | ' >> ' | '"' | AppendPath | '"' ;

    ExecuteCommand(CommandAppend,1);
...where FooterString is the line of text being appended for the footer, and AppendPath is the destination txt file being updated.
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: ASCIIOUTPUT file locking/unlocking

Post by BariAbdul »

Thanks a lot.
"You Never Fail Until You Stop Trying......"
Post Reply