Why cannot modify record in Dataport?

bluerock
bluerock Member Posts: 32
I create a dataport for importing data, and re-calculate the amount. But it won't update the amount, any mistake in my coding? thank you.


OBJECT Dataport 90002 Item2007Opening ImpUpdate
{
OBJECT-PROPERTIES
{
Date=24/07/09;
Time=[ 4:49:55 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
FileFormat=Variable;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table90021;
AutoSave=Yes;
AutoUpdate=Yes;
AutoReplace=Yes;
DataItemTableView=SORTING(Item No.);
OnAfterImportRecord=BEGIN
g_recItem2007Opening.SETFILTER("Item No.","Item 2007 Opening"."Item No.");;
IF g_recItem2007Opening.FIND('-') THEN
BEGIN
g_recItem2007Opening.GET("Item 2007 Opening"."Item No.");

intAmount := g_recItem2007Opening."Unit Cost" * g_recItem2007Opening.Quantity;
g_recItem2007Opening.Amount := intAmount;
//g_recItem2007Opening.VALIDATE(Amount, intAmount);
g_recItem2007Opening.MODIFY;
END;
END;

}
FIELDS
{
{ ; ;"Item No." }
{ ; ;Quantity }
{ ; ;"Unit Cost" }
{ ; ;Amount }
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=9020;
Height=3410;
}
CONTROLS
{
}
}
CODE
{
VAR
g_recItem2007Opening@1000000000 : Record 90021;
intAmount@1000000001 : Integer;

BEGIN
{
/* This is used to import the "Unit Cost" into the table 'Item 2007 Opening'
/* And then re-calculatte the amount ["Unit Cost" * Quantity] in the table 'Item 2007 Opening'
/* The .csv file just contains two columns: 1) Item No. 2) Unit Cost
}
END.
}
}

Comments

  • Luc_VanDyck
    Luc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try adding a MESSAGE just after the line g_recItem2007Opening.MODIFY; to see if this line is being executed or not.

    And why you first do a g_recItem2007Opening.GET after you did a IF g_recItem2007Opening.FIND('-') THEN is mystery to me.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • kriki
    kriki Member, Moderator Posts: 9,132
    BTW : if you run the dataport directly in design-mode, it will NOT do a implicit COMMIT at the end. For this you need to run the dataport from the object designer or from the menu or from another object.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!