Transcription of Teamcenter Enterprise: Guidelines for Customizing
1 Erich Brauchli PLM-ConsultingErich Brauchli PLM-ConsultinTeamcenter enterprise : Guidelines for Customizing 2. March 2008 ( ) / Erich Brauchli g Teamcenter enterprise : Guidelines for Customizing Volume ITI-MTI-D Written by Erich Brauchli March 2, 2008 Version Reflecting Teamcenter enterprise 2005 Email: Internet: (Total 34 pages) Entire List of Teamcenter Documents: ITI-MTI-A Guidelines for Planing and Operation ITI-MTI-B Guidelines for Setup and Configuration ITI-MTI-C Guidelines for Oracle Setup and DB Configuration ITI-MTI-D Guidelines for Customizing ITI-MTI-E Rules D:\Dokument\Metaphase\Programming Guide\ ITI-MTI-D page 1/34 Teamcenter enterprise : Guidelines for Customizing 2.
2 March 2008 ( ) / Erich Brauchli Erich Brauchli PLM-ConsultingErich Brauchli PLM-Consulting D:\Dokument\Metaphase\Programming Guide\ ITI-MTI-D page 2/34 Content 1 General Remark .. 3 2 Memory Management .. 3 Pointers ..3 Low Level Routines ..4 Character Arrays ..4 Strings got from Objects ..4 objGetAttribute ..4 objClass ..5 Nature of pointer types / releasing SetOfStrings ..5 Char* string ..5 SetOfObjects ..5 ObjectPtr ..5 NVSET ..6 SqlPtr ..6 SetPtr ..6 String handling ..6 Freeing Arguments ..7 Output IML-Methods ..7 Calling next Methods ..7 3 Relations .. 8 Rules for Relations ..8 Handle Relations at MakeItemRevisionDP, CheckOutItemDP, CheckInItemDP, ..8 Customized Structure 4 General Action Flow.
3 9 5 Status Handling .. 10 dstat ..10 mfail ..10 Samples ..11 Sample Method Code ..11 Values of *mfail used in Teamcenter enterprise ..12 Reporting Database Integrity Error ..27 6 User 27 Multipel Sample text definition: ..27 AWK script sample ..28 Dialog 7 Query 29 8 Some sample codes .. 30 9 Miscallaneous .. 31 Custom Subclassing and Methods ..31 10 Upgrade: Obsolete / deprecated messages and objects ..32 Obsolete Items ..32 Deprecated Items ..32 Usage of vfysourc ..32 Erich Brauchli PLM-ConsultingErich Brauchli PLM-ConsultinTeamcenter enterprise : Guidelines for Customizing 2. March 2008 ( ) / Erich Brauchli g 1 General Remark This document reflects a number of Guidelines , which should avoid common errors I have seen upon code reviewing in different projects.
4 It is not the intention to create a complete set of Guidelines ; it is simply driven by misunderstandings of C-programmers, which are novice in Teamcenter enterprise method programming. It is my intention to add new topics as observed in other cases. Be aware, that Teamcenter enterprise has strict object oriented architecture, even if its standard is not completely compatible with OMT standards. Teamcenter enterprise has started before the OMT standard was released. But Teamcenter enterprise respects its standard very strongly. If your customization breaks these rules (even for a small performance gain), you will pay hard in a future release upgrades. If you respect the rules, then any future upgrade will be smooth. 2 Memory Management Memory ManagementObjectAttributesAttribute.
5 Attribute ..Attribute ..Attribute ..Attribute ..PointerPointerPointerStaticDynamicMana ged Pointers Pointers, defined within a message or function are usually in dynamic memory. Pointers got back from some low-level functions bring you a STATIC pointer (see later). Assigning memory to a string pointer through the following actions assign the memory the pointer is pointing to in managed memory: nlsStrAlloc, nlsStrDup Assigning memory to a string pointer through the following actions assign the memory the pointer is pointing to in managed memory too: objGetAttribute D:\Dokument\Metaphase\Programming Guide\ ITI-MTI-D page 3/34 Teamcenter enterprise : Guidelines for Customizing 2. March 2008 ( ) / Erich Brauchli Erich Brauchli PLM-ConsultingErich Brauchli PLM-Consulting D:\Dokument\Metaphase\Programming Guide\ ITI-MTI-D page 4/34 But be aware, this pointer points into the memory structure of the object.
6 Thus the pointer is valid only as long as the object is not moved within the memory and as long as it is not freed. Generally the object is moved , if is used in a method call as an argument, which is declared as update in the message signature of the called message. Most common error is to get a pointer (through any ) to point to some object or string or structure within that object without being aware, that the owner of the memory copy of object may release or change the object. In the first case you are working with a pointer pointing to some random memory content, in the later case you will have a new (changed) value in the content (string, object,..), which you do not know where it comes from (see previous paragraph). Low Level Routines Low level system routines giving back a string (like low_rad_convert or osGetTempName and other similar) point all always to the same location in static memory.
7 This means: after: ptr1 = low_rad_convert(i,10); ptr2 = osGetTempName(Host,User,NULL); both pointers point to the same static location, and the value of convert is overwritten. nlsStrDup , nlsStrCpy or nlsStrCat must copy such string value before any other action may occur with this value. Character Arrays Defined as: char mystring[24]; Be carefully using strings that are defined as arrays of char. They are allocated (both the pointer and the value part) in dynamic memory (on the stack!); thus they are freed upon exit of the routine. If you use such a string to put together a value, you may not deliver the pointer to outside of the routine, because it points to a value that disappears at the end of the routine. Better practice is string mystring = NULL.
8 Mystring = nlsStrAlloc(24); or string mystring = NULL; .. mystring = nlsStrDup(..); Strings got from Objects objGetAttribute The code objGetAttribute(thisObj,ClassAttr,&mystr ing) sets the value of pointer mystring to point into the managed memory belonging to the object. Thus it points to a subset of the memory occupied, what thisObj points to. However if for any reason the memory of thisObj is released, mystring points to some random value. If you are sure, that thisObj stays intact until you do no more need mystring , then it is OK. If not you are advised to replace like this: if (dstat = objGetAttribute(thisObj,ClassAttr,&strin 1)) goto EXIT; mystring = (nlsIsStrNull(string1)) ? NULL : nlsStrDup(string1); Teamcenter enterprise : Guidelines for Customizing 2.
9 March 2008 ( ) / Erich Brauchli Erich Brauchli PLM-ConsultingErich Brauchli PLM-Consulting D:\Dokument\Metaphase\Programming Guide\ ITI-MTI-D page 5/34 This gives you a real copy of the string in newly allocated managed memory. You have to free it later by nlsStrFree(mystring) , if it is not inserted into something else, which will free globally. objClass Replace objGetAttribute(thisObj,ClassAttr,&mystr ing) by mystring = objClass(thisObj) and respect the same rules as with objGetAttribute . Nature of pointer types / releasing routines SetOfStrings A pointer pointing to a chain of pointers to strings, much like an array of pointers, but the series of pointers is in managed memory too. Your pointer points to the first of them.
10 May be freed by: low_set_destroy . This frees the memory of each individual string, if the individual strings have been added by low_set_add_str to the set, and then it releases the chain of pointers. Char* string A pointer pointing to a chain of characters. The chain of characters is in any type of memory. Only pointers pointing to managed memory may be freed by: nlsStrFree . Your pointer points to managed memory, if you have assigned a value either through nlsStrAlloc or through nlsStrDup . Never free: strings you have got out of an object, because the character chains will be freed with the object! strings you have got out of a set of strings, because the character chain will be freed with set! strings you have assigned a character array. The array will be freed at end of the routine auto-matically.