31 Ocak 2013 Perşembe

AXAPTA - bir kullanıcıya uyarı mesajı göndermek

static void sendAlertToUser(UserId _UserId,EventSubject _Subject,EventMessage _Message)
{
    EventInbox        inbox;
    EventInboxId      inboxId;
    SysClientSessions sessions;
    ;
    inboxId = EventInbox::nextEventId();
    inbox.initValue();
    inbox.ShowPopup            = NoYes::Yes;
    inbox.Subject              = _Subject;
    inbox.Message              = _Message;
    inbox.SendEmail            = true;
    inbox.UserId               = _UserId;
    inbox.InboxId              = inboxId;
    inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
    inbox.insert();
}

AXAPTA - kodla sipariş oluşturma

...
    SalesTable                  salesTable;
    NumberSeq                   NumberSeq;
    SalesLine                   salesLine;
    AxSalesLine                 axSalesLine = new axSalesLine();
    AxSalesTable                axsalesTable = new axSalesTable();
    ;
...
    ttsbegin;
    axsalesTable.parmSalesId();
    if (ServiceOrder.CustName == "")
        axsalesTable.parmCustAccount(ServiceOrder.CustAccount);// Cust Account
    else
        axsalestable.parmOneTimeCustomer(Dialog_OneTime.value());

    axsalesTable.parmDlvMode(Dialog_DLVMode.value());
    axsalesTable.parmDlvTerm(Dialog_DLVTerm.value());
    axsalesTable.save();
    while select forupdate Lines where Lines.RepairJournalId == _RepairJournalId && Lines.SalesId == "" &&
        Lines.CSApproval == B_Approval::Approved && Lines.ItemId != "" && Lines.Qty > 0
    {
        axSalesLine = AxSalesLine::construct();
        axSalesLine.parmSalesId(axsalesTable.parmSalesId());
        axSalesLine.parmItemId(Lines.ItemId);
        axSalesLine.parmSalesQty(Lines.Qty);
        axSalesline.parmSalesPrice(Lines.ProjSalesPrice);
        axSalesline.parmCurrencyCode(Lines.ProjCurrencyCode);
        axSalesline.parmSalesUnit(Lines.Unit);
        Lines.SalesId = axsalesTable.parmSalesId();
        Lines.update();
        axSalesLine.save();
    }
    ttscommit;
...

29 Kasım 2012 Perşembe

AXAPTA SysQuery ile Form ve Report'a Range Ekleme

Form için:
    SysQuery::findOrCreateRange(B_RMAOutTable_DS.query().dataSourceTable(tablenum(B_RMAOutTable)),        fieldnum(B_RMAOutTable,RMAIn)).
         value(QueryValue(NoYes::Yes));


Report için:

    SysQuery::findOrCreateRange(this.query().dataSourceTable(tablenum(SMAServiceOrderTable)),
        fieldnum(SMAServiceOrderTable,ItemSerialNum)).
 value(sysquery::valueNotEmptyString());


Run methoduna super'den önce yazabilirsiniz.

27 Kasım 2012 Salı

If ve like

Axapta'da like operatörü sadece sql - select cümleciklerinde değil, if komutunda da kullanılabilir:

if (ItemId like "WX*")

5 Kasım 2012 Pazartesi

AXAPTA - Excel Import

void clicked()
{
    SysExcelApplication application;
    SysExcelWorkbooks   workbooks;
    SysExcelWorkbook    workbook;
    SysExcelWorksheets  worksheets;
    SysExcelWorksheet   worksheet;
    SysExcelCells       cells;
    COMVariantType      type;
    int                 row;
    str                 line;
    Filename            Filename;
    ;
    super();
    Filename = WinApi::getOpenFileName(element.hWnd(),['XLS dosyaları','*.xls'],"","Serino dosyası");
    if (!Filename)
        return;

    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    try
    {
        workbooks.open(filename,0,true);
    }
    catch (Exception::Error)
    {
        throw error(strfmt("Dosya açılamıyor: %1",Filename));
    }

    element.lock();
    workbook = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    do
    {
        row++;
        type = cells.item(row+1,1).value().variantType();

        switch(cells.item(row,1).value().variantType())
        {
            case COMVariantType::VT_BSTR:
                line = cells.item(row,1).value().bStr();
                break;
            case COMVariantType::VT_DECIMAL, COMVariantType::VT_R4, COMVariantType::VT_R8:
                line = strfmt("%1",any2int(cells.item(row,1).value().double()));
                break;
            case COMVariantType::VT_I1, COMVariantType::VT_I2, COMVariantType::VT_I4:
                line = strfmt("%1",cells.item(row,1).value().int());
                break;
            case COMVariantType::VT_UI1, COMVariantType::VT_UI2, COMVariantType::VT_UI4:
                line = strfmt("%1",cells.item(row,1).value().uLong());
                break;
            case (COMVariantType::VT_DATE):
                line = date2str(cells.item(row,1).value().date(),123,2,1,2,1,4);
             case COMVariantType::VT_EMPTY:
                line ="";
                break;
            default:
                line="";
}
        if (Line != "")
            element.insertSerial(line);
    }
    while (type != COMVariantType::VT_EMPTY);
    application.quit();
    element.unLock();
}

15 Ekim 2012 Pazartesi

AXAPTA - Client Arabelleğini Temizleme

Bazen yeni yazdığınız kodlar client'i resetleseniz bile client tarafında görünmeyebilir. Bu durumda client bilgisayarında aşağıdaki kodları çalıştırmanız işe yarayabilir:

xSession::removeAOC();
SysTreeNode::refreshAll();
SysFlushDictionary::doFlush();
SysFlushAOD::doFlush();
xSession::updateAOC();

9 Ekim 2012 Salı

AXAPTA - Empty compound statement uyarısı

Axapta derleme esnasında bu uyarıyı verir. Boş blokları temizleyerek bu uyarıdan kurtulunabilir. Ancak Try/Catch bloğunda bunu yapamazsınız. Bu durumda ne yapacaksınız?
catch (Exception::Error)
{
 exceptionTextFallThrough();
}


Uyarıyı kaldırmaktan başka bir işlevi olmayan bu fonksiyonu bir blogdan buldum.