Temp. Data to a Report

stonystony Member Posts: 122
Hello,

i have in a form (source is item), a variable TempItem (is a temp. variable - record - item), which will be filled with same items records. Now, i want to start a report, which will use only this TempItem Records. (with the FlowFields "Qty. on Sales Order" to the DateFilter)

This is the code to start the report (OnRun-Trigger by a Button)
SelectItem := TempItem;
SelectItem.COPYFILTERS(TempItem);

REPORT.RUN(50073,TRUE,FALSE,SelectItem);
The Report have as DataItem "Item" and "Sales Line".
But this did not work right. What is wrong. How can i transfer the TempItem to the report?

regards
stony

Comments

  • ssinglassingla Member Posts: 2,973
    Search the forum for "Parameter report" and you will find examples like
    viewtopic.php?f=23&t=42803&hilit=parameter+report
    CA Sandeep Singla
    http://ssdynamics.co.in
  • BeliasBelias Member Posts: 2,998
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    why are you not using directly the TempItem when calling the report?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • stonystony Member Posts: 122
    Do you mean ?
    REPORT.RUN(50073,TRUE,FALSE,TempItem);
    
  • vijay_gvijay_g Member Posts: 884
    As you have mentioned flowfiled,one thing is also keep in mind value of flow filed does not calculated in TempTable.
  • kinekine Member Posts: 12,562
    stony wrote:
    Do you mean ?
    REPORT.RUN(50073,TRUE,FALSE,TempItem);
    

    Better will be something like:
    REPORT.RUN(REPORT::"50073",TRUE,FALSE,TempItem);
    
    (but it is only the "purity" of the coding)
    But yes, try it...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    i've not tried it (but i tried it in the past), but passing a temporary table to a report doesn't work...it gave me some strane message like "settableview not defined" or so...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    I think that it depends on specific version, but may be I am wrong, I have not used it long time...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    i just tried it...i'm too curious :mrgreen:
    in nav 2009 sp1 this code
    tbcustomer.findfirst;
    tempcustomer := tbcustomer;
    tempcustomer.insert;
    report.run(report::"Customer - List",false,false,tempcustomer);
    
    returns this error...
    The Customer - List report does not have a DataItem that uses the table (Table 18 Customer) specified in the function SetTableView.
    maybe a filter on markedonly can work...but be aware of possible performance problems...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    Ah,ok, than, I am wrong...

    It is the error that table is not there but it is... I think that it was same for XMLPort in NAV 4 but was solved for it in NAV 5+ and may be I remember this one...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • FlowerBizFlowerBiz Member Posts: 34
    I just recently went through this exercise. Here's what I did.

    I used a form that was bound to a table with the "SourceTableTemporary" property set to Yes. My form fills the temporary table with data. When I want to launch a report based on the temporary data, I execute this code from within the form:

    CLEAR(SalesRep);
    SalesRep.PassParams(Rec);
    SalesRep.RUN

    "SalesRep" is a variable that is type "Report", set to the report I wish to run.

    In the report, I added a function called "PassParams" with one pass-by-reference parameter (i.e. the VAR column is checked) of type "Record" which points to the same table that the form is bound to. The function looks like this:

    PassParams(VAR TempSales : Record "Sales Report Worksheet")
    SalesRec.COPY(TempSales,TRUE);

    "SalesRec" is a global variable of type "Record" that is set to the table that the form is bound to. Its "Temporary" property is set to Yes. The one line of code is key as it tells Navision to reference the temporary table (and thus all of its data) that was passed (by reference also) from the Form. So in the report, "SalesRec" is actually referencing the temporary table that was created (and still held) by the form.

    The report must use the Integer table as the data item and the temporary records must be looped manually. To do this place this code at the beginning of the "Integer - OnAfterGetRecord()" trigger:

    IF Counter = 0 THEN
    SalesRec.FINDFIRST
    ELSE
    SalesRec.NEXT;
    Counter += 1;

    "Counter" is a global variable of type integer. Finally, place this code in the "Integer - OnPreDataItem()" trigger:

    SETRANGE(Number,1,SalesRec.COUNT);
    Counter := 0;

    Otherwise, the report will run for as long as there are integers in the Integer table. Also, each field used in the report "sections" will have to be prefixed with the temporary table variable name (SalesRep in my example above), since these fields won't exist in the Integer table.
  • BeliasBelias Member Posts: 2,998
    Flowerbiz, you're making harder a simple thing :-k
    why do you need a form with temporary sourcetable and pass the parameters to the report?
    you can just populate the temptable within the report dataitems, and then show the integers! (just like it's done in the howto)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • FlowerBizFlowerBiz Member Posts: 34
    Belias wrote:
    Flowerbiz, you're making harder a simple thing :-k
    why do you need a form with temporary sourcetable and pass the parameters to the report?
    you can just populate the temptable within the report dataitems, and then show the integers! (just like it's done in the howto)

    I agree with you but the original poster was asking to launch a report from within a form, using a temporary table.
  • BeliasBelias Member Posts: 2,998
    #-o right, i didn't read carefully...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.