| Quintiq file version 2.0 | 
| #parent: #root | 
| Method SetBookmarkElement ( | 
|   const Units units, | 
|   const StockingPoint_MPs stocking_points, | 
|   const Product_MPs products, | 
|   const SalesSegment_MPs sales_segments, | 
|   const structured_Object periodObjects | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // Set the elements to be bookmarked in a Bookmark | 
|     oldBookmarks := selectset( this, AllBookmarkElement, e, true ); | 
|     newBookmarks := construct( BookmarkElementBases ); | 
|      | 
|     // Find/Create bookmark elements according to the units passed in and assign it to newBookmarks | 
|     traverse( units, Elements, e ) | 
|     { | 
|       newBookmarks.Add( BookmarkUnitElement::FindCreate( this, e ) ); | 
|     } | 
|      | 
|     // Find/Create bookmark elements according to the stocking points passed in and assign it to newBookmarks | 
|     traverse( stocking_points, Elements, e ) | 
|     { | 
|       newBookmarks.Add( BookmarkStockingPointElement::FindCreate( this, e ) ); | 
|     } | 
|      | 
|     // Find/Create bookmark elements according to the products passed in and assign it to newBookmarks | 
|     traverse( products, Elements, e ) | 
|     { | 
|       newBookmarks.Add( BookmarkProductElement::FindCreate( this, e ) ); | 
|     } | 
|      | 
|     // Find/Create bookmark elements according to the sales segment passed in and assign it to newBookmarks | 
|     traverse( sales_segments, Elements, e ) | 
|     { | 
|       newBookmarks.Add( BookmarkSalesSegmentElement::FindCreate( this, e ) ); | 
|     } | 
|      | 
|     // Find/Create bookmark elements according to the periodObjects consist of PeriodSpecification passed in and assign it to newBookmarks | 
|     traverse( periodObjects, Elements.astype( PeriodSpecification_MP ), e ) | 
|     { | 
|       newBookmarks.Add( BookmarkPeriodSpecificationElement::FindCreate( this, e ) ); | 
|     } | 
|      | 
|     // Find/Create bookmark elements according to the periodObjects consist of PeriodSpecificationPeriod passed in and assign it to newBookmarks | 
|     traverse( periodObjects, Elements.astype( PeriodSpecificationPeriod ), e ) | 
|     { | 
|       newBookmarks.Add( BookmarkPeriodSpecificationPeriodElement::FindCreate( this, e ) ); | 
|     } | 
|      | 
|     // Get old bookmark elements that is not in the updated set of bookmark elements | 
|     oldBookmarks := oldBookmarks.Difference( newBookmarks ); | 
|      | 
|     // Delete all old bookmark elements | 
|     BookmarkElementBase::Delete( oldBookmarks ); | 
|   *] | 
| } |