Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
olni
Contributor
Contributor

tfiledelete_does_not_delete_file

Hi,

I have a problem with the tfile delete component. I build a job to upload a logfile to salesforce. To do this i have a Prejob which redirects the console output to a file with these lines:

context.WorkingDir = System.getProperty("user.dir");
context.Pid = this.pid;
System.out.println(context.Pid);
System.out.println(context.WorkingDir);
context.LogFile = (context.WorkingDir + "\\" + context.Pid + "_log");

java.io.PrintStream ps = new java.io.PrintStream(new java.io.FileOutputStream(context.LogFile));
System.setOut(ps);

Later i use tLogCatcher to collect the Logs and read the file as shown here:

0683p000009M4M4.png

 

The Logfile is uploaded successfully - after that i want to delete the Logfile within a Postjob:

0683p000009M4ME.png

 

But i get an exception that the file could not be deleted:

0683p000009M4MO.png

I thought that the file is maybe not properly closed, but i don't know how to do this i tried:

new java.io.FileOutputStream(context.LogFile).close();

But that didn't work either.

It would be great if someone could help/explain me what i'm doing wrong here.

 

Regards,

Olli

 

Labels (1)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

to do 

 

in Prejob , add ps as globalMap variable at the end of code 

 

globalMap.put("ps",ps);

 

then before deleting file in tPostJob, close the stream using tJava

 

((java.io.PrintStream)globalMap.get("ps")).close();

View solution in original post

5 Replies
Anonymous
Not applicable

Hello

Just to undersdand
what not simply doing :

tLogCatcher -----------------> SaleForce Insert

olni
Contributor
Contributor
Author

.. i also want to have a summary of what ID's are successfully uploaded. But LogCatcher only logs errors from java exception or tdie/twarn.
That is the reason i store everything in a file before i upload it.

The result looks like this:

 

### Starting Accounts SF2ERP_SQL  ...
SalesforceURL: https://login.salesforce.com/services/Soap/u/44.0
ERP          : 192.168.0.65/Kunden
Lastrun      : Wed May 22 09:19:54 CEST 2019
LastrunSQL   : 2019-05-20T05:00:51.000Z

knr 214578 220256 220039 215620 208529
...
...

It all works fine except the removing of the logfile.. 😞

 

Olli

 

 

 

Anonymous
Not applicable

I suggest you try temporary files

something like tCreateTemporaryFile ...
akumar2301
Specialist II
Specialist II

to do 

 

in Prejob , add ps as globalMap variable at the end of code 

 

globalMap.put("ps",ps);

 

then before deleting file in tPostJob, close the stream using tJava

 

((java.io.PrintStream)globalMap.get("ps")).close();

olni
Contributor
Contributor
Author

Hi Akumar,

thanks again for your help, this works perfectly.

 

Oliver