viernes, 18 de noviembre de 2011

Ejecutar Reporte Ax 2012 con parametros

SrsReportRunController  reportRunController;
    Map                     queryContracts;
    MapEnumerator           mapEnum;
    Query                   query;
    QueryBuildRange         range;
   
      GsCamEsTiketContract contract ;
    ;
   
    // Create the report run controller
    reportRunController = new SrsReportRunController();
    reportRunController.parmReportName('GsCamEsTiketSalida.PrecisionDesign1');
    reportRunController.parmLoadFromSysLastValue(false);
   
   
   
    // Set printer settings (print to file, format, filename, etc).
    reportRunController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
   // contract =reportRunController.parmReportContract() as GsCamEsTiketContract;
    reportRunController.parmReportContract().parmRdpContract().parmGsComEspCamionEsperaid("ABI-000024_Cam");
    //reportRunController.parmReportContract().parmPrintSettings().overwriteFile(true);  
    //reportRunController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
    //reportRunController.parmReportContract().parmPrintSettings().fileName('c:\\test.pdf');
       
    // Find/enumerate queries in the contract. The return from parmQueryContracts is
    // a map of type <ParameterName,Query(class)>  
   
    // There must be a better way than this of updating the query prior to running the report -
    // Or at least utility methods should be created to find the correct query
    // or datasource directly from the ReportRunController.        
    /*
    queryContracts = reportRunController.parmReportContract().parmQueryContracts();
    mapEnum = queryContracts.getEnumerator();  
    while(mapEnum.moveNext())  
    {
        // Get the query and update the datasource as required
        query = mapEnum.currentValue();  
        range = SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(VendTable)),fieldNum(VendTable,AccountNum));
        range.value('1*');
    }  
    */
    // Run the report
    reportRunController.runReport();


Fuente: http://axinternals.blogspot.com/2011/11/running-report-via-code-in-ax2012.html

No hay comentarios:

Publicar un comentario