Dim objApp As Object
Dim objRep as Object

Dim imrFile as String
Dim catalogFile as String
Dim exportFile As String
Dim exportFormat As String


Sub Main ()
   rem On Error Resume Next

   rem imrFile = "C:\GAPS\Portal\System\IQD\Belege\Belege.imr"
   rem catalogFile = "C:\GAPS\Portal\System\Catalogs\Finance.cat"
   rem exportFile = "C:\GAPS\Portal\System\Export\Belege.csv"
   rem exportFormat = "x_ascii.flt"
   
   imrFile = GetField(Command, 1, ",")
   catalogFile = GetField(Command, 2, ",")
   exportFile = GetField(Command, 3, ",")
   exportFormat = GetField(Command, 4, ",")
   
   
   Set objApp = CreateObject("CognosImpromptu.Application")
   objApp.OpenCatalog catalogFile, "Ersteller"
   Set objRep = objApp.OpenReport(imrFile)
   objRep.RetrieveAll
   If exportFormat = "ims" Then
      objRep.ExportHotFile(exportFile)
   Else
      objRep.Export exportFile, exportFormat
   End If
   objRep.CloseReport
   objApp.Quit
   Set objRep = Nothing
   Set objApp = Nothing

End Sub
