Options

Rtc-Print Excel

LambaLamba Member Posts: 260
edited 2012-02-28 in NAV Three Tier
Hi Experts,

There is a customized report, having code on OnPreSection() of the dataitem's body trigger.
The code is given below which does the insertion of data in excel:

IF COMPANYNAME = 'XYZ' THEN
SalesAmt :=SalesCrMemoLineAmount;

NetAmt := 0;
IF Customer.GET("Sales Cr.Memo Header"."Sell-to Customer No.") THEN
IF (CRSalesAmt <> 0) AND (Customer."Net Amount %" <> 0) THEN
NetAmt := (CRSalesAmt / Customer."Net Amount %") * 100;

IF CurrReport.SHOWOUTPUT AND ExportToXL THEN BEGIN
EnterCell(i,1,FORMAT("Document No."),FALSE,FALSE);
EnterCell(i,2,FORMAT("Sales Cr.Memo Header"."Posting Date"),FALSE,FALSE);
EnterCell(i,3,FORMAT("Sell-to Customer No."),FALSE,FALSE);
EnterCell(i,4,FORMAT("Sales Cr.Memo Header"."Sell-to Customer Name"),FALSE,FALSE);
EnterCell(i,5,FORMAT("No."),FALSE,FALSE);
EnterCell(i,6,FORMAT(Description),FALSE,FALSE);
EnterCell(i,7,FORMAT("Item Category Code"),FALSE,FALSE);
EnterCell(i,8,FORMAT(CRItemCatDesc),FALSE,FALSE);

EnterCell(i,9,FORMAT("Product Group Code"),FALSE,FALSE);
EnterCell(i,10,FORMAT("Sales Cr.Memo Header"."Ship-to Code"),FALSE,FALSE);
EnterCell(i,11,FORMAT("Sales Cr.Memo Header"."Ship-to Name"),FALSE,FALSE);
EnterCell(i,12,FORMAT(CRCountry),FALSE,FALSE);
IF COMPANYNAME = 'PMI' THEN
EnterCell(i,13,FORMAT(SalesCrMemoLineAmount),FALSE,FALSE)
ELSE
EnterCell(i,13,FORMAT(CRSalesAmt),FALSE,FALSE);
EnterCell(i,14,FORMAT(CRValueAmt),FALSE,FALSE);
EnterCell(i,16,FORMAT("Unit of Measure Code"),FALSE,FALSE);

EnterCell(i,15,FORMAT(CMQty * -1),FALSE,FALSE);

QuantityKL := 0;
ItemUnitMeasure.RESET;
ItemUnitMeasure.SETRANGE("Item No.","No.");
ItemUnitMeasure.SETRANGE(Code,'KL');
IF ItemUnitMeasure.FINDFIRST THEN BEGIN
QuantityKL := CMQtyBase / ItemUnitMeasure."Qty. per Unit of Measure" * -1;
END;

QuantityNo := 0;
ItemUnitMeasure.RESET;
ItemUnitMeasure.SETRANGE("Item No.","No.");
ItemUnitMeasure.SETRANGE(Code,'NOS');
IF ItemUnitMeasure.FINDFIRST THEN BEGIN
QuantityNo := CMQtyBase / ItemUnitMeasure."Qty. per Unit of Measure" * -1;
END;

EnterCell(i,17,FORMAT(QuantityNo),FALSE,FALSE);
EnterCell(i,18,FORMAT(QuantityKL),FALSE,FALSE);
EnterCell(i,19,FORMAT(NetAmt),FALSE,FALSE);

i+=1;
END;

I have tried:

1. Moving code to the dataitem's OnAftergetrecord() with the following

IF ISSERVICETIER THEN
code...

still i getting the data in the excel,excel is getting generated. But without any data.

Answers

  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Is this code generating data in classic client?
  • Options
    LambaLamba Member Posts: 260
    Mohana,

    Yes, it is.
    And the companies in both classic and Rtc are also same.
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Can you add message statements in different places under If Conditions and check whether the code is executing in RTC or not..
  • Options
    LambaLamba Member Posts: 260
    Yes it is working on Rtc, after generating the preview, Message pops up, with the corresponding values
  • Options
    LambaLamba Member Posts: 260
    But the data is not flowing to the Excel.
  • Options
    LambaLamba Member Posts: 260
    I have tried transferring the code to OnPostReport(),still the data is not moving to the Excel in Rtc. ](*,)
  • Options
    mihail_kolevmihail_kolev Member Posts: 379
    probably the EnterCell function is working with file in some local path. In RTC, local path means a path on the machine that run the Service. Try to run the report on the machine that runs the NAVService to see if the function is actually do what it should.
    -Mihail- [MCTS]
  • Options
    akhileshekakhileshek Member Posts: 28
    Hi Lamba
    Section Level coding will not work on RTC reports You have to write the code at
    onpredataitemtriger or on aftergetrecords


    Regards
    Akhilesh
  • Options
    LambaLamba Member Posts: 260
    HI Mihail,

    Can u please, tell me how can i identify the nav service in a machine.
    Is it the service Named Microsoft Dynamics Nav server, running with my login id.
  • Options
    LambaLamba Member Posts: 260
    HI Mihail,

    Can u please, tell me how can i identify the nav service in a machine.
    Is it the service Named Microsoft Dynamics Nav server, running with my login id.
  • Options
    mihail_kolevmihail_kolev Member Posts: 379
    yes, this is the name of the service, but I'm talking about the service that RTC is connected to. You can check this in the RTC - Microsoft Dynamics NAV->Select Server
    -Mihail- [MCTS]
  • Options
    LambaLamba Member Posts: 260
    Mihail,

    It shows like localhost:7046/DynamicsNAV in RTC-> Microsoft Dynamics Nav-> Select server..
    I think this is not the concern, its something related to code.
  • Options
    mihail_kolevmihail_kolev Member Posts: 379
    well, let's say that the EnterCell function use some Automations. The CREATE method in RTC should be called with additional parameters like CREATE(xlAutomation,FALSE,ISSERVICETIER);
    -Mihail- [MCTS]
  • Options
    LambaLamba Member Posts: 260
    well, let's say that the EnterCell function use some Automations. The CREATE method in RTC should be called with additional parameters like CREATE(xlAutomation,FALSE,ISSERVICETIER);

    Mihail,
    How could that be done.
    as i have the Entercell code is on most of the section for Excel data entry.
  • Options
    mihail_kolevmihail_kolev Member Posts: 379
    EnterCell looks like a single function (View->C/AL Globals->Functions tab, select the function and press F9). It's possible to use some Automation OR the Automation can be a Global variable. Check it where this automation is created, or post the code of the EnterCell function.
    -Mihail- [MCTS]
  • Options
    LambaLamba Member Posts: 260
    Simple CurrReport.SHOWOUTPUT doesn't works for Rtc. I removed that part from the code.
    And now the data is flowing into the excel for Rtc
Sign In or Register to comment.