[Not Solved]Change Fields while dataport is running

Roke
Member Posts: 7
Hi,
I want to do a dataport that export all records that have one field not cheked, and them when the dataport finish to export check this field. I have that code :
Movimientos tarjetas - OnPostDataItem()
recMovimientos.SETRANGE(recMovimientos.Sincronizado,FALSE);
recMovimientos.FINDFIRST;
REPEAT
recMovimientos.Sincronizado := TRUE;
recMovimientos.MODIFY;
UNTIL (recMovimientos.NEXT = 0);
But it doesnt work, is like the navision dont do a COMMIT, if i put a commit at the end it works. Some sugestions ?
Thanks for all.
I want to do a dataport that export all records that have one field not cheked, and them when the dataport finish to export check this field. I have that code :
Movimientos tarjetas - OnPostDataItem()
recMovimientos.SETRANGE(recMovimientos.Sincronizado,FALSE);
recMovimientos.FINDFIRST;
REPEAT
recMovimientos.Sincronizado := TRUE;
recMovimientos.MODIFY;
UNTIL (recMovimientos.NEXT = 0);
But it doesnt work, is like the navision dont do a COMMIT, if i put a commit at the end it works. Some sugestions ?
Thanks for all.
0
Comments
-
your code doesn't work because you're applying filters on a field you are going to modify...so you are losing the pointer on the record (I don't know if i told well in english)
substitute your code with this one...recMovimientos2 it's the same rec variable of recMovimientos...
recMovimientos.SETRANGE(recMovimientos.Sincronizado,FALSE);
recMovimientos.FINDSET;
recMovimientos2.RESET;
REPEAT
recMovimientos2.get(recMovimientos."primary key");
recMovimientos2.Sincronizado := TRUE;
recMovimientos2.MODIFY;
UNTIL (recMovimientos.NEXT = 0);0 -
the problem with original code is that once you change the value from FALSE to TRUE you jump down in the records list and skip all records with FALSE VALUE:
1 FALSE (when changed to TRUE you jump from 1st to 4th record)
2 FALSE (this one is skipped)
3 FALSE (this one is skipped)
4 TRUE
Alternatively you can try to loop from end to top:Movimientos tarjetas - OnPostDataItem() recMovimientos.SETRANGE(recMovimientos.Sincronizado,FALSE); recMovimientos.FINDLAST; REPEAT recMovimientos.Sincronizado := TRUE; recMovimientos.MODIFY; UNTIL (recMovimientos.NEXT(-1) = 0);
0 -
No that is not how you do it, in fact that is about the worst you can do. FINDFIRST and FINDLAST are NOT intended to be used when you need to loop through records, that is what FINDSET is for. Second, reverse looping through a record set is also not very safe, and could contribute to deadlocks.
If you need to modify a field that you filter on, then you have two options:
1 - you use a second variable to modify the record, just like Belias suggests.
2 - you use the FINDSET parameter to control its behavior. Go to the C/SIDE reference guide under the Help menu and read about FINDSET.0 -
Thanks for all help but it doesnt work. I do it with FINDSET but doesnt work.
I see on debug and the value change to false but dont save in database.
If i put the COMMIT sentence at the end the program works. THe tableview of the dataport its SORTING(No. Tarjeta,Numero Documento Asociado) ORDER(Ascending) WHERE(Sincronizado=CONST(No))
](*,) I think its for the type of transaction, but i try with all combinations. More suggestions please.
Thanks.0 -
I dont have it
I dont know what i do but i dont have.
Some suggestions ???
Here is the code:
OBJECT Dataport 50000 Exportar Tarjetas MM.AA
{
OBJECT-PROPERTIES
{
Date=18/03/08;
Time=14:03:43;
Modified=Yes;
Version List=;
}
PROPERTIES
{
FileFormat=Variable;
OnPostDataport=BEGIN
MESSAGE('proceso finalizado correctamente');
END;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table50002;
AutoSave=Yes;
AutoUpdate=Yes;
AutoReplace=Yes;
DataItemTableView=SORTING(No. Tarjeta,Numero Documento Asociado)
ORDER(Ascending)
WHERE(Sincronizado=CONST(No));
OnAfterExportRecord=BEGIN
recMovimientos.GET("Movimientos tarjetas"."No. Tarjeta","Movimientos tarjetas"."Numero Documento Asociado");
recMovimientos.Sincronizado := TRUE;
recMovimientos.MODIFY;
END;
}
FIELDS
{
{ ; ;"Fecha Registro" }
{ ; ;"No. Tarjeta" }
{ ; ;"Numero Documento Asociado" }
{ ; ;Descripcion }
{ ; ;"Importe Documento" }
{ ; ;"No. Puntos" }
{ ; ;"No. Cliente" }
{ ; ;"Nombre Cliente" }
{ ; ;"Nombre Empresa" }
{ ; ;Sincronizado }
}
}
{ PROPERTIES
{
DataItemTable=Table50000;
DataItemTableView=SORTING(No. Tarjeta,Cod. Cliente)
ORDER(Ascending)
WHERE(Sincronizado=CONST(No));
OnAfterExportRecord=BEGIN
recTarjetas.GET("Tarjeta Cliente"."No. Tarjeta","Tarjeta Cliente"."Cod. Cliente");
recTarjetas.Sincronizado := TRUE;
recTarjetas.MODIFY;
END;
}
FIELDS
{
{ ; ;"No. Tarjeta" }
{ ; ;"Fecha Entrada Vigor" }
{ ; ;"Fecha Caducidad" }
{ ; ;"Cod. Cliente" }
{ ; ;Saldo }
{ ; ;"Nombre de la Empresa" }
{ ; ;Sincronizado }
{ ; ;"No. Series" }
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=9020;
Height=3410;
}
CONTROLS
{
}
}
CODE
{
VAR
recMovimientos@1000000000 : Record 50002;
recTarjetas@1000000001 : Record 50000;
BEGIN
END.
}
}0 -
If you run your dataport directly from the dataport design-mode, you have this effect:the DB-changes are not commited. You need to save your dataport and then run it through the menu or directly from the object designer.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
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