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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Code having Error..

vuchekar
9-Granite

Code having Error..

Hi All,

Below code giving some error, how i can fix this and get WTPartsusesby

Thanks,

Vivek

try{

WTPart part = null;

wt.fc.QueryResult qr=wt.part.WTPartHelper.service.getUsesWTPartMasters(part);

if(qr.hasMoreElements()){

System.out.println(part.getNumber()+"----Has----Child---"+qr.size());

wt.part.WTPartMaster partMaster = (WTPartMaster)part.getMaster();

wt.fc.QueryResult qr_parents = wt.part.WTPartHelper.service.getUsedByWTParts(partMaster);

while(qr_parents.hasMoreElements()) {

wt.part.WTPart parentPart = (wt.part.WTPart) qr_parents.nextElement();

System.out.println(partMaster.getNumber()+"----Has----Parents---"+parentPart.getName());

wt.part.WTPartMaster parentMaster = (WTPartMaster)parentPart.getMaster();

wt.fc.QueryResult qr_grandpa = wt.part.WTPartHelper.service.getUsedByWTParts(parentMaster);

}

}

}

1 REPLY 1
KD
4-Participant
4-Participant
(To:vuchekar)

Hi Vivek,
What kind of error you are getting ?

This is the first three line of your code.

"

try{

WTPart part = null;

wt.fc.QueryResult qr=wt.part.WTPartHelper.service.getUsesWTPartMasters(part);

"

in line no 2 you set part variable to null and without Instantiate it properly ,in line no 3 you are calling getUsesWTPartMaster() and passing part as an argumnet.

So i guess it will throw NullPointerException.

Others part of that code looks good.

thanks and regards,

Kaushik

Top Tags