Skip to Content
author's profile photo Former Member
Former Member

Read Stock out of history tables (e.g. mardh, mskah)


I have to write a program, that lists stock by a user-selected period (for example stock for material 4711 per period 2004/11).

The data is stored in the tables mard and mardh (or in my special case it is Sales-Order-Stock out of tables mska and mskah).

The History-Tables (MxxxH) store their data in a way, that makes sql-select difficult - to me.


MARDH for MATNR 4711 / WERKS 0001 / LGORT 0001


2004 8 10

2004 9 20

2005 1 5

The Stock for period 2004/11 is 20 (it has been the same since 2004/9).


- Is there Function module (i didn't find one)?

- Has anybody written a similar program?

- Does anybody know a "smart" SQL-Command?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Feb 24, 2005 at 09:18 AM

    Hi Jürgen,

    maybe not 'smart', but at least only one select:

      SELECT ... FROM mardh
            UP TO 1 ROWS
            WHERE matnr = sel_matnr
             AND  werks = sel_werks
             AND  lgort = sel_lgort
             AND  lfgja LE sel_lfgja
             AND  lfmon LE sel_lfmon
             ORDER BY lfgja DESCENDING lfmon DESCENDING.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.