Problem with temporary table in a dataport

Hello, please help me to solve following problem: Dataport - DataItem is Integer Record variable “TmpInvoiceLine” is temporary InvoiceHeader.SETRANGE(“Posting Date”,StartDate,EndDate); IF InvoiceHeader.FIND(’-’) THEN REPEAT InvoiceLine.SETRANGE(InvoiceLine.“Document No.”,InvoiceHeader.“No.”); InvoiceLine.SETFILTER(InvoiceLine.“Return Reason Code”,‘ZV’); IF InvoiceLine.FIND(’-’) THEN REPEAT TmpInvoiceLine.COPY(InvoiceLine); TmpInvoiceLine.INSERT; UNTIL InvoiceLine.NEXT = 0; UNTIL InvoiceHeader.NEXT = 0; The content of temporary table will be deleted after each founded InvoiceHeader. After export of TmpInvoiceLine i get only invoice lines from last invoice header. Do you have any solution? Darius Dudek

I already tried to make init. But it didn’t work Darius

Hi You find lines or only one line? Please try it with TmpInvoiceLine.INIT. <OnBeforeExportRecord> InvoiceHeader.SETRANGE("Posting Date",StartDate,EndDate); IF InvoiceHeader.FIND('-') THEN REPEAT InvoiceLine.SETRANGE(InvoiceLine."Document No.",InvoiceHeader."No."); InvoiceLine.SETFILTER(InvoiceLine."Return Reason Code",'ZV'); IF InvoiceLine.FIND('-') THEN REPEAT **TmpInvoiceLine.INIT;** TmpInvoiceLine.COPY(InvoiceLine); TmpInvoiceLine.INSERT; UNTIL InvoiceLine.NEXT = 0; UNTIL InvoiceHeader.NEXT = 0; bye André

quote:


Originally posted by Andre DDB
Hi You find lines or only one line? Please try it with TmpInvoiceLine.INIT.


Hi, the 1st Invoice has 2 lines the 2nd 2 lines too. I get only 2 lines from the last invoice. (After using of TmpInvoiceLine.Init i get the same output) Bye Darius

Hi

quote:


Originally posted by Dudi
… The content of temporary table will be deleted after each founded InvoiceHeader. After export of TmpInvoiceLine i get only invoice lines from last invoice header. …


IMHO your code looks OK. Place your code in the OnPreDataItem - trigger of the Dataport. Perhaps this will work. bye André

quote:


Originally posted by Andre DDB IMHO your code looks OK. Place your code in the OnPreDataItem - trigger of the Dataport. Perhaps this will work. bye André


After using of OnPreDataItem - trigger i get only 1 line!?! Bye Darius

Hi I never worked with temporary tables in a dataport [:(]. First you got one header now you get one line. Do you filter your DataItem(Integer)? Perhaps there is a problem[?] bye André

Hi, Your code looks OK.Try TRANSFERFIELDS instead of COPY.

quote:


Originally posted by Rajeshj
Hi, Your code looks OK.Try TRANSFERFIELDS instead of COPY.


Hi, Great!!! It works [:D] Thanks! Darius

Slightly off, but anyway… I would like to use a dataport toIMPORT to a temporary table, while running the dataport from a form. Is this possible? How? Thanks in advance! Pelle

Pelle, Set up variables in your dataport and use these in your dataport fields to recieve the CSV values from the imported file. In the OnAfterImport trigger of the dataport Init your new temp record, assign the values from the variables and insert the rec to the temp table. Make sure you clear all of your variables after doing the each insert or values might persist if there are blanks in the CSV file. Note, when you use variables instead of data item fields for your dataport fields it does not actually matter what data item you define for the dataport. Hope this helps… Chris.

Chris, thank yuo for your answer! But I don’t understand how I can access the temp table from the calling form. Do you have an idea? Pelle