Günü Sözü

"Hiçbir şey bilmeyen cahildir, ama bilip de susan ahlaksızdır. " Bertolt Brecht.
"İyilik yapabildiğim zaman mutlu olurum; ama en büyük mutluluk yapılan bir haksızlığı düzeltmektir." Tolstoy

3 Eylül 2018 Pazartesi

query filtre örneği, lookup filter örneği

filteredDs.addRange(fieldNum(FilteredTable, Field1)).value(strFmt(
    "(%1.%2 like %3.%4)",
    filteredDs.name(),
    fieldStr(FilteredTable, Field1),
    definitionDs.name(),
    fieldStr(FilterDefiniton, Field1)));


lookup filter
forma eklenen bir alan ve bu alan lookup ise filtre verme

Query                   query = new Query();
    QueryBuildDataSource    qbds;
    QueryBuildRange qr;
    SysMultiTableLookup     sysTableLookup;

    qr = query.addDataSource(tableNum(CustTable)).addRange(FieldNum(CustTable,RecId));
    //qr.value(strFmt('(!(AccountNum LIKE "%1"))',SysQuery::valueLikeAfter('M')));
   // qr.value(strFmt('(!(AccountNum LIKE "%1"))',"M*"));
    qr.value(strFmt('(!(AccountNum LIKE "M*"))'));

//status(2); bu recid değilde accountnum da gösterilecekse enable yapar



    sysTableLookup = SysMultiTableLookup::newParameters(this, query);
    sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
    sysTableLookup.addLookupField(fieldNum(CustTable, Party));

    sysTableLookup.performFormLookup();


örnek

 Query q;
    Queryrun qr;
    QueryBuildRange qbr;
    QueryBuildDataSource qbds;
    InventTrans iv;
    Real Total;
    str range;

    /* The following query produces the same results as:
    while select sum(qty) from inventTrans
        where (inventtrans.ItemId == "1016756") || inventtrans.ItemId == "1032958"
            join inventDim
                group by inventBatchId
                where inventDim.InventDimId == inventTrans.InventDimId */

    q = new query("Inventory_Transactions");
    qbds = q.addDataSource(tablenum(InventTrans));
    qbds.addSelectionField(fieldnum(InventTrans,Qty),selectionfield::Sum);
    qbr = qbds.addRange(fieldnum(InventTrans,ItemId));

    qbr.value(strfmt('((%1 == "%2") || (%1 == "%3"))',fieldstr(inventtrans,ItemId),'1016756','1032958'));
    range = strfmt('((ItemId == "%1")||(ItemID =="%2"))',queryvalue('1016756'),queryvalue('1032958'));
    qbr.value(range);

    qbds = qbds.addDataSource(tablenum(InventDim));
    qbds.relations(true);
    qbds.orderMode(ordermode::GroupBy);
    qbds.addSortField(fieldnum(InventDim,InventBatchId));
    qr = new QueryRun(q);  // If the user clicks OK, continue.
    if (qr.prompt())
    {
        while (qr.next())
        {
           iv = qr.get(tablenum(InventTrans));
           total =  iv.Qty;
        }
    }
    info(strfmt("Quantity: %1",total));
     info (qr.query().dataSourceNo(1).toString());

6 Ağustos 2018 Pazartesi

List, Set, Map and Containers in Dynamics Ax 2012 (Collection classes), Macros

static void TDS_ListExample(Args _args)
{
    List l = new List(Types::String);
    ListIterator li;
    ;
   
    // limitation of list - it will give in the order u add - ascending or descending order
    // it all also allow duplicates
   
   
    l.addStart("Tendulkar");
    l.addEnd("sehwag");
    l.addEnd("gambhir");
    l.addEnd("yuvraj");
    l.addStart("haribhajan");
    l.addend("haribhajan");
   
    info(int2str(l.elements()));
   
    li = new ListIterator(l);
   
    while (li.more()) // this will return true or false -
    {
        info (li.value());
        li.next();
    }
   

}
http://dynamicsaxforu.blogspot.com/2014/03/list-set-and-map-in-dynamics-ax-2012.html


static void Erm_Set_kull(Args _args)
{
    CustTable       custTable;
    Set             set = new Set(Types::Record);
    SetEnumerator   setEnumerator;
    ;

    while select custTable
    {
       if (custTable && !set.in(custTable))
        {
            set.add(custTable);
        }

    }

   if (!set.empty())

    {
        setEnumerator = set.getEnumerator();
        setEnumerator.reset();
        while (setEnumerator.moveNext())
        {
            custTable = setEnumerator.current();
            info(strfmt("Customer: %1",custTable.AccountNum));
        }
    }

}

*--*

static Set dimensionCodesSet2DimensionTopicsSet(Set _dimensionCodesSet) { Set topicsSet; SetEnumerator setEnumerator; DimensionTopic dimensionTopic; ; topicsSet = new Set(Types::Class); setEnumerator = _dimensionCodesSet.getEnumerator(); while (setEnumerator.moveNext()) { dimensionTopic = DimensionTopic::construct( DimensionTopicType::Dimension, Dimensions::code2ArrayIdx(setEnumerator.current())); topicsSet.add(dimensionTopic); } return topicsSet; }

static void TDS_SetExample(Args _args)
{
    Set s1 = new Set(Types::String);
    SetIterator si;
   
    Set s2 = new Set(Types::String);
   
    Set resultSet;
   
    // set will always result in ascending order and it will not allow duplicates
    // set can perform additional operations - union , intersection and difference
   
   
    s1.add("A");
    S1.add("z");
    s1.add("B");
    s1.add("F");
    s1.add("F");
   
    // To find any value in a set use "in" method
    if (s1.in("b") == true)
    {
        info ("b exists");
    }
    else
    {
        error ("b doesnt exists");
    }
   
   
    s2.add("A");
    s2.add("k");
    S2.add("g");
   
    info(int2str(s1.elements()));
   
    si = new SetIterator(s1);
   
    while (si.more())
    {
        info(si.value());
        si.next();
    }
   
    resultSet = Set::intersection(s1, s2);
   
    si = null;
   
    info ("Intersection");
    si = new SetIterator(resultSet);
   
     while (si.more())
    {
        info(si.value());
        si.next();
    }

   
}

Map : 

        - Map can hold a key and associated value
        - Imp methods : elements, Key, insert

static void TDS_MapExample(Args _args)
{
    // Maps are used to hold the key and correspondiong value
   
    Map m = new Map(Types::Integer, Types::String);
    MapIterator mi;
    ;
   
    m.insert(100, "Nick");
    m.insert(200, "Leo");
    m.insert(400, "Eve");
   
    mi = new MapIterator(m);
   
    while (mi.more())
    {
        info(mi.key());
        info(mi.value());
        mi.next();
    }
}

static void MAP_LoadTableTable(Args _args)
{
   Map m = new Map(Types::String, Types::Real);
   MEE_CustTable k;
   MapIterator mi;
 
 
   ;
 
   while select k
   {
        m.insert(k.CustomerId, k.Creditlimit);
   }
 
   info(int2str(m.elements()));
 
   info ("_______________________");
 
    mi = new MapIterator(m);
   
    while (mi.more())
    {
        info(mi.key());
        info(mi.value());
        mi.next();
    }

}

Containers :

  - Containers are used to store different datatypes
  - Max columns in a container - 50

>> some important functions :

conlen - gives the length of the container
conpeek - gives the value of an element based on the index
conpoke - used for replacing any element with new element value
condel - willl delete the elements in cotnainer based on the start postion and number of elements to be deleted
connull - will empty the container
conins - will help to insert new elements to container
conview - to viuew the elements in the container - onyl for unit testing

confind - to find a particular element exists in container - it will give u the postiion/index

>> Just look at the following example to undestand how these methods can be applied :

static void TDS_Containers(Args _args)
{
    Container con = [1000, "Rahul", 5000.00, 56];
    container resultCon;
    int i;
    int position;
    // container limit is 50 columns
    ;
   
    // container index starts with 1
   
    // to get the length of the container
    info(int2str(conlen(con)));
   
    // to get any value based on the index use conpeek() function
    info(conpeek(con, 3));
   
    // to get all the values in one shot
   
    info("__________________________________");
   
    for ( i = 1; i <= conlen(con); i++)
    {
        info(conpeek(con,i));
    }

    info("__________________________");
   
    resultcon = condel(con, 2,2);
   
    conview(resultcon); // this should be only used for testing purpose
   
    // to nullify to empty the container
   
    //con = connull();
   
    //info(int2str(conlen(con)));
   
    //
    // To insert any new valuezs into container - use conins()
    // To replace any value in the container - use conpoke()
    // to find any value in container- use confind
   
    position= confind(con, "sreedhar");
   
    info(strfmt("sreedhar is found at %1 position", position));
}

Macros in Microsoft dynamics Ax

Macro :
  • Macros are reusable components
  • Macros are mostly used to remove hardcoding and for constant values
  • Macros are pre-compiled/FASTER
  • In AX, we have a macro processor
  • Macros cannot be debugged
  • Macros reduces line of code/optimizes the lines of code
  • Macros will not end with semicolon
Macros can be defined in 3 ways :


1) Local Macro
2) AOT Macro [Global macro - we can call it in all objects, tables, forms, jobs, reports etc]
3) Macro library

1) Local Macro :
                      Local macro is a mcaro which is local to that function and cannot be used outside the method/function
static void TDS_LocalMacro(Args _args)
{
#define.pi(3.142)
#define.name('Tony')
#define.address('SR Nagar, Hyd')
;
info(strfmt('%1',#pi));
info(#name);
info(#name + "is a bad person");
info(#address);
}
2) AOT Macro :
                          AOT Macros will help to resue the functions inside it.
>>Go to AOT >> Macros >> Right click on the Macros node >> New Macro >> rename it to TDSAdd 4 functions inside the macros by doubling clicking it

#define.college('SR College')
#define.age(30)
#define.inst('Vertex soft')
#define.cl(4000.00)
>>How to call AOT Macro
>>Create a new job as shown below
static void TDS_CallAOTMacro(Args _args)
{
#TDS
;
info(#college);
info(int2str#age));
}
>>How to use in any other object:
Go to TDS_CustTable >> Methods >> Override initvalue() method and paste the following code
public void initValue()
{
#TDS
;
super();
this.Creditlimit = #cl;
this.JoinedDate = systemdateget();
}
3) Macro library :
                          Microsoft has already given many macros in AOT >> Macros node
[sys] layer
we can go ahead and add any function to already existing macros [sys layer]
AOT >> Macros >> AOTExport >> open in editor and add a new function at the end
#define.marks(30)
How to call Macro library macro
static void TDS_MacroLib(Args _args)
{
#aotexport //#macrolib.aotexport
;
info(int2str(#marks));
}
How to pass values or nuMber of lines in Macros: possible
static void TDS_PassingValues_Macro(Args _args)
{
int c;
#localmacro.sum
c = %1 + %2;
#endmacro
;
#sum(10,20)
info(int2str(C));
#sum(1000,5466)
info(int2str(c));
}
Macros reduces number of lines of code as well
static void TDS_PassingValues_Macro(Args _args)
{
int c;
#localmacro.sum
c = %1 + %2;
c = c - 4;
c = c * 4/100;
#endmacro
;
#sum(10,20)
info(int2str(C));
#sum(1000,5466)
info(int2str(c));
}

Note : It is best practice to use macros only to define constants. Also TDS stands for Tushar Devendra Srivastava just using my initials as best pratice for creating my own customizations.
http://dynamicsnavax.blogspot.com/2010/08/ax-how-to-use-set-and-setenumerator.html

https://docs.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/implementation-methodology?redirectedfrom=MSDN

7 Mayıs 2018 Pazartesi

Ax 2012 R2, R3 Sql de en son değişiklikleri bulma

 SELECT  ME.Name ,

        ME2.Name ,

        MED.MODIFIEDDATETIME ,

        MED.MODIFIEDBY

FROM    dbo.ModelElementData AS MED

        LEFT JOIN dbo.ModelElement AS ME ON ME.ElementHandle = MED.ElementHandle

        LEFT JOIN dbo.ModelElement AS ME2 ON ME2.ElementHandle = ME.ParentHandle

WHERE MED.MODIFIEDBY like '%CKR%'

ORDER BY MED.MODIFIEDDATETIME DESC

2 Mayıs 2018 Çarşamba

Ax 2012 R3, x++ Global fonksiyonlar, Kategori bazında

 Kaynak: Microsoft

Categorization of X++ Functions

The following table lists the X++ functions that belong in each previous category.

CATEGORIZATION OF X++ FUNCTIONS

Category

X++ function

Business

  • cTerm

  • ddb

  • dg

  • fv

  • idg

  • intvMax

  • intvName

  • intvNo

  • intvNorm

  • pmt

  • pt

  • pv

  • rate

  • sln

  • syd

  • term

Compiler Verified

(also named Intrinsic)

  • attributeStr

  • classNum

  • classStr

  • configurationKeyNum

  • configurationKeyStr

  • datasetStr

  • enumNum

  • enumStr

  • evalBuf

  • extendedTypeNum

  • extendedTypeStr

  • fieldNum

  • fieldPName

  • fieldStr

  • formControlStr

  • formStr

  • identifierstr

  • indexNum

  • indexStr

  • licenseCodeNum

  • licenseCodeStr

  • literalStr

  • menuItemActionStr

  • menuItemDisplayStr

  • menuItemOutputStr

  • menuStr

  • methodStr

  • perspectiveNum

  • perspectiveStr

  • queryDataSourceStr

  • queryStr

  • reportStr

  • resourceStr

  • runBuf

  • securityKeyNum

  • securityKeyStr

  • ssrsReportStr

  • staticMethodStr

  • tableCollectionStr

  • tableFieldGroupStr

  • tableMethodStr

  • tableNum

  • tablePName

  • tableStaticMethodStr

  • tableStr

  • varStr

  • webActionItemStr

  • webDisplayContentItemStr

  • webFormStr

  • webletItemStr

  • webMenuStr

  • webOutputContentItemStr

  • webPageDefStr

  • webReportStr

  • webSiteDefStr

  • webSiteTempStr

  • webStaticFileStr

  • webUrlItemStr

  • webWebpartStr

  • workflowApprovalStr

  • workflowCategoryStr

  • workflowTaskStr

  • workflowTemplateStr

Container

  • conDel

  • conFind

  • conIns

  • conLen

  • conNull

  • conPeek

  • conPoke

Convert

  • any2Enum

  • any2Date

  • any2Guid

  • any2Int

  • any2Int64

  • any2Real

  • any2Str

  • char2Num

  • Date2Num

  • Date2Str

  • Datetime2Str

  • formattedStr2Num

  • guid2Str

  • int2Str

  • int642Str

  • num2Char

  • num2Date

  • num2Str

  • str2Enum

  • str2Date

  • str2Datetime

  • str2Guid

  • str2Int

  • str2Int64

  • str2Num

  • str2Time

  • time2Str

  • uint2Str

Date

  • dayName

  • dayOfMth

  • dayOfWk

  • dayOfYr

  • endMth

  • maxDate

  • mkDate

  • mthName

  • mthOfYr

  • nextMth

  • nextQtr

  • nextYr

  • prevMth

  • prevQtr

  • prevYr

  • timeNow

  • today

  • wkOfYr

  • year

Enum

  • enum2Str

  • enumCnt

Math

  • abs

  • acos

  • asin

  • atan

  • corrFlagGet

  • corrFlagSet

  • cos

  • cosh

  • decRound

  • exp

  • exp10

  • frac

  • log10

  • logN

  • power

  • round

  • sin

  • sinh

  • tan

  • tanh

  • trunc

Miscellaneous

  • beep

  • classIdGet

  • dimOf

  • getPrefix

  • max

  • maxInt

  • min

  • minInt

  • newGuid

  • setPrefix

  • sleep

  • systemDateget

  • systemDateset

Reflection

  • fieldId2Name

  • fieldId2PName

  • fieldName2Id

  • indexId2Name

  • indexName2Id

  • refPrintAll

  • tableId2Name

  • tableId2PName

  • tableName2Id

  • typeOf

Session

  • curExt

  • curUserId

  • getCurrentPartition

  • getCurrentPartitionRecId

  • SessionId

  • funcName

  • prmIsDefault

  • runAs

String

  • match

  • strAlpha

  • strCmp

  • strColSeq

  • strDel

  • strFind

  • strFmt

  • strIns

  • strKeep

  • strLen

  • strLine

  • strLTrim

  • strLwr

  • strNFind

  • strPoke

  • strPrompt

  • strRem

  • strRep

  • strRTrim

  • strScan

  • strUpr

  • subStr