martes, 8 de mayo de 2012

Obtener Dimensiones Ax 2012


  container dimensionValueIn;
   
    ;
   

print AxdDimensionUtil::getMultiTypeAccountId(enumName2Id("LedgerJournalACType"),0,["ABTECH-MTY-Produccion","11161004"]);
print AxdDimensionUtil::getDimensionAttributeValueSetId([2,"División","ABTECH","Sucursal","MTY"]);
  dimensionValueIn=AxdDimensionUtil::getDimensionAttributeValueSetValue(AxdDimensionUtil::getDimensionAttributeValueSetId([2,"División","ABTECH","Sucursal","MTY"]));
 
   pause;

miércoles, 28 de marzo de 2012

Crear y leer Archivos Dynamics ax 2012

static void Job_File_IO_TextIo_Write_Read(Args _args)
{
    TextIo txIoRead,
         txIoWrite;
    FileIOPermission fioPermission;
    container containFromRead;
    int xx,
        iConLength;
    str sTempPath,
        sFileName = "Test_File_IO.txt",
        sOneRecord;
    ;
    // Get the temporary path.
    sTempPath = WINAPI::getTempPath();
    info("File is at: " + sTempPath + sFileName);

    // Assert permission.
    fioPermission = new FileIOPermission
        (sTempPath + sFileName ,"RW");
    fioPermission.assert();
 
    // If the test file already exists, delete it.
    if (WINAPI::fileExists(sFileName))
    {
        WINAPI::deleteFile(sTempPath + sFileName);
    }
    
    // Open a test file for writing.
    // "W" mode overwrites existing content, or creates the file.
    txIoWrite = new TextIo( sTempPath + sFileName ,"W");

    // Write records to the file.
    txIoWrite.write("Hello        World.");
    txIoWrite.write("The sky is blue.");
    txIoWrite.write("");
    txIoWrite.write("// EOFile");

    // Close the test file.
    txIoRead = null;

    // Open the same file for reading.
    txIoRead = new TextIo(sTempPath + sFileName ,"R");
    // Read the entire file into a container.
    containFromRead = txIoRead.read();

    // Loop through the container of file records.
    while (containFromRead)
    {
        sOneRecord = "";
        iConLength = conLen(containFromRead);
        // Loop through the token in the current record.
        for (xx=1; xx <= iConLength; xx++)
        {
            if (xx > 1) sOneRecord += " ";
            sOneRecord += conPeek(containFromRead ,xx);
        }
        info(sOneRecord);

        // Read the next record from the container.
        containFromRead = txIoRead.read();
    }

    // Close the test file.
    txIoRead = null;
    // Delete the test file.
    WINAPI::deleteFile(sTempPath + sFileName);

    // revertAssert is not really necessary here,
    // because the job (or method) is ending.
    CodeAccessPermission::revertAssert();
}
Fuente: http://msdn.microsoft.com/en-us/library/cc967403.aspx

martes, 13 de marzo de 2012

Crear Asiento Ax 2012

 LedgerVoucher   lv;
    NumberSeq       numberSeq;
   currencyExchangeHelper currencyExchangeHelper ;
    LedgerVoucherTransObject LedgerVoucherTransObject;
   LedgerVoucherObject LedgerVoucherObject;
    ;
    currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), today());
    ttsBegin;
    numberSeq = NumberSeq::newGetVoucher(LedgerParameters::numRefLedgerExchAdjVoucher());

    lv = LedgerVoucher::newLedgerPost(
        DetailSummary::Detail,
        SysModule::Ledger,
        numberSeq.parmNumberSequenceCode());

    LedgerVoucherObject= LedgerVoucherObject::newVoucher(numberSeq.voucher(),today(), SysModule::Ledger,LedgerTransType::Invent);
    lv.addVoucher(LedgerVoucherObject);

    LedgerVoucherTransObject=LedgerVoucherTransObject::newTransactionAmountDefault(
            LedgerVoucherObject,//("ABI-000437"),
            LedgerPostingType::LedgerJournal,
            DimensionDefaultingService::serviceCreateLedgerDimension(5637157573),           // Ledger account
            Ledger::find(Ledger::current()).AccountingCurrency,
            2004,              // Amount
            currencyExchangeHelper);
     lv.addTrans(LedgerVoucherTransObject);

     LedgerVoucherTransObject=LedgerVoucherTransObject::newTransactionAmountDefault(
            LedgerVoucherObject,//("ABI-000437"),
            LedgerPostingType::LedgerJournal,
            DimensionDefaultingService::serviceCreateLedgerDimension(5637158025),           // Ledger account
            Ledger::find(Ledger::current()).AccountingCurrency,
            -2004,              // Amount
            currencyExchangeHelper);
     lv.addTrans(LedgerVoucherTransObject);
    lv.end();
    ttsCommit

jueves, 9 de febrero de 2012

AifQueueManager Manual

static void AIFProcessing(Args _args)
{
AifOutboundProcessingService outboundService = new AifOutBoundProcessingService();
AifGatewaySendService sendService = new AifGatewaySendService();
;
outboundService.run();
sendService.run();
}

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