|  |  | 
 |  |  |      | 
 |  |  |     // New version | 
 |  |  |     globalotdtable := GlobalOTDTable; | 
 |  |  |     globalotdsop := GlobalOTDSOP; | 
 |  |  |     testbusinesstype := "集团"; | 
 |  |  |     if( data.IsCreateNewVersion() ){ | 
 |  |  |       VersionControl::CreateNewSceneVersion( globalotdtable, testbusinesstype ); | 
 |  |  |       VersionControl::CreateNewSceneVersion( globalotdsop, testbusinesstype ); | 
 |  |  |       }else{ | 
 |  |  |         VersionControl::CopyVersion( globalotdtable, testbusinesstype ); | 
 |  |  |         VersionControl::CopyVersion( globalotdsop, testbusinesstype ); | 
 |  |  |         } | 
 |  |  |     versionname := VersionControl::GetVersionInfo( globalotdtable, testbusinesstype ).Element( 3 ); | 
 |  |  |     versionname := VersionControl::GetVersionInfo( globalotdsop, testbusinesstype ).Element( 3 ); | 
 |  |  |      | 
 |  |  |     // Get Version Name | 
 |  |  |     if( data.Name() = "" ){ | 
 |  |  | 
 |  |  |       } | 
 |  |  |      | 
 |  |  |     // Get Business Type from Scenario Name | 
 |  |  |     businesstype := select( globalotdtable,  | 
 |  |  |                             BusinessType,  | 
 |  |  |                             b,  | 
 |  |  |                             b.ScenarioName()=data.ScenarioName() ).BusinessTypeName(); | 
 |  |  |     businesstype := guard( select( globalotdtable,  | 
 |  |  |                                    BusinessType,  | 
 |  |  |                                    b,  | 
 |  |  |                                    b.ScenarioName()=data.ScenarioName() ).BusinessTypeName(),  | 
 |  |  |                            "" ); | 
 |  |  |     data.BusinessType( businesstype ); | 
 |  |  |      | 
 |  |  |     // Copy scenario | 
 |  |  | 
 |  |  |         MacroPlan::DoSync( macroPlanNew,  | 
 |  |  |                            data.BusinessType(), data.IsKeyProduct(), data.CreatePurchaseSupplyMaterial() ,GlobalOTDTable); | 
 |  |  |     } | 
 |  |  |     macroPlanNew.BusinessType( businesstype ); | 
 |  |  |     macroPlanNew.IsKeyProduct( data.IsKeyProduct() ); | 
 |  |  |     macroPlanNew.CreatePurchaseSupplyMaterial( data.CreatePurchaseSupplyMaterial() ); | 
 |  |  |      | 
 |  |  |     MacroPlan.UpdateStartOfPlanning( dsPlanningStart.Date().DateTime() ); | 
 |  |  |      | 
 |  |  |     this.Close(); | 
 |  |  |   *] |