Kamis, 22 Desember 2016

AX : Get Label Enum AX 2012

SysDictEnum InventTransPostingTypeEnum = new SysDictEnum(enumnum(InventTransPostingType) );

InventTransPostingTypeEnum.value2Label(_SID.InventTransPostingType);

Rabu, 21 Desember 2016

AX : Working with dates X++ (https://dynamicsaxed.wordpress.com/2015/06/04/working-with-dates-in-x/)

I was working on some date related functionality the other day during which I discovered some really useful date functions in X++. Some of you might be familiar with some of this already, however it is always good to have a blog post out there that lists them all for future reference. I have also added sample code for the usage of each function.

Initialization

A date variable can be initialized with a date constant. The date literal in X++ has a predefined format i.e. dd\MM\yyyy. Note that backslash is used instead of forward slash and unlike string constants neither single nor double quotes is used.

transDate = 01\01\2015;

today

Returns the date of the machine on which the code is run.

transDate = today();

systemDateGet

Selasa, 20 Desember 2016

Rabu, 14 Desember 2016

Query : Contoh Query Fcuntion SQL Server

create function CustBalanceAsOfTransDatex ( @AsOfDate datetime, @DataAreaID varchar(10) )
returns table
as return (
select a.ACCOUNTNUM, sum(AMOUNTMST - isnull(Terbayar, 0)) as Sisa, cust.CUSTGROUP,dirp.NAME as names
from (

    select   
        ct.*,
        (select sum(SETTLEAMOUNTMST - EXCHADJUSTMENT)
            from CUSTSETTLEMENT cset
            where cset.ACCOUNTNUM = ct.ACCOUNTNUM and cset.TRANSRECID = ct.RECID
                and partition = 5637144576 and DATAAREAID = @DataAreaID
                and cset.TRANSDATE <= @AsOfDate)
                as Terbayar
    from
        (
            select VOUCHER, INVOICE, CLOSED, POSTINGPROFILE, AMOUNTMST, AMOUNTCUR, RECID, ACCOUNTNUM, TRANSDATE
            from CUSTTRANS
            where --AccountNum = 'CUST-C006' and
            partition = 5637144576 and DATAAREAID = @DataAreaID
            and TRANSDATE <= @AsOfDate
            and TransType in (
            0, --None
            2, -- Sales
            15, -- payment
            8, -- cust
            36 -- General Journal
            ) and
            POSTINGPROFILE = 'GEN' and (Closed = '1900-01-01' or Closed > @AsOfDate)
        ) ct
) a inner join CUSTTABLE cust on a.ACCOUNTNUM = cust.ACCOUNTNUM
inner join DIRPARTYTABLE dirp on cust.PARTY = dirp.RECID
where a.AMOUNTMST - isnull(a.Terbayar, 0) <> 0
group by a.ACCOUNTNUM, cust.CUSTGROUP,dirp.NAME
)
go