Data Management Capabilities > Managing Part Structures > Windchill Options and Variants Capabilities > Creating and Managing Variants > Variant Specification Information Page > Loading Variant Specifications > Loading Variant Specifications Using an API > Loading Variant Specifications Using API #1 > Sample Code for API #1
  
Sample Code for API #1
Below is a sample code for using API #1 for loading variant specifications.
public static void main(String[] args) throws Exception {

// Create part config specs

List<VariantLoadPartConfigSpecBean> partConfigSpecBeans = new
ArrayList<VariantLoadPartConfigSpecBean> (1);
VariantLoadPartConfigSpecBean partConfigSpecBean1 = new
VariantLoadPartConfigSpecBean("MyPartConfigSpec1", null, null, null, null);
partConfigSpecBeans.add(partConfigSpecBean1);

// Create a Latest ATO rule Config spec

List<VariantLoadATORuleConfigSpecBean> atoConfigSpecBeans = new
ArrayList<VariantLoadATORuleConfigSpecBean> (1);

VariantLoadATORuleConfigSpecBean atoConfigSpecBean1 = new

VariantLoadATORuleConfigSpecBean("MyATOConfigSpec1", null, null);
atoConfigSpecBeans.add(atoConfigSpecBean1);

VariantLoadNavCriteriaBean bean1 = new VariantLoadNavCriteriaBean();

bean1.setVariantSpecName("TestThruApi3");
bean1.setVariantSpecDescription("Test thru API 1");
bean1.setVariantSpecFolder("/Default");
bean1.setVariantSpecCreateVariants(false);
bean1.setPartNumber("BICYCLE1");
bean1.setRuleCheckingDisabled(true);

List<String> choices = new ArrayList<String>();

choices.add("D0022");
bean1.addChoiceNames("Locale", choices);

choices = new ArrayList<String>();
choices.add("D0009");

bean1.addChoiceNames("Steering Type", choices);

// Use the part and option filter config specs from above
bean1.addPartConfigSpec("MyPartConfigSpec1");
bean1.addAtoRuleConfigSpecs("MyATOConfigSpec1");
//////////////////////////////////////////////////////

VariantLoadNavCriteriaBean bean2 = new VariantLoadNavCriteriaBean();

bean2.setVariantSpecName("TestThruApi1");
bean2.setVariantSpecDescription("Test thru API 1");
bean2.setVariantSpecFolder("/Default");
bean2.setVariantSpecCreateVariants(false);
bean2.setPartNumber("BICYCLE1");
bean2.setRuleCheckingDisabled(true);

choices = new ArrayList<String>();
choices.add("D0022");

bean2.addChoiceNames("Locale", choices);

List<VariantLoadNavCriteriaBean> beans = new ArrayList<VariantLoadNavCriteriaBean>(1);

beans.add(bean1);
beans.add(bean2);
VariantSpecLoaderHelper.service.loadVariantSpecs(beans, partConfigSpecBeans, atoConfigSpecBeans);
}