How to Call Report after importing with Dataport

selece28selece28 Member Posts: 316
Hi nav Masters,
I have a problems when importing using dataport then i call a report to print the record that i just imported.

I use a temptable on the dataport to fill in the data that is imported, then call a function in the report, the function is to fill the temp table in the report.

So now i have the same record in the dataport and in the report.
Then on the dataport i call the report with this code :

Dataport - OnPostDataport()

RptSalesPrice.gFn_SetRecord(RecTmpSalesPrice);
RptSalesPrice.USEREQUESTFORM(TRUE);
RptSalesPrice.RUN();


The Import data is success but it didn't call the Report?
What i want is to show the Report Request Form so i can preview or print.
Can i do that?

Please advice

Thanks in advance
______________

Regards,
Steven

Answers

  • rajpatelbcarajpatelbca Member Posts: 178
    if you want to show request form when report run use

    REPORT.RUNMODAL(Number [, ReqWindow] [, SystemPrinter] [, Record])

    here u create a variable type record of same rec because if u pass rec in last parameter then it wont work.

    saleshdr record sales header

    saleshdr.setrange(saleshdr."No.","No.");
    if saleshdr.findfirst then
    report.runmodal(50000, ture, false, saleshdr);

    hope it will help u.
    Experience Makes Man Perfect....
    Rajesh Patel
  • selece28selece28 Member Posts: 316
    Hi rajpatelbca

    I've try this before. Cannot use RUNMODAL because it will cause ERROR, i think its be cause the dataport haven't commit yet.

    Any other idea?
    thanks
    ______________

    Regards,
    Steven
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Better is to have a function that calls the dataport, and then calls the report, rather than having the report called from the dataport.
    David Singleton
  • selece28selece28 Member Posts: 316
    Hi David,
    Thats a good idea, but i want to know if navision can call report from dataport?

    Thanks for the advice
    ______________

    Regards,
    Steven
  • EugeneEugene Member Posts: 309
    u cant pass temporary table to a report to print from it.

    Instead in your OnPostDataport trigger you could COMMIT changes and after that call the report with RUN.

    Upon exit of OnPostDataport the COMMIT is issued by dataport itself so calling from a separate function your dataport and then your report essencially does the same thing
  • selece28selece28 Member Posts: 316
    Hi Eugene,
    I already try to use COMMIT and then RUN, still cannot.
    I think navision cannot call report from dataport, so i will try to find a workaround by calling from another function like David said.

    Thanks
    ______________

    Regards,
    Steven
  • garakgarak Member Posts: 3,263
    edited 2008-05-13
    The better solution is: You call your Dataport from a form and after dataport is running u get back the TempTab and send this to the Report.

    example:
    YourDataportAsVariable.runmodal;
    YourDataportAsVariable.GetTempTab(TempTab); <- CallByReference (VAR)
    YourReportAsVariable.SetTempTab(TempTab);
    YourReportAsVariable.runmodal;
    

    Regards
    Do you make it right, it works too!
  • selece28selece28 Member Posts: 316
    Yes thats a great idea, but it seems that i cannot get my TempTab.
    I always get 0 record.

    Any idea?
    ______________

    Regards,
    Steven
  • rajpatelbcarajpatelbca Member Posts: 178
    user message box to count record after importing data into table in dataport.
    if records are avail in that time. then use var type parameter.
    in a function called from from
    Experience Makes Man Perfect....
    Rajesh Patel
  • ara3nara3n Member Posts: 9,256
    selece28 wrote:
    Hi Eugene,
    I already try to use COMMIT and then RUN, still cannot.
    I think navision cannot call report from dataport, so i will try to find a workaround by calling from another function like David said.

    Thanks

    Change it from RUN to runmodal;
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • selece28selece28 Member Posts: 316
    I think when using RUNMODAL also cause an error.
    Currently trying to do like this from codeunit

    YourDataportAsVariable.runmodal;
    YourDataportAsVariable.GetTempTab(TempTab); <- CallByReference (VAR)
    YourReportAsVariable.SetTempTab(TempTab);
    YourReportAsVariable.runmodal;

    But i can't get my value even using CallByReference ](*,)

    This is my code:
    gFn_GetImportedRecord(VAR Rec_TmpSalesPrice : TEMPORARY Record "Sales Price")
    Rec_TmpSalesPrice := gRec_TmpSalesPrice;
    

    Its seems that my code must add Insert
    gFn_GetImportedRecord(VAR Rec_TmpSalesPrice : TEMPORARY Record "Sales Price")
    Rec_TmpSalesPrice := gRec_TmpSalesPrice;
    Rec_TmpSalesPrice.INSERT;
    

    bu then problems when i have more than 1 record. Should i use looping or does Nav have a function to copy all records to another records?

    Thanks in advance[/quote]
    ______________

    Regards,
    Steven
  • garakgarak Member Posts: 3,263
    Thjis is the code in your Codeunit
    CLEAR(YourDataport);
    CLEAR(YourReport);
    YourDataport.RUNMODAL;
    YourDataport.GetTempTab(VarTempTab);
    YourReport.SetTempTab(VarTempTab);
    YourReport.RUNMODAL;
    

    This is the code in function GetTempTab in YourDataport
    GetTempTab(VAR VarTempTab : TEMPORARY Record "Customer Objects")
    IF TempTab.FIND('-') THEN BEGIN
      REPEAT
        VarTempTab := TempTab;
        VarTempTab.INSERT;
      UNTIL TempTab.NEXT = 0;
    END;
    


    This is the code in function SetTempTab in YourReport
    SetTempTab(VAR VarTempTab : TEMPORARY Record "Customer Objects")
    IF VarTempTab.FIND('-') THEN BEGIN
      REPEAT
        TempTab := VarTempTab;
        TempTab.INSERT;
      UNTIL VarTempTab.NEXT = 0;
    END;
    

    Now in report you loop through the TempTab, for example, in DataItem "Integer"
    Do you need more informations :?:
    Do you make it right, it works too!
  • selece28selece28 Member Posts: 316
    Yes this is the solution,
    Thanks garak.
    I just find out that navision cannot do Rec := Rec1 without looping and INSERT.

    My problem solved now,
    Thank you all :)
    ______________

    Regards,
    Steven
Sign In or Register to comment.