cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

How to retrieve Quantity attribute for WTPart Structure?

rkumar-10
5-Regular Member

How to retrieve Quantity attribute for WTPart Structure?

I am trying to retrieve Quantity attribute for BOM Structure.

WTPartUsageLink puLink = WTPartUsageLink.newWTPartUsageLink(part, partMaster);

puLink.getQuantity().getAmount(); //gives quantity 1.0 always.

2 REPLIES 2

The code you are using isn't actually looking at persisted data. You're essentially creating a "new"  local WTPartUsageLink and I'm guessing 1.0 is the default value. If you would like to actually retreive the quantity from an existing link in the database, you need to get a reference to that link.

One of the APIs you could use would be:

WTPartHelper.service.getUsesWTParts(parents, configSpec);

JavaDoc:
getUsesWTParts

Persistable[][][] getUsesWTParts(WTList parts, ConfigSpec configSpec) throws WTException

Navigates from many used-by parts to their uses
part masters and applies a ConfigSpec to select the iterations
of the uses parts. Returns a three dimensional array of Persistable
where the first dimension is corresponds the the used-by parts passed
in. The second dimension corresponds to the part usage links from
the used-by part. The third dimension is two elements long where [0]
is the WTPartUsageLink and [2] is the uses WTPart or WTPartMaster
if the config spec did not select an iteration of the uses part. This
API does not support filtering. 

Supported API: true


Parameters:
parts - Ordered list of used-by parts.
configSpec - The config spec to use to select the uses part iterations.
Returns:
Persistable[][][]
Throws:
WTException

Once you have the link you can use your code above to get the quanity:

puLink.getQuantity().getAmount();

You could also check out this article to show you how to get the link:

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS49806

rkumar-10
5-Regular Member
(To:jmomber)

Hi Jamie

Thanks for your help. It worked for me.

Regards

Rakesh

Top Tags