• No replies
3 Posts

Pinned topic Add New Requirement to Existing Package using the ReqPro Extensibility

‏2012-10-22T19:17:06Z |

The IBM site has an example of adding a new requirement to the root package, then moving it to a newly created package; however, it doesn't show how to move the newly added Requirement to an existing Package. See their example below. In bold, I'm having trouble finding what method to retrieve the existing package object with (the example is only good for adding to a newly created package). Does anyone know what method I should use when retrieving an existing package object (for example: a package named "Audit Package")?

'move a requirement
Sub MoveRequirement(oProject As ReqPro40.Project)

Dim a_oReqs As ReqPro40.Requirements
Dim a_oReq As ReqPro40.Requirement
Dim a_oRootPackage As ReqPro40.RootPackage
Dim a_oPackage As ReqPro40.Package

'get all requirements of type "PR"
Set a_oReqs = oProject.GetRequirements("PR", _

'add a requirement to the collection of PR requirements
Set a_oReq = a_oReqs.Add( _
"requirement_name", _
"This is a root PR requirement.", _
"PR", eReqTypesLookups_Prefix)

'commit this to the database by doing a save on the requirement

'retrieve the root package
Set a_oRootPackage = oProject.GetRootPackage

'create a package at the root level

'Don't need to call save, CreatePackage will persist the package

Set a_oPackage = a_oRootPackage.CreatePackage("Package Name1", "My Package")

a_oPackage.AddElement a_oReq, _
ePackageLookup_Object, _

Set a_oReqs = Nothing
Set a_oReq = Nothing
Set a_oRootPackage = Nothing
Set a_oPackage = Nothing
End Sub