using “update_record” instead of “while select forupdate”

description on MSDN :
“This means that certain tasks may have improved performance by using the power of the SQL server.”

replace code below for a better perfomance.

MyTable myTableBuffer;
;
while select forUpdate mytableBuffer
{
mytableBuffer.field1 = field * 1.10;
}

with


MyTable myTableBuffer;
;
update_recordset myTableBuffer
setting field1 = field1 * 1.10;

source : http://msdn.microsoft.com/en-us/library/aa674382.aspx

Advertisements

How to print barcode Label , SSRS can’t print on Landscape Printer AX 2012r2

Hi there ,
after the report being save to PDF on local drive, i call adobe to print barcode,
i have to did that, because SSRS can’t print on landscape printer.

here is my example code

void clicked()
{
    //AIFD_PrintBarcode
    AI_PrintBarcodeController  aiBarcode = new AI_PrintBarcodeController();
    AI_PrintBarcodeContract    aiContract = new AI_PrintBarcodeContract();
    ProdJournalProd            prodJournalProdLoc;
    SRSPrintDestinationSettings  printSettings = new SRSPrintDestinationSettings();
    PrintJobSettings    printJobSettings = new PrintJobSettings();
    Dialog              dialog = new Dialog();
    DialogField         dialogFileName;
    str                 adobeExe;
    str                 adobeParm;

    str                 fileName;
    int                 fileCount;

    //AIFD
    InteropPermission   permission;
    str errorMessage;
    //END
    real WeightInreal;
    permission = new InteropPermission(InteropKind::ClrInterop);
    permission.assert();

    super();
    try
    {
        prodJournalProdLoc = ProdJournalProd_ds.getFirst(true);

        while (prodJournalProdLoc)
        {
            fileCount++;
            aiBarcode.parmReportName(ssrsReportStr(AI_PrintBarcoderReport,Report));
            aiBarcode.parmShowDialog(false);
            aiContract.parmRecordId(prodJournalProdLoc.RecId);
            aiContract.parmDocumentTitle("x");

            //printSettings = aiBarcode.parmReportContract().parmPrintSettings();
            printSettings.printMediumType(SRSPrintMediumType::File);
            //printSettings.landscape(false);
            //printSettings.printerPageSettings('KRRLabelBarcode');
            //info(strFmt("%1",printSettings.printerPageSettings()));

            fileName = strFmt("D:\\barcode%1.pdf",fileCount);

            printSettings.fileFormat(SRSReportFileFormat::PDF);
            printSettings.fileName(fileName);
            printSettings.printerName("TOSHIBA B-SA4TP TS");
            printSettings.landscape(false);
            printSettings.overwriteFile(true);
            aiBarcode.parmReportContract().parmRdpContract(aiContract);
            aiBarcode.parmReportContract().parmPrintSettings(printSettings);

            aiBarcode.startOperation();

            WeightInReal = sleep(500);
            //printJobSettings.printerSettings('SysPrintForm');
            printJobSettings.setTarget(PrintMedium::Printer);
            printJobSettings.preferredTarget(PrintMedium::Printer);
            adobeExe = WinAPI::findExecutable(fileName);

            adobeParm = strFmt(' /t "%1" "%2" "%3" "%4"',
                               fileName,
                               "TOSHIBA B-SA4TP TS",
                               printJobSettings.printerDriverName(),
                               printJobSettings.printerPortName());

            winAPI::shellExecute(adobeExe,  adobeParm);

            WeightInReal = sleep(500);

            prodJournalProdLoc = ProdJournalProd_ds.getNext();
         }
     CodeAccessPermission::revertAssert();
    }
    catch(Exception::CLRError)
    {
        errorMessage = AifUtil::getClrErrorMessage();

        CodeAccessPermission::revertAssert();

        throw error(errorMessage);
    }
    //END
}

Custom lookup example code x++ AX 2012

Example of custom lookup for itemid on PurchLine , form : PurchTable

public void lookup()
{
 SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);
 Query query = new Query();
 QueryBuildDataSource queryBuildDataSource, queryBuildDataSource2;
 QueryBuildRange queryBuildRange, queryBuildRange2;
 QueryBuildLink queryBuildLink;
 BuyBackScheme BuyBackScheme;
 str FilterCategory;
 //super();

 queryBuildDataSource = query.addDataSource(tablenum(InventTable));
 //add by Fanddy
 if(InventBuyerGroup::find(PurchTable.ItemBuyerGroupId).InventOwnership == InventOwnership::MD)
 {
 queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(PdsApprovedVendorList));
 queryBuildDataSource.joinMode(JoinMode::InnerJoin);
 queryBuildDataSource.relations(true);

 queryBuildDataSource.addRange(fieldNum(PdsApprovedVendorList,PdsApprovedVendor)).value(PurchTable.OrderAccount);
 queryBuildDataSource.addRange(fieldNum(PdsApprovedVendorList,ValidFrom)).value(strFmt(“<= %1″,DateTimeUtil::date(DateTimeUtil::removeTimeZoneOffset(PurchTable.createdDateTime,TimeZone::GMTPLUS0700_BANGKOK_HANOI_JAKARTA))));
 queryBuildDataSource.addRange(fieldNum(PdsApprovedVendorList,ValidTo)).value(strFmt(“>= %1″,DateTimeUtil::date(DateTimeUtil::removeTimeZoneOffset(PurchTable.createdDateTime,TimeZone::GMTPLUS0700_BANGKOK_HANOI_JAKARTA))));

 }
 //END by fandd

 sysTableLookup.addLookupfield(fieldnum(InventTable, itemId));
 sysTableLookup.addLookupMethod(‘itemName’);
 sysTableLookup.addLookupMethod(‘itemGroupId’);
 sysTableLookup.addLookupfield(fieldnum(InventTable, NameAlias));
 sysTableLookup.addLookupMethod(tableMethodStr(InventTable,pdsDefaultOrderType));
 sysTableLookup.addLookupfield(fieldnum(InventTable, RetailType));
 sysTableLookup.parmQuery(query);
 sysTableLookup.performFormLookup();

}

happy daxing !