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

Windchill - Custom Part Numbers

Highlighted
Amethyst

Windchill - Custom Part Numbers

Windchill gives you the flexibility to use custom numbers when creating new wtparts (or other Windchill objects). There are several options available for configuring the way Windchill reserves numbers in the Windchill database without customization (see https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS38320 and http://support.ptc.com/cs/help/windchill_hc/wc102_hc/ObjRuleObjectNumbering.html), or with some light customization it can also be configured to use numbers from a database outside of Windchill, like the one your ERP system uses. It might sound difficult because you have to write some code to do it, but the code is usually simple to write. Here's how we did it with SAP:

  1. Write a java method using the SAP API that connects to the SAP system and reserves numbers.
  2. Call this new java method from the Windchill Object Initialization Rule (OIR) for the object.

There's really only these two steps. Once step 1 is completed, step 2 only involves changing one line in the OOTB OIR.

See the attached java code for an example of the method required for step 1. It uses the SAP Java Connector (JCo) version 2.1.8 which is a middleware component that enables the development of SAP-compatible applications in Java. Version 2.1.8 is not the latest and the programming methods have changed considerably from version 2 to 3, so some reworking would be required. First, the SAP JCo class files must be imported to this custom class, e.g.  com.sap.mw.jco.*. A jar file can be copied to the Windchill server under the codebase. Then, the method reads property values for connecting to SAP and connects. After connecting and creating a repository for information, the standard SAP BAPI_MATERIAL_GETINTNUMBER BAPI is called to reserve the next available material number. A few required parameter values are passed with the BAPI_MATERIAL_GETINTNUMBER function. Note that this function does not create a material in SAP. It only reserves the number so no one else can use it. We later use additional SAP functions (like BAPI_MATERIAL_SAVEDATA) to create and maintain the material.

Now, the wtpart OIR can be modified to use this custom method. Change the OOTB Windchill numbering algorithm <AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator"> to <VarDef id="gennum" algorithm="SAPESI.MyNumberGenerator"> where SAPESI is the package name and MyNumberGenerator is the class. We also use the VarDef xml tag instead of the AttrValue tag. Once the modified OIR is uploaded and new parts are created in Windchill, the number is populated with values from SAP.

One potential headache with doing this is that as your external system is upgraded, the API may change forcing you to update your custom method. That's something that must be considered with any upgrade, so it probably isn't new to you. Also, we use an SAP service account to create the parts. The password is stored in clear text in a property file on the server. To prevent misuse, this service user is configured so that it can't be used to login through the SAP client.

Note that this can be used with any object in Windchill using the OIR for that object and the appropriate API for the external system. We use a similar method to use an SAP change notice number for our Windchill change notices.

.

Announcements