Data Copying Procedure - Active Method Doesn't Work

Troubles_In_Paradise
Member Posts: 588
Hi guys!
I'm wondering if anyone has already faced a problem like this:
We started with a Re-numbering process for tables.
For example:
50000 -> 18035765
50001 -> 18035766
etc...
After that I want to transfer data from "old" tables to "new" tables. To do it without dataport I wrote a process.
The Table RenObject contains 1 record for each table, specifing the new number:
PK old ID new ID
1 50000 18035765
2 50001 18035766
ecc..
INTStart e INTEnd describe the table range I want to work with.
When I read it I thought that the length of one field was too small for the content, but debugging I found that this error occurs on empty field and in particular with disabled table field. So I decide to put the part of the code that gives to the FieldRef variable the value of the other into an IF statement testing the Active method of the FieldRef but it doesn't work.
Testing the value of the field Enabled in the Table "Field" instead of using the method active on the FieldRef.
Thx all and excuse me for the long post...
I'm wondering if anyone has already faced a problem like this:
We started with a Re-numbering process for tables.
For example:
50000 -> 18035765
50001 -> 18035766
etc...
After that I want to transfer data from "old" tables to "new" tables. To do it without dataport I wrote a process.
The Table RenObject contains 1 record for each table, specifing the new number:
PK old ID new ID
1 50000 18035765
2 50001 18035766
ecc..
INTStart e INTEnd describe the table range I want to work with.
VarRecordRenObject.RESET; VarRecordRenObject.SETRANGE("Source Type",VarRecordRenObject."Source Type"::Record); VarRecordRenObject.SETRANGE("Source ID",INTStart,INTEnd); IF VarRecordRenObject.FINDSET THEN BEGIN DLGWindow.OPEN(TXCMess1); REPEAT DLGWindow.UPDATE(1,VarRecordRenObject."Source ID"); VarRecordField.RESET; VarRecRefOld.OPEN(VarRecordRenObject."Source ID"); VarRecRefNew.OPEN(VarRecordRenObject."Destination ID"); IF VarRecRefNew.FINDSET THEN BEGIN ERROR('table not empty'); END; IF VarRecRefOld.FINDSET THEN BEGIN INTRec := 1; REPEAT DLGWindow.UPDATE(2,INTRec); VarRecordField.SETRANGE(TableNo,VarRecordRenObject."Source ID"); IF VarRecordField.FINDSET THEN BEGIN REPEAT VarFieldRefFrom := VarRecRefOld.FIELD(VarRecordField."No."); VarFieldRefTo := VarRecRefNew.FIELD(VarRecordField."No."); VarFieldRefTo.VALUE := VarFieldRefFrom.VALUE; VarRecRefNew := VarFieldRefTo.RECORD; UNTIL VarRecordField.NEXT = 0; END; IF VarRecRefNew.INSERT THEN BEGIN END; INTRec += 1; UNTIL VarRecRefOld.NEXT = 0; END; VarRecRefOld.CLOSE; VarRecRefNew.CLOSE; UNTIL VarRecordRenObject.NEXT = 0; DLGWindow.CLOSE; END;It works fine but in one case it gives me an error of overflow in the conversion from Code to Code.
When I read it I thought that the length of one field was too small for the content, but debugging I found that this error occurs on empty field and in particular with disabled table field. So I decide to put the part of the code that gives to the FieldRef variable the value of the other into an IF statement testing the Active method of the FieldRef but it doesn't work.
... if VarFieldRefFrom.active then begin VarFieldRefTo.VALUE := VarFieldRefFrom.VALUE; VarRecRefNew := VarFieldRefTo.RECORD; end; ...So a colleague of mine suggest me a solution that works.
Testing the value of the field Enabled in the Table "Field" instead of using the method active on the FieldRef.
... if VarRecordField.enabled then begin VarFieldRefFrom := VarRecRefOld.FIELD(VarRecordField."No."); VarFieldRefTo := VarRecRefNew.FIELD(VarRecordField."No."); VarFieldRefTo.VALUE := VarFieldRefFrom.VALUE; VarRecRefNew := VarFieldRefTo.RECORD; end; ...The only thing we wonder is if anyone already knows this problem...
Thx all and excuse me for the long post...
~Rik~
It works as expected... More or Less...
It works as expected... More or Less...
0
Comments
-
"active" method for fieldrefs works on my own pc! :-k
recref.open(3); fieldref := recref.field(2); message(format(fieldref.active)); clear(fieldref); fieldref := recref.field(1); message(format(fieldref.active));
the code is significant only in italian version, because field 2 is not enabled by default just in our contry0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions