SOA Service Client : Pack / Unpack BOM

本文详细介绍了如何使用StructureService的packOrUnpack方法来打包和解包BOM线,包括获取BOM线状态、判断是否已打包及进行相应操作的完整流程。通过示例代码展示了如何遍历子BOM线并根据其状态执行打包或解包操作。

How to Pack/Unpack BoM

CreateBOMWindowsResponse createBOMWindowsResponse = createBOMWindows2(modObjParent);

 BOMWindow[] bomWindows = getBOMWindows(createBOMWindowsResponse);
 BOMLine parentBOMLine = getParentBOMLine(createBOMWindowsResponse);
 List<BOMLine> arrChildBOMLines = getChildren(parentBOMLine, plugin);

 System.out.println( "Children BOMLines : " + arrChildBOMLines);
//Expand child lines one by one.
if(arrChildBOMLines != null && arrChildBOMLines.size() > 0)
{
    for (int cnt = 0; cnt < arrChildBOMLines.size(); cnt++)
    {
        if(arrChildBOMLines.get(cnt) instanceof BOMLine)
         {  
          //Get child bomlines
          BOMLine bline = (BOMLine)arrChildBOMLines.get(cnt);
          boolean bIsBomLinePacked = false;
          try           {
               bIsBomLinePacked = bline.get_bl_is_packed();
          } 
         catch (NotLoadedException e)
          {
             System.out.println("get_bl_is_packed attribute not loaded fetching from Tc="+ e);
             bIsBomLinePacked = (Boolean) plugin.getObjectAttribute(bline,"bl_is_packed", null);
          }
         System.out.println("Value for get_bl_is_packed :  " + bIsBomLinePacked);
         if(bIsBomLinePacked)
          {
            System.out.println("BOM Line is packed, unpacking the complete BOMLine");

           //com.teamcenter.services.strong.structuremanagement.StructureService
           StructureService strucService = StructureService.getService(connection);
           ServiceData response = strucService.packOrUnpack(new BOMLine[] { bline } , 3);
           if(response.sizeOfPartialErrors() == 0)
           System.out.println("unpacking successfull ");
         }
       }
    } 
}

Explanation :
StructureService strucService = StructureService.getService(connection);
ServiceData response = strucService.packOrUnpack(new BOMLine[] { bline } , 3);
packOrUnpack method parameters are ->1st Parameter) lines - The lines that need to be packed. If pack all option is selected, the children of the lines will be packed.2nd Parameter)flag - 0:pack the lines 1:unpack the lines 2:pack all lines 3:unpack all lines
 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值