This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Part BOM Load

aravinth_r - Wednesday, May 16, 2012 8:13 AM:

Hello,

Customer does not want the system to allow adding Superseded parts into the BOM. So, we added a method in the onBeforeAdd server event of the Part BOM Itemtype as follows:

Innovator inn = this.getInnovator();
string strChildPartID = this.getProperty("related_id");
Item ChildPartObj = inn.getItemById("Part",strChildPartID);
string strChildPartName = ChildPartObj.getProperty("item_number");
string strChildPartState = ChildPartObj.getProperty("state");

if(strChildPartState == "Superseded") {
    string strResult = "Child Part Number " + strChildPartName + " is in Superseded state. Children in Superseded state cannot be added to BOM";
    return inn.newError(strResult);
}
return this;

This code works fine and we are able to achieve the functionality. But problem comes while loading the BOM using Batch Loader. We give the input for the Batch loader as follows:

Parent|Child
WT-017-101156|WT-002-100153

And the mapping file I use is as follows:

<Item type="Part BOM" action="add">
  <source_id>
    <Item type="Part" action="get" select="id">
      <keyed_name>@1</keyed_name>
    </Item>
  </source_id>
  <related_id>
    <Item type="Part" action="get" select="id">
      <keyed_name>@2</keyed_name>
    </Item>
  </related_id>
</Item>

When I use this and run the Batch loader, I get the following error:

[6:39:42 PM - Worker process for lines up to 25 (Thread #1)]: #1 - Failed to process row WT-017-101156|WT-002-100153
[6:39:42 PM - Worker process for lines up to 25 (Thread #1)]:     Code: SOAP-ENV:Server
[6:39:42 PM - Worker process for lines up to 25 (Thread #1)]:     Message: ID must be specified
[6:39:42 PM - Worker process for lines up to 25 (Thread #1)]:     Details: ID must be specified

When i remove the code in the onBeforeAdd server event of the Part BOM Itemtype, the BOM loads successfully. Can any one help me to know what is the problem in the code?

Regards, Aravinth

 



Brian - Monday, May 21, 2012 9:38 AM:

Hi Aravinth,

Since the server method returns an error whenever it detects a superceded part, the batch loader is going to receive an error back and stop importing.

You may have to write your own batch load process that reads the file and checks for errors before it tries to add each relationship.

That way you can ignore parts that don't qualify and only send the ones that are OK to the server in the first place.

Cheers,

Brian.



aravinth_r - Monday, May 21, 2012 10:54 AM:

Hi Brian,

Thanks for the reply.

The child parts that I am trying to add are in Preliminary state. And so, the method will not return error for these parts. If I add this part manually to the parent from the user interface, it works. so, I see that there is a problem with the server event code that I have written. Can you please advise me on that code after seeing it? Thanks in advance!

Regards, Aravinth