Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to use SQL to get release production ItemId different unit

Posted on by 305

Hello,

I need to search the AX 2012 ItemId unit (include purch.united, Sales.United, Invent.United, Invent.CountingUnitIed, InventTable.BomUnited) and get have different unit of the ItemId.

I use SQL had problem:

I found AX 2012:

INVENTTABLEMODULE use field MODULETYPE: 0(Invent), 1(purch), 2(Sales) ,

and have field UnitId , CountingUnitId and

InventTable have BOMUnitId

My SQL:

select IT.ITEMID , ITM.MODULETYPE ,ITM.UNITID ,ITM.COUNTINGUNITID ,IT.BOMUNITID
from ECORESPRODUCTTRANSLATION as ET left join (INVENTTABLE as IT left join INVENTTABLEMODULE as ITM on IT.ITEMID=ITM.ITEMID) on IT.PRODUCT=ET.PRODUCT AND ET.LANGUAGEID = 'en-us'
where ITM.UNITID <> ITM.COUNTINGUNITID or ITM.UNITID<>IT.BOMUNITID OR ITM.COUNTINGUNITID<>IT.BOMUNITID
order by IT.ITEMID DESC

Please help fix it to right.

Thanks in advance.

Br, Jen

*This post is locked for comments

  • ATMA-Jen Profile Picture
    ATMA-Jen 305 on at
    RE: How to use SQL to get AX 2012 release production ItemId different unit

    Hello MATTGUO,

    Very helpful.

    Thank you.

    Br, Jen

  • Verified answer
    MATTGUO Profile Picture
    MATTGUO 22,306 on at
    RE: How to use SQL to get AX 2012 release production ItemId different unit

    Hi ATMA-Jen,

    In my environment, have no COUNTINGUNITID field, so i delete it from sql query.

    SQL QUERY:

    select a.itemid,
    max(case a.MODULETYPE when '0' then a.unitid else '' end) inventunit,
    max(case a.MODULETYPE when '1' then a.UNITID else '' end) purchunit,
    max(case a.MODULETYPE when '2' then a.UNITID else '' end) salesunit,
    a.BOMUNITID from
    (select IT.ITEMID as itemid , ITM.MODULETYPE as moduletype ,ITM.UNITID as unitid,IT.BOMUNITID as BOMUNITID
    from ECORESPRODUCTTRANSLATION as ET left join (INVENTTABLE as IT left join INVENTTABLEMODULE as ITM on IT.ITEMID=ITM.ITEMID) on IT.PRODUCT=ET.PRODUCT AND ET.LANGUAGEID = 'en-us'
    where ITM.UNITID<>IT.BOMUNITID ) as a
    group by a.itemid,a.BOMUNITID

    The blank field means ITM.UNITID=IT.BOMUNITID .

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans