บทความ

กำลังแสดงโพสต์จาก 2019

Ax How to set a where condition between two fields of a same table in AOT query

รูปภาพ
 this.query().datasourceTable(TableNum(CustTrans)).addRange(FieldNum(CustTrans,recid)).value(strFmt('(%1 - %2 > 0)', fieldStr(custtrans, amountcur),fieldStr(custtrans, settleamountcur) ) );     this.query().datasourceTable(TableNum(CustTrans)).addRange(FieldNum(CustTrans,recid)).value(strFmt('((%1 != %2))',fieldStr(CustTrans, AmountCur),fieldStr(CustTrans, SettleAmountCur)));

How multiple selec records in a grid !! Axapta

รูปภาพ
1. Set Properties Button     MultiSelection = Yes 2.Coding void clicked() {     Y_Customer    Customer;     MultiSelectionHelper helper = MultiSelectionHelper::construct();     helper.parmDatasource(Y_Customer_ds);     Customer = helper.getFirst();     while (Customer.RecId != 0)     {         info(Customer.CustAccount);         Customer = helper.getNext();     }     super(); }

How to add/remove Filter on Display Method Axapta

รูปภาพ
public void context() {     int                     selectedMenu;     formrun                 fr;     Args                    ag;     Name                    strtext;     querybuilddataSource    qb1;     queryrun                qr;     query                   q;     PopupMenu menu = new PopupMenu(element.hWnd());     int a = menu.insertItem('Filter By Field');     int b = menu.insertItem('Filter By Selection');     int c = menu.insertItem('Remove Filter');     ;     q   = TPI_SalesTableLineTC_ds.query();     qb1 = ...

display rangeField Show Input inReport Axapta

รูปภาพ
display name showInputdata() {     return "วันที   : "+     strReplace(strReplace(element.query().dataSourceName("TaxTrans_1").rangeField(fieldnum(TaxTrans,Transdate)).value(),'"',""),'..','  ถึง  ') ; }

เริ่ม ต้นเขียนโปรแกรมกับ กับ X++

เริ่ม ต้นเขียนโปรแกรมกับ กับ X++ เรามาทำความรู้จักภาษาที่ใช้ ใน การพัฒนา Axapta นั่นคือ ภาษา X++ ถูกออกแบบโครงสร้างคล้ายกับ JAVA ซึ่ง X++ มีโครงสร้าง แบบ object oriented programming สามารถที่จะ inheritance, classes, object และ methods. X++ สามารถเขียน scripting language SQL ในการ ติดต่อข้อมูลเป็นส่วนหนึ่ง ของ ภาษา X++ ก่อนที่เราจะเรียนรู้กับการเขียนโปรแกรมเราจะมาดูรายเอียดในหัวข้อต่างดังนี้ AOT แสดงถึง โครงสร้างของ Application ทั้งหมด Data Dictionary ใช้แสดงและออกแบบ Database จะประกอบไปด้วย   Table ตารางเก็บข้อมูล   MAP ใช้สำหรับ MAP ตารางเก็บข้อมูล ที่มีโครงสร้างที่คล้ายกันเพื่อให้ง่ายต้องการใช้งาน   View ใช้ทำ Query เพื่อจำลอง Table เสมือนเพื่อที่จะใช้ในการแสดงข้อมูล   Extended Data Type ประเภทข้อมูลมีความสำคัญในการใช้จัดการประเภทข้อมูลเป็นอย่างมาก Base Enums คือการกำหนด ข้อความเป็นตัวเลขในการเก็บข้อมูล เช่น NOYES::NO = 0, NOYES::YES = 1 Feature Key ใช้ในการกำหนดสิทธ์ (เฉพาะ Axapta 2.5) License Code ใช้ในการ License ให้กับ Code ที่ได้ทำก...

Add dimension in Range in ax

รูปภาพ
public void init() {     str _str = '8C16';     super();     LedgerJournalTrans_ds.query().dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldId2Ext(fieldNum(LedgerJournalTrans,Dimension),1)).value(strFmt('%1',_str)); }

date Functions Axapta X++

รูปภาพ
static void date_Functions(Args _args) {     Transdate    d;     ;     d = mkdate(27,08,2017);     info(strfmt("Date - %1",d));     //Gets the month for the given date...     info(strfmt("Month - %1",mthofYr(d)));     //Gets the month name from the given date...     info(strfmt("Month Name - %1",mthname(mthofYr(d))));     //Gets the day for the given date...     info(strfmt("Day - %1",dayOfMth(d)));     //Gets the day name from the given date...     info(strfmt("Day Name - %1",dayname(dayOfMth(d))));     //Gets the year for the given date...     info(strfmt("Year - %1",year(d)));     //Gets the current weekday number from the date...     info(strfmt("Weekday number - %1",dayOfwk(d)));     //Gets the day of the year from the given date...     info(strfmt("Day of year - ...

Code Basic Select X++

รูปภาพ
static void TestSelectSalesTable(Args _args) {     salesTable  salesTable;     ;     select firstonly salesTable         index hint SalesIdx         where salesTable.SalesId == "8003322590";         info(salesTable.CustAccount); }

Axapta X++ buf2Buf copy record ,Copying table records to duplicate table

static void buf2Buf_Example(Args _args) {     //Updating by buf2Buf()     SourceA     source,                 destination;     ;     source.number   = 1;     source.fieldA   = 'xxx';     source.fieldB   = 'yyy';     source.fieldC   = 'zzz';     destination     = sourceA::find(1,true);     ttsBegin;         buf2Buf(source, destination);         if (!destination.validateWrite())             throw Exception::Error;         destination.update();     ttsCommit;     info('done');   }

Ax Code X++ For Loop While Loop

static void ForWhile(Args _args) {     int i; // Control variable.     int ex=-1;     real curVal;     real _Value=5;     ;     i = 1;     while (i <= 100)     {         info(strfmt('%1',i));         i++;     }     for (i=1; i<=100; i+=1)     {         info(strfmt('%1',i));     }     for (i=1; i<=5; i++)     {        info(strfmt('%1',i));     }     do    {       ex += 1;       curVal = power(10, ex);    }    while (_Value>curVal);    info(strfmt('%1',ex)); }

AX Code X++ changeCompany

static void changeCom(Args _args) {    //check if company is part of a virtual company    VirtualDataAreaList           virtualDataAreaList, virtualDataAreaFind;    InventTableModule            otherInventTableModule;    ;     if (!xDataArea::find(curext()).isVirtual)    {        select firstOnly virtualDataAreaFind                   where virtualDataAreaFind.Id == curext();        if (virtualDataAreaFind)        {            while select virtualDataAreaList                   where virtualDataAreaList.virtualDataArea    == virtualDataAreaFind.virtualDataArea                               {...

AX Code X++ create SalesLine

static void createSalesLine(Args _args) {     SalesTable  salesTable  = SalesTable::find('012500');     ItemId      itemId      = 'G0001';     InventDimId inventDimId = '000051';     SalesLine   salesLine;     // performs relevant checks. Can we create line?     // If sales order invoiced and sales ledger parameters Safety level of invoiced order parameter is set to Locked then we can not     if (salesTable.checkUpdate(true))     {         salesLine.clear();         salesLine.SalesId       = salesTable.SalesId;         salesLine.ItemId        = itemId;         salesLine.InventDimId   = inventDimId;         salesLine.SalesQty      = 2;         salesLine.createLine(true, true, true, true, true,...

Dialog Code X++ Ax

static void DialogSampleCode(Args _args) {     Dialog      dialog;     DialogField field;     ;     if(box::yesNo("ต้องการสร้าง ใบ work ใหม่ หรือไม่?",       dialogbutton::Yes) == dialogbutton::Yes)     {         dialog = new Dialog("Select Work");         dialog.addText("Voucher No:");         field = dialog.addField(typeid(VourchID));         dialog.run();         if (dialog.closedOk())         {             info(field.value());         }     } }

X++ Conpeek Conpoke AX

static void Test_Conpeek_Conpoke(Args _args) {     container c1 = ["item1", "item2", "item3"];     container c2;     int i;     void conPrint(container c)     {         for (i = 1 ; i <= conlen(c) ; i++)         {             info(conpeek(c, i));         }     };     conPrint(c1);     c2 = conpoke(c1, 4, "PokedItem");     info('---');     conPrint(c2);     info(conpeek(c1, 1));     c2 = connull();     info('---');     conPrint(c2);     info(int2str(conlen(c2))); }

Axapta Create WH Location x++

static void CreateWHLocation(Args _args) {     WMSLocation                 WMSLocationSource, WMSLocationCopy;     inventlocation              inventlocationSource,InventlocationCopy;       inventdim                   inventdim;     InventLocationId            InventLocationIdsource,newInventLocationId;     wMSLocationId               wMSLocationIdsource,newwMSLocationId;     ;            InventLocationIdsource      = "IM-0001";         newInventLocationId         = "IM-0002";         wMSLocationIdsource         ="WMS001";         newwMSLocationId            = "WMS...

How to Pick Sales Order Axapta

static void PickSO(Args _args) {     SalesFormLetter_PickingList salesFormLetter;     SalesTable      salesTable = salesTable::find('SO19-00001');     ;     salesFormLetter = SalesFormLetter_PickingList::construct();     salesFormLetter.transDate(systemDateGet());     salesFormLetter.update(salesTable,                             systemdateget(),                             SalesUpdate::All,                             AccountOrder::None,                             NoYes::No,                             NoYes::No); }

Ax reserve

static void reserve(Args _args) {     InventTrans             inventTrans;     InventMovement          inventMovement;     InventUpd_Reservation   inventUpd_Reservation ;     SalesLine               salesLine = SalesLine::findInventTransId("L19999");     ;     inventTrans = InventTrans::findTransId(salesLine.InventTransId);     if(inventTrans.RecId)     {         Inventmovement = inventTrans.inventmovement(true);         inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement, inventTrans.inventDim(), inventTrans.Qty, false);         inventUpd_Reservation.updatenow();     }     info('done'); }

X++ Export Excel

static void ExportExcel(Args _args) {    int x;    SysExcelApplication          xlsApplication;    SysExcelWorkBooks            xlsWorkBookCollection;    SysExcelWorkBook             xlsWorkBook;    SysExcelWorkSheets           xlsWorkSheetCollection;    SysExcelWorkSheet            xlsWorkSheet;    SysExcelRange                xlsRange;    int                          row = 1;    str                          fileName;    ;    fileName = "C:\\Users\UserName\Downloads\TemplateShip.xls";    //Initialize Excel instance    xlsApplication       ...

AX container Example

static void conInsExample(Args _args) {     container c;     int i;     ;     c = conIns(c,1,"item1");     c = conIns(c,2,"item2");     c = conIns(c,3,"itemXXX");     for (i = 1 ; i <= conLen(c) ; i++)     {         info(strfmt('%1', conPeek(c, i)));     } }

AX Code Exchange Rates

static void ExchRates(Args _args) {      ExchRate  ex,ex1;      date      df = mkdate(1,1, 2019);      amount    amount;      ;      //ex = ExchRates::exchRateCache().exchRate('USB', systemdateget());      //Back Date 1 day Ref: Date Confirmation      ex = ExchRates::exchRateCache().exchRate('USB', df)/100;            //ExchRates::find(_currencyCode, _exchRateDate, 0).ExchRate;      ex1 = ExchRates::find('USB', today(), 0).ExchRate/100;      amount = (171.40*ex)-(1/100);      info(strfmt('%1',amount));      info(strfmt('%1 ,  %2',df,ex));      info(strfmt('%1 ,  %2',systemdateget(),ex1)); }

connection AX to the sql database ,DirectSql

Example : Connection AX 2009 to the sql database ,DirectSql static void DirectSql2(Args _args) {     CCADOConnection     ccConnection;     CCADOCommand        ccCommand;     CCADORecordSet      ccRecordset;     CCADOFields         ccFields;     Com               Com;     Str                 servername  = '10.0.1.10';     Str                 database    = 'DataBaseName';     Str                 user        = 'UserName';     Str                 PWD         = 'Password';     Str              ...