Options

Idea for Import Lines in Comment Sheet Table?

elToritoelTorito Member Posts: 191
HI,

for any Items i would make an Dataport for Import Comment Sheets.

Now i have make an Report (i did id make with an processing only report and request form)...

The Report runs ... it Inserts some Descriptions in my Comments Line \:D/

But now the Problem, i don't have any idea what can i make if already exists Comment Sheets for the Item.

I Have decided that before Importing new lines, i delte all the old Lines, but here ist the problem ...

This is the Format of File what i want be import:
3#Item1#01.02.2005#CODE#Description for Line 1#
3#Item1#01.02.2005#CODE#Description for Line 2#
3#Item1#01.02.2005#CODE#Description for Line 3#
3#Item2#01.02.2005#CODE#Description for Line 1#
3#Item2#01.02.2005#CODE#Description for Line 2#

In Trigger OnAfterGetRecord() i have all the Fields i need,
but the Trigger is processed for each Line in the Text File, so
if i ask if already exists Lines for any Item and would Delete them, and insert New, then when der trigger runs again with an item with the same Number, then it deletes me the new lines i have inserted.

If i try with Modify old Lines, then i have Problem that when trigger runs again i overwrite a line that already was changed.

I Hope you understand what i mean...

With an Process Only Report i would Import Comment Sheet Lines, when already exists an Item with Comment Lines, i would delete this Lines and insert new lines for this item.

I Hope now you have kind of an idea for me because i'm now

:-k ](*,) #-o :-s

Thanks


EDIT: I have now found that i can give my Record (Comment Line) a Temporary Propierty ....
The C/SIDE Reference says:
Using a temporary table can be useful in some situations. If you need to perform a lot of calculations on data in a table, for example, in a report, but it is not of the utmost necessity that the data used are the newest version, you can reduce load on the server by copying the table in question to a temporary table and working with this copy.

Well, if i give this propierty? then i cann put him all my new lines in them ?
And if Answer is yes, how can i transfer them to my originally table with delete the Entrys what i would replace?

hmm... 8-[
(Oo)=*=(oO)

Comments

  • Options
    WaldoWaldo Member Posts: 3,412
    I don't know what you're doing wrong, but may be this can help (just another approach):

    It seems you already found a way to identify the line numbers for the comment sheet. Lets modify that logic by calculating the new line number, depending on the existing lines. So do a FIND('+') ("find last record") on the comment table (ranged on the proper item), and find your last Line No. for that record. Add 10000 to it, and that's the new line number for you comment lines to import.

    So the logic could be:
    OnAfterImportRecord()
    IF codItemNo <> codPreviousItemNo THEN BEGIN
      CalculateLineNo
    ELSE
      intLineNo := intLineNo + 1;
    CommentSheet."Line No." := intLineNo;
    
    CalculateLineNo()
    lrecItemCommentSheet.SETRANGE("Item No.", codItemNo)
    IF lrecItemCommentSheet.FIND('+') THEN
      intLineNo := lrecItemCommentSheet."Line No." + 10000
    ELSE
      intLineNo := 10000;
    

    I hope I understood your question right ... and this is something you can use ... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    elToritoelTorito Member Posts: 191
    Waldo wrote:
    I hope I understood your question right ... and this is something you can use ... .


    Hi Waldo,

    yes, this give me one idea for solucion my problem.
    my function like so now :
    IF iNo <> PreviousItemNo THEN BEGIN
      lrecItemCommentSheet.RESET;
      lrecItemCommentSheet.SETFILTER("Table Name", 'Item');
      lrecItemCommentSheet.SETFILTER("No.", iNo);
      lrecItemCommentSheet.SETFILTER(Code,iCode);
      
      IF lrecItemCommentSheet.FIND('-') THEN
        lrecItemCommentSheet.DELETEALL();
        
        lrecItemCommentSheet.INIT;
        lrecItemCommentSheet."Table Name" := iTableName;
        lrecItemCommentSheet."No." := iNo;
        lrecItemCommentSheet."Line No." := CalculateLineNo(iNo,iCode);
        lrecItemCommentSheet.Date := iDate;
        lrecItemCommentSheet.Code := iCode;
        lrecItemCommentSheet.Comment := iComment;
        lrecItemCommentSheet.INSERT;
        PreviousItemNo := iNo;
    END ELSE BEGIN 
          lrecItemCommentSheet.INIT;
          lrecItemCommentSheet."Table Name" := iTableName;
          lrecItemCommentSheet."No." := iNo;
          lrecItemCommentSheet."Line No." := CalculateLineNo(iNo,iCode);
          lrecItemCommentSheet.Date := iDate;
          lrecItemCommentSheet.Code := iCode;
          lrecItemCommentSheet.Comment := iComment;
          lrecItemCommentSheet.INSERT;
    END;
    

    Well , thanks, and have i nice day. =D>
    (Oo)=*=(oO)
Sign In or Register to comment.