Scrolling thru all folders and all projects to export to Excel

Greetings,

Telelogic DOORS 9.1.

I have been RTFMing all day and still can't find out how to do this. Is it possible, using DXL, to scroll through all folders/projects/modules and export each module to Excel? If so, can someone please point me in the right direction? If it's not possible, can someone please let me know?

Many thanks!
Mike
mike_1973 - Tue Aug 30 16:51:58 EDT 2011

Re: Scrolling thru all folders and all projects to export to Excel
OurGuest - Wed Aug 31 07:11:24 EDT 2011

It is possible to modify the existing rtf export or spreadsheet to iterate through the modules. Of course you will have to build in the logic to select the desired view.

Do you want excel as the title implies or rtf as you text implies?

Re: Scrolling thru all folders and all projects to export to Excel
mike_1973 - Wed Aug 31 08:32:54 EDT 2011

OurGuest - Wed Aug 31 07:11:24 EDT 2011
It is possible to modify the existing rtf export or spreadsheet to iterate through the modules. Of course you will have to build in the logic to select the desired view.

Do you want excel as the title implies or rtf as you text implies?

My mandate is to export all modules to Excel.

So it is possible to iterate through all projects/modules? Any examples anywhere? If not then I'll figure it out on my own.

Many thanks for replying.

Cheers,
Mike

Re: Scrolling thru all folders and all projects to export to Excel
OurGuest - Wed Aug 31 10:08:17 EDT 2011

mike_1973 - Wed Aug 31 08:32:54 EDT 2011
My mandate is to export all modules to Excel.

So it is possible to iterate through all projects/modules? Any examples anywhere? If not then I'll figure it out on my own.

Many thanks for replying.

Cheers,
Mike

Here is a starting point for you.

//IterateDatabase
/*Demo*/
Project cProject
Module mC
Item itm
bool bForeGround=true, bStandardView=true
void PROCESSMODULE(Module mC)
{ print fullName mC  "\n"
  //PLACE EXPORTER CALL HERE 
  //halt
}
 
void ITERATEDATABASE()
{ for cProject in database do  
  { for itm in cProject do 
    {  if(type itm !="Formal")continue
       mC=read(fullName itm,bForeGround,bStandardView)
       if(null mC)continue
       PROCESSMODULE(mC)
       close(mC,false)
    }
  }
}
ITERATEDATABASE()

Re: Scrolling thru all folders and all projects to export to Excel
llandale - Wed Aug 31 16:10:13 EDT 2011

This post has a more glorified "loop" structure:

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14236907#14236907

Mostly it processes module's in their natural Hierarchy and Alpha order (as seen in the Explorer), whereas the "for item in Project" loop processes them in "Item" order, which I think is the order in which each module was created; but anyway looks random.

The above is also sensitive to the current Project/Folder giving you more flexibility on which modules to select. Open a folder and run the script and you get the current folder context.

You would want to change...
this... // Deal with the module here.
to..... ExportModule(NameItem)

and write that function.

Other folks may need to help with the actual export of the module, but I presume it will include opening a particular view, exporting, and saving to a particular file, which has the module name in it, and you will need to make sure that modules with the same name get different file names.

  • Louie

If you want 'Item' order you can change..
this ... { put(skpItems, fullName(itm), itm)
to ......{ put(skpItems, itm, itm)

Re: Scrolling thru all folders and all projects to export to Excel
mike_1973 - Wed Aug 31 16:37:20 EDT 2011

OurGuest - Wed Aug 31 10:08:17 EDT 2011

Here is a starting point for you.

//IterateDatabase
/*Demo*/
Project cProject
Module mC
Item itm
bool bForeGround=true, bStandardView=true
void PROCESSMODULE(Module mC)
{ print fullName mC  "\n"
  //PLACE EXPORTER CALL HERE 
  //halt
}
 
void ITERATEDATABASE()
{ for cProject in database do  
  { for itm in cProject do 
    {  if(type itm !="Formal")continue
       mC=read(fullName itm,bForeGround,bStandardView)
       if(null mC)continue
       PROCESSMODULE(mC)
       close(mC,false)
    }
  }
}
ITERATEDATABASE()

Thanks a lot!

It works...BUT...I get the following error the first time I run it:

-R-E- DXL: <Line:1000> null Module parameter was passed into argument position 1
Backtrace:
<Line:1031>
<Line:1065>
-I- DXL: execution halted

When I run it again, I don't get the error. However, if I close DOORS and re-open it, I'll again get the error the first time.

The error occurs when it reads the module : mC=read(fullName itm,bForeGround,bStandardView)

Any ideas?

Note that I put noError() before reading the module and I still get the error.

Thanks again.

Re: Scrolling thru all folders and all projects to export to Excel
OurGuest - Wed Aug 31 16:57:45 EDT 2011

mike_1973 - Wed Aug 31 16:37:20 EDT 2011
Thanks a lot!

It works...BUT...I get the following error the first time I run it:

-R-E- DXL: <Line:1000> null Module parameter was passed into argument position 1
Backtrace:
<Line:1031>
<Line:1065>
-I- DXL: execution halted

When I run it again, I don't get the error. However, if I close DOORS and re-open it, I'll again get the error the first time.

The error occurs when it reads the module : mC=read(fullName itm,bForeGround,bStandardView)

Any ideas?

Note that I put noError() before reading the module and I still get the error.

Thanks again.

The error probably is within a different layout dxl that is running in another name space.

If you notice I checked for null module.

Also you will notice there are not 1000 lines of code in the script.

Change the parameters to read the modules in standard view or open in background.

You will need to locate the other name space which is probably a layout dxl in someones default view.

Re: Scrolling thru all folders and all projects to export to Excel
Mathias Mamsch - Wed Aug 31 17:22:38 EDT 2011

OurGuest - Wed Aug 31 10:08:17 EDT 2011

Here is a starting point for you.

//IterateDatabase
/*Demo*/
Project cProject
Module mC
Item itm
bool bForeGround=true, bStandardView=true
void PROCESSMODULE(Module mC)
{ print fullName mC  "\n"
  //PLACE EXPORTER CALL HERE 
  //halt
}
 
void ITERATEDATABASE()
{ for cProject in database do  
  { for itm in cProject do 
    {  if(type itm !="Formal")continue
       mC=read(fullName itm,bForeGround,bStandardView)
       if(null mC)continue
       PROCESSMODULE(mC)
       close(mC,false)
    }
  }
}
ITERATEDATABASE()

Also note that the "for project in database for item in project" will loop over the same module multiple times if you use sub projects (i.e. projects below another project). Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Scrolling thru all folders and all projects to export to Excel
Mathias Mamsch - Wed Aug 31 17:31:46 EDT 2011

mike_1973 - Wed Aug 31 08:32:54 EDT 2011
My mandate is to export all modules to Excel.

So it is possible to iterate through all projects/modules? Any examples anywhere? If not then I'll figure it out on my own.

Many thanks for replying.

Cheers,
Mike

HSuch a script is highly non-trivial. Not because of the export, but because you need to be extremely careful when coding such a script that will have to handle a large amount of data. I find it very likely that any script you will be able to find will die of memory shortage if you just put a loop around it and apply it to 100+ large modules.

The most scalable and fastest way to dump the complete database would be to dump one module at a time from one or more batch jobs, then collect the results to one big file. For an example on how to create a batch job doing an export you can look here:

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14587301&#14587301

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Scrolling thru all folders and all projects to export to Excel
llandale - Wed Aug 31 17:46:10 EDT 2011

mike_1973 - Wed Aug 31 16:37:20 EDT 2011
Thanks a lot!

It works...BUT...I get the following error the first time I run it:

-R-E- DXL: <Line:1000> null Module parameter was passed into argument position 1
Backtrace:
<Line:1031>
<Line:1065>
-I- DXL: execution halted

When I run it again, I don't get the error. However, if I close DOORS and re-open it, I'll again get the error the first time.

The error occurs when it reads the module : mC=read(fullName itm,bForeGround,bStandardView)

Any ideas?

Note that I put noError() before reading the module and I still get the error.

Thanks again.

OurGuest is probably right about that error being in some other code auto-executed, and probably a layout (or attr-DXL or Trigger) of some module that gets opened when you open your first module. Those are hard to track down but we can help.

Your command "close(mC)" looks suspicious as perhaps the Exporter has closed the module.

Since your ProcessModule may be 950 lines long and we can see if its really in this code. You can insert:

... print "Before 'read': " (dxlHere()) "\n"

right above your "read" and also your "close" to see their exact line numbers.

You could also print the fullName(itm) so you know which module, then open that module manually to see if you get errors. Don't forget to check out the Explorer >Tools menu >Manage Open Modules and close them all, you can expect several invisible "background" modules open. Closing the modules will likely simulate your exiting-restart DOORS symptoms.

Generally surround strange code with
noError()
read..
string ErrMess = lastError()
if (!null ErrMess)//
then report and bypass
else proceed.

That code should be short. In this case if your exporter has a "lastError" in there, then it turns it all off and the "close" statement will lack "noError" protection.

You want ErrMess to deal with such errors. Failing that then the offending command fails but the code continues, and you'll get an error somewhere else down the line because this command failed. e.g. if "read" fails then your Exporter will generate an error due to the lack of a Module.

  • Louie

Re: Scrolling thru all folders and all projects to export to Excel
llandale - Wed Aug 31 17:51:41 EDT 2011

Mathias Mamsch - Wed Aug 31 17:22:38 EDT 2011
Also note that the "for project in database for item in project" will loop over the same module multiple times if you use sub projects (i.e. projects below another project). Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

if (!null getParentProject(prj)) continue

may fix that; ignoring projects that are subordinate to other projects.

Re: Scrolling thru all folders and all projects to export to Excel
mike_1973 - Fri Sep 02 09:37:12 EDT 2011

Mathias Mamsch - Wed Aug 31 17:22:38 EDT 2011
Also note that the "for project in database for item in project" will loop over the same module multiple times if you use sub projects (i.e. projects below another project). Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Thanks for replying.

I realized that the problem was not in the code provided above. I thought that the errors I was getting was due to some other module in DOORS that I don't know about that you guys might have been aware of. Obviously I'm very green in the DOORS world :/.

Thanks again,
Mike