web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Opening and Closing Stock

(0) ShareShare
ReportReport
Posted on by

i need to find opening and closing quantity through sql any suggest how can i find

*This post is locked for comments

I have the same question (0)
  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    What do you mean by opening and closing quantity exactly? Can you elaborate?

    Best regards

    Ludwig

  • Community Member Profile Picture
    on at

    I NEED TO FIND ONHAND QUANTITY BEFORE FROM DATE FROM INVENTTRANS

  • Community Member Profile Picture
    on at

    OPENING STOCK OF THE PRODUCT DEPENDING UPON FROM DATE SPECIFIED IN THE PARAMETER

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    The only thing that might come close to your requirement is the inventory value report.

    Have you tested whether this report includes all the information that you need?

    Best regards,

    Ludwig

  • Guy Terry Profile Picture
    28,972 Moderator on at

    Hi Muhammad,

    Try (and test) this:

    DECLARE @Company nvarchar(4)

    DECLARE @Date datetime

    DECLARE @Partition bigint

    SELECT @Partition  = Par.RECID FROM dbo.PARTITIONS AS Par WHERE Par.PARTITIONKEY = 'initial'

    SET @Company='USMF'

    SET @Date='2017-01-01 00:00:00.000'

    SELECT IT.ITEMID, sum(ITr.QTY) AS 'Quantity', sum(CASE WHEN ITr.STATUSISSUE = 2 THEN ITr.COSTAMOUNTPHYSICAL WHEN ITr.STATUSRECEIPT = 2 THEN ITr.COSTAMOUNTPHYSICAL ELSE ITr.COSTAMOUNTPOSTED + ITr.COSTAMOUNTADJUSTMENT END) AS 'Value'

    FROM dbo.INVENTTABLE AS IT

     JOIN dbo.INVENTTRANS AS ITr ON IT.PARTITION = ITr.PARTITION AND IT.DATAAREAID = ITr.DATAAREAID AND IT.ITEMID = ITr.ITEMID

     WHERE ITr.STATUSISSUE <=2 and ITr.STATUSRECEIPT <=2 AND ITr.DATAAREAID = @Company AND ITr.PARTITION = @Partition AND ITr.DATEPHYSICAL <= @Date

         GROUP BY IT.ITEMID

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans