Hot News:

Unser Angebot:

  Foren auf CAD.de (alle Foren)
  ENOVIA SmarTeam
  Generating Material ID from Material Type plus a number incremented...

Antwort erstellen  Neues Thema erstellen
CAD.de Login | Logout | Profil | Profil bearbeiten | Registrieren | Voreinstellungen | Hilfe | Suchen

Anzeige:

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen nächster neuer Beitrag | nächster älterer Beitrag
Autor Thema:  Generating Material ID from Material Type plus a number incremented... (4744 mal gelesen)
purdueman
Mitglied


Sehen Sie sich das Profil von purdueman an!   Senden Sie eine Private Message an purdueman  Schreiben Sie einen Gästebucheintrag für purdueman

Beiträge: 7
Registriert: 09.08.2005

erstellt am: 07. Dez. 2005 13:58    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

hi,
sorry, i couldn't write in German, aber ich wolle Deutsch sprechen 
I try to change Material ID field with the Material Type with a number incremented, for example; if I change the material type as 'brass', Material ID should be 'brass-1', 'brass-2', so on, when I change the material type as 'paper', it should be 'paper-1' and so on.
Firstly I define a variable as CN_COUNTER, this variable should be initialized with ADD operation, then should be incremented with UPDATE operation. Here is the code for UPDATE operation (I couldn't solve incrementing yet) ;

Function UpdateMaterialID(ApplHndl As Long,OpStr As String, _
FirstPar As Long,SecondPar As Long,ThirdPar As Long ) As Integer

Dim Session As SmSession
Set Session = SCREXT_ObjectForInterface(ApplHndl)

Dim RecListIn As Object
CONV_RecListToComRecordList FirstPar,RecListIn

Dim RecListOut As Object
CONV_RecListToComRecordList ThirdPar, RecListOut

Dim RecordIn As Object
Set RecordIn = RecListIn.GetRecord(0)

Dim ObjectStore As ISmObjectStore
Set ObjectStore = Session.ObjectStore

Dim SourceObject As ISmObject
Set SourceObject = ObjectStore.ObjectFromData(RecordIn, True)

Dim AttributeName As String
Dim SourceAttribute As ISmClassAttribute
Dim SourceAttributes As ISmClassAttributes

AttributeName = "CN_MATERIAL_TYPE"
Set SourceAttributes = SourceObject.Attributes
Set SourceAttribute = SourceAttributes.ItemByName(AttributeName)

Dim LookupValue As Long
Dim LookupClassId As Long
Dim LookupObject As ISmLookUpObject

LookupValue = SourceObject.Data.ValueAsInteger(AttributeName)
LookupClassId = SourceAttribute.ReferencedClassId
Set LookupObject = ObjectStore.GetSmLookUp(LookupClassId, LookupValue)

RecListOut.AddHeader "CN_ID",20,1
RecListOut.ValueAsString ("CN_ID", 0) = LookupObject.DisplayName

CONV_ComRecListToRecordList RecListOut,ThirdPar
End Function

CN_ID is the attribute for Material ID.
I can easily get the display name of the lookup table in UPDATE operation, but not in ADD operation, when I try to use the same code, the error is;
Error No: 02101
Internal Error. Method 'SetupFromRecord' requires attribute 'OBJECT_ID' in the input record.

any advice or solution for ADD operation and incrementing the number will be highly appreciated, thanks for your help.

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

ChristianS
Moderator
Leiter Kundenbetreuung


Sehen Sie sich das Profil von ChristianS an!   Senden Sie eine Private Message an ChristianS  Schreiben Sie einen Gästebucheintrag für ChristianS

Beiträge: 635
Registriert: 27.09.2000

erstellt am: 13. Dez. 2005 08:15    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities Nur für purdueman 10 Unities + Antwort hilfreich

Hi,

the error is in line

'**************
Set SourceObject = ObjectStore.ObjectFromData(RecordIn, True)
'**************

If you will get the attributes in 'Before ADD' event, the sourceobject does not exist at this moment.
So you have to get the needed attributes directly from firstrec or secondrec.
To see it clearly you can export the recordlists with firstrec.printtofile

Regards,
Christian

[Diese Nachricht wurde von ChristianS am 13. Dez. 2005 editiert.]

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Anzeige.:

Anzeige: (Infos zum Werbeplatz >>)

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen

nächster neuerer Beitrag | nächster älterer Beitrag
Antwort erstellen


Diesen Beitrag mit Lesezeichen versehen ... | Nach anderen Beiträgen suchen | CAD.de-Newsletter

Administrative Optionen: Beitrag schliessen | Archivieren/Bewegen | Beitrag melden!

Fragen und Anregungen: Kritik-Forum | Neues aus der Community: Community-Forum

(c)2023 CAD.de | Impressum | Datenschutz