IDEA Script extract data off IDEA Server or other servers

18 posts / 0 new
Last post
aveenm293
Offline
Joined: 10/23/2012 - 16:02

Hi Brian
I have tried the code above using IDEA version 8.5. I keep getting the attached errors. I have a few changes I have 2000 text files to import but have used the report reader to import and have created a jpm template file.
Please can you assist?
Thank you
Regards
Aveen
 

Images: 
Brian Element's picture
Brian Element
Online
Joined: 07/11/2012 - 19:57

Sorry Aveen, html sometimes likes to change & to & to protect the code.  I think I found the errors and corrected them in the script.

aveenm293
Offline
Joined: 10/23/2012 - 16:02

Hi Brian
Thank you very much. Will it work with a JPM as opposed to an RDF?
Regards
Aveen

Brian Element's picture
Brian Element
Online
Joined: 07/11/2012 - 19:57

Aveen you will have to change the following line from:

Client.ImportDelimFile filename, dbName, FALSE, "", "D:\Data\test\Detailed Time Code-1.RDF", TRUE

to

Client.ImportPrintReport "D:\Data\test\Detailed Time Code-1.jpm", filename, dbname, FALSE

aveenm293
Offline
Joined: 10/23/2012 - 16:02

Hi Brian
I updated as follows:
Option ExplicitOption Base 1 'arrays start at 1Const FOLDER = "C:\Users\amahado\Desktop\Microsoft Data\Test Run"Const EXTENSION = "*.del"Const JPM =  "C:\Users\amahado\Desktop\Microsoft Data\Test Run\New Template.jpm"Dim workingFolder As StringDim sFiles() As String 'to hold the files
Sub Main workingFolder =Client.WorkingDirectory() Call importFiles() client.refreshFileExplorerEnd Sub
Function importFiles() Dim Files As String Dim filename As String Dim dbName As String Files = Dir(FOLDER & EXTENSION) Dim bFirstPassInd As Boolean  bFirstPassInd = true ReDim sFiles(1) ' While a call to Dir() continues to return file names. Do  ' Get the next file name and place it in FileList.  If Len(Files) > 1 Then   filename = Mid(Files, 1, InStr(1, Files, ".") - 1)      dbName = filename & ".IMD"   If bFirstPassInd Then    bFirstPassInd = False   Else    ReDim preserve sFiles(UBound(sFiles) + 1)   End If   sFiles(UBound(sFiles)) = FOLDER & dbName   filename = FOLDER & Files   Client.ImportPrintReport "C:\Users\amahado\Desktop\Microsoft Data\Test Run\New Template.jpm", filename, dbname, FALSE   'Client.ImportDelimFile filename, dbName, FALSE, "", "D:\Data\test\Detailed Time Code-1.RDF", TRUE   Client.OpenDatabase (dbName)  End If  Files = Dir Loop While Files <> ""
End Function
The script runs but no data appears in IDEA. Have I missed something?
Thank you
Regards
Aveen

Brian Element's picture
Brian Element
Online
Joined: 07/11/2012 - 19:57

Aveen, I will have a look at it tonight and get back to you.

Brian Element's picture
Brian Element
Online
Joined: 07/11/2012 - 19:57

Aveen, this works, you were missing a \ in the FOLDER variable. Also makes sure the EXTENSION variable is the extension of the files you want to import, they should all be the same. Also I changed the import instruction to use the JPM variable for the template, make sure the name is correct and it is store in that location.

Option Explicit
Option Base 1 'arrays start at 1
Const FOLDER = "C:\Users\amahado\Desktop\Microsoft Data\Test Run\"
Const EXTENSION = "*.del"
Const JPM =  "C:\Users\amahado\Desktop\Microsoft Data\Test Run\New Template.jpm"
Dim workingFolder As String
Dim sFiles() As String 'to hold the files
Sub Main 
	workingFolder =Client.WorkingDirectory() 
	Call importFiles()
	client.refreshFileExplorer
End Sub
Function importFiles() 
	Dim Files As String 
	Dim filename As String 
	Dim dbName As String 
	Files = Dir(FOLDER & EXTENSION) 
	Dim bFirstPassInd As Boolean  
	bFirstPassInd = true 
	ReDim sFiles(1)
	 ' While a call to Dir() continues to return file names. 
	 Do  
	 	' Get the next file name and place it in FileList.  
	 	If Len(Files) >1 Then  
	 		
	 		filename = Mid(Files, 1, InStr(1, Files, ".") - 1)      
	 		dbName = filename & ".IMD"   
	 		If bFirstPassInd Then    
	 			bFirstPassInd = False   
	 		Else   
	 		 	ReDim preserve sFiles(UBound(sFiles) + 1)   
	 		End If   
	 		sFiles(UBound(sFiles)) = FOLDER & dbName   
	 		 filename = FOLDER & Files   
	 		Client.ImportPrintReport JPM, filename, dbname, FALSE   ' 
	 		Client.OpenDatabase (dbName)  
	 	End If  
	 	Files = Dir 
	 Loop While Files <> ""
End Function

 

Pages