create temptable in dataport import, use in report

jversusj
jversusj Member Posts: 489
I have checked the forums and found some similar threads, but they didn't really help me achieve my goal.

I am importing a text file into Navision that creates Sales Quotes. During the import, if the Item No. on the sales line is found to be invalid, i write a record to a temporary table I am calling error log. On PostDataItem, I call a report to print the error log. Trouble is, the tempTable doesn't seem to have any data in it when the report runs.

I tested physically writing the error log and then putting a DELETEALL in the report to purge the table, and this worked perfect, but is not the ideal solution.

One thread i found here suggested calling the report first, and from the report running the dataport, but i was having the same problem.

Is there a tutorial thread i did not find that discusses how to pass a temptable from a dataport import to a report?

flow:
import record.
If problem on import, write error log
finish import
call report to print the error log so user sees what problems exist and can address them.
kind of fell into this...

Answers

  • bobnavision
    bobnavision Member Posts: 159
    how are you calling the report?
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,598
    Tick Var in the parameter.
  • jversusj
    jversusj Member Posts: 489
    here's how i call the report
    Integer - OnPostDataItem()
    PrintErrorLog();
    
    PrintErrorLog()
    COMMIT;
    //ErrorRpt.tmpError(ErrorLog); //testing an idea from another thread here
    REPORT.RUNMODAL(50060,FALSE);
    

    Miklos, do I tick Var in the dataport function that calls the report, or in a function on the report?

    I'm currently experimenting with a function on the report (tmpError) that is accepting the temporary table, but after the function is done, the report closes and the output is never created... it never enters the dataitems.

    edit:
    I know the solution is somehow related to this thread i just found:
    http://www.mibuso.com/forum/viewtopic.php?t=12482&highlight=call+dataitem+function, but I am still having the trouble getting the dataitems to run... I get to my function and copy the temptable to a global on the report, but then it quits.[/url]
    kind of fell into this...
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,598
    Tick everywhere a temp table is passed as a parameter, I think.
  • jversusj
    jversusj Member Posts: 489
    no luck.

    following through with the other thread's suggestions, here is what i have:
    REPORT
    Integer - OnPreDataItem()
    ErrorLog.RESET;
    SETRANGE(Number,1,ErrorLog.COUNT);
    
    Integer - OnAfterGetRecord()
    IF Number = 1 THEN
       ErrorLog.FIND('-')
    ELSE
       ErrorLog.NEXT;
    
    Integer - OnPostDataItem()
    
    tmpError(VAR XLog : Record "Error Log")
    ErrorLog.COPY(XLog);
    
    the function tmpError gets called from my dataport, and in debugger, I see it properly populate ErrorLog with the data from xLog, but then it leaves the function and returns to the dataport, where the runmodal is called. Then the report initializes an empty error log table...

    Is there a way to call a report function, but when the function is done, go to the dataitems of the report instead of back to the dataport? If I could just get into the report dataitems i think i could crack this. thanks in advance!
    kind of fell into this...
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,598
    OK some clarification:

    - in the dataport, somewhere at the end loop through the template and call the function in the report for each record

    - in the function of the report, insert the VAR record received as a parameter into a global temp table

    it should work, because as long as the report object variable is in scope and it has a global temptable populated it won't lose it just because the code goes back to the dataport
  • jversusj
    jversusj Member Posts: 489
    Hello,
    I have followed Miklos helpful suggestion, neglecting to make the destination table temporary in the report. so, the first time i ran the import, everything went well (although i took the temp data and turned it into physical data).

    I ran it a second time and saw the same errors from the first time, plus some new. I realized I forgot to change the destination table to temporary. I made the change (deleting the records in the table as well) and re-ran the process.

    I got an error that the table was empty.

    I watched the process through debugger and saw the following:
    my loop in the dataport to pass the temp table (XLog) to the report function, where it writes the same record to another temp table (ErrorLog). This all appears to go smoothly.
    After completing the loop, the RUNMODAL was called, and the report came up with the temptable ErrorLog uninitialized (? - i just populated it). Of course, it initializes with no records and my FIND fails.

    Any ideas why I might be having this problem?
    kind of fell into this...
  • jversusj
    jversusj Member Posts: 489
    i'm dumb.

    i was using 2 different syntax, so i was calling two different instances of the report - hence the uninitiated record. i corrected my syntax and POW! everything worked great.

    Thanks Miklos and everyone else in the other thread for getting me on the right track.
    kind of fell into this...