将业务对象添加为子行创建BOMTeamcenter SOA

问题描述

我正在尝试将一个项目添加到另一个父项目的bomview中,此刻SOA在itemrev父项目中创建BOMView,但不添加任何其他itemrev。

实际上,如果在AddParam Flags属性添加数字1,则会出现此错误

代码:46019严重性:3您不能替代BOM表的顶行。

有人知道错在哪里吗?

谢谢。

我正在使用的实现代码

Teamcenter.Services.Strong.Cad.StructureManagementService smService = Teamcenter.Services.Strong.Cad.StructureManagementService.getService(Teamcenter.ClientX.Session.getConnection());
StructureService sService = StructureService.getService(Teamcenter.ClientX.Session.getConnection());
 
Addinformation info = new Addinformation();
info.BomView = null;
info.Element = null;
info.ItemRev =  ModelObject_ItemRev;
info.Line = null;
info.InitialValues = new Hashtable();
 
AddParam param = new Addparam();
param.Parent = parentItem.GetBOMLine(true); // The parent where the objects are added.
param.ToBeAdded = new Addinformation[] { info }; // The information about the objects to be added.
param.Flags = 1;
 
AddResponse response = sService.Add(new AddParam[] { param });

解决方法

解决问题的方法是错误的。必须创建炸弹列表以解决该问题。 我在此博客中找到了实现:

SOA服务客户端:创建BOM

https://teamcenter-open-gate.blogspot.com/2016/12/soa-service-client-creating-bom.html

这是我对C#库的实现:

public static void addAllChildrenInBOM(ItemRevision parentObject,ItemRevision[] childObjects)
{
      ArrayList createBOMWindowsResponse = openBOMWindow(parentObject);      
      BOMWindow[] bomWindows = new BOMWindow[] { (BOMWindow)createBOMWindowsResponse[0] };
      BOMLine parentBOMLine = (BOMLine)createBOMWindowsResponse[1];
      Teamcenter.Services.Strong.Cad.StructureManagementService cadSMService = Teamcenter.Services.Strong.Cad.StructureManagementService.getService(Teamcenter.ClientX.Session.getConnection());
    
      ItemLineInfo[] itmLineInfoArr = new ItemLineInfo[childObjects.Length];

      for (int i = 0; i < childObjects.Length; i++)
      {
           itmLineInfoArr[i] = new ItemLineInfo();
           itmLineInfoArr[i].ItemRev = childObjects[i];
           itmLineInfoArr[i].ClientId = "ClientID";
       }

       AddOrUpdateChildrenToParentLineInfo[] addChToParInfoArr = new AddOrUpdateChildrenToParentLineInfo[1];
       addChToParInfoArr[0] = new AddOrUpdateChildrenToParentLineInfo();
       addChToParInfoArr[0].Items = itmLineInfoArr;
       addChToParInfoArr[0].ParentLine = parentBOMLine;
       Teamcenter.Services.Strong.Bom.StructureManagementService bomSMService = Teamcenter.Services.Strong.Bom.StructureManagementService.getService(Teamcenter.ClientX.Session.getConnection());
       AddOrUpdateChildrenToParentLineResponse addUpdChToParResp = bomSMService.AddOrUpdateChildrenToParentLine(addChToParInfoArr);

       if (addUpdChToParResp.ServiceData.sizeOfPartialErrors() > 0)
       {
           throw new Exception("Creating BOMLines - " + addUpdChToParResp.ServiceData.GetPartialError(0).Messages[0]);
        }
        saveBOMWindow(bomWindows[0]);
        closeBOMWindow(bomWindows[0]);
 }

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...