How to query a item stock quantity for a given date
Hi there,
I need to query the stock quantity of an item for a given date. For example, i want to know how many pieces of A i have on stock at the 20th of march 2009.
I know there is a report, but i need the value for a subquery.
Regards Steffen
Sorry Gordon,
Your query is not wrong, far from me to insult your work. It does indeed make full sense if the business process allows the item description to change.
If not, we can avoid a "inner join" = smaller, cleaner and (theoritically) faster query
Here is your code with the little review:
SELECT T0.ItemCode, T0.Dscription, sum(T0.InQty - T0.OutQty) as 'On Hand'
FROM DBO.OINM T0
WHERE T0.DocDate <= '[%0]' and T0.ItemCode = '[%1]'
GROUP BY T0.ItemCode, T0.Dscription
Cheers
tested on 2007 SP00 PL46
Similar Messages
-
Plant Stock details for a given date
At present we are using MB52 for latest stock position of a plant. Is there any code for getting stock details for earlier date.
As we are facing lot of problems while audits....Hi
Please check the following link
Re: No stock showing in Inventory on date stock report
Cheers
Chandra -
How to store beyond the range value for a given data type!!!
Hi all,
I want to know.Is it possible to create a new data type like int,float in java. which can store any number without any range restrictions.As you know the range of byte data type is -128 - + 127.I don't want any range restrictions.The data type should be able to grow dynamically.
Regards!!
Tameshwar SahuThe only solution I can think of is to use java objects, Im not sure youll be able to create a new primitive for java !!
Youd have to put together Integers, posibly in a vector depending on how HUGE a number youd like to create.
If you reached the max of one, add another to the vector. and then continue with the next.. The problem with this of course is the fact that math operations, will be a bit of a challenge to code. also actuall representation of the value would be a bit tricky as well !! There are however ways to go about this, you just have to think about it a little. -
How to get the item stock for a date
Hi all
I need to get the item stock quantity on a date, but i don´t know if i can get it from a table or if i have to make a query to calculate it from the documents´lines. If you can help me please reply this post.
ThanksDo you already know of table OINM (Warehouse table) - it is not documented in SAP-BO references?
This table contains entries for each movement in stocks of your system. Here are some examples of fields in this table:
BASE_REF document number of document affecting OITW.OnHand
DocDate date of this document
ItemCode Item of which the stock quantity is changed
Dscription name of item
Warehouse affected stock
InQty number of items added into stock (OITW.OnHand is increased)
OutQty number of items taken from stock (OITW.OnHand is decreased)
TransType type of booking (see below)
Balance this is NOT the OITW.OnHand at the date of this booking;
it's something like the cumulated stock value in some currency
To calculate the OnHand-value at a date of any of these bookings you have to
sum up the incoming/outgoing quantities, e.g. (z.B. SUM(InQty) - SUM(OutQty)).
Relation between the type of booking and the values in InQty / OutQty:
++ InQty/OutQty contain the number of items added to/taken from the stock;
the number complies to the value OITW.OnHand is increased/decreased;
-- doesn't affect stock (InQty/OutQty = 0)
? missing documentation
TransType InQty OutQty
-2 ++ -- opening balance
13 -- -- outgoing invoice
13 -- ++ outgoing invoice without previous delivery note
15 -- ++ delivery note
18 -- -- incoming invoice
20 ++ -- incoming delivery note
58 ? ? inventory
59 ++ -- stock receipt (without purchasing transactions)
60 -- ++ goods issue (without sales transactions)
67 -- ++ transfer between stocks
67 ++ -- transfer between stocks
I hope that I got your question right and that my hints will help you!
Frank -
Hi experts . how can we know the stock details for a perticular plant?
hi experts . how can we know the stock details for a perticular plant
check this code
REPORT YSG_MATSTK_REP LINE-SIZE 220
LINE-COUNT 50(5).
*& DATA DECLARATION *
TABLES: MARA, "GENERAL MASTER DATA
MARC, "PLANT DATA FOR MATERIAL
MARD, "STORAGE LOCATION DATA FOR MATERIAL
MBEW, "MATERIAL VALUATION
MVKE, "SALES DATA FOR MATERIAL
MAKT. "MATERIAL DESCRIPTION
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,"MATERIAL NUMBER
MBRSH LIKE MARA-MBRSH,"INDUSTRY SECTOR
MEINS LIKE MARA-MEINS,"BASE UNIT OF MEASURE
END OF I_MARA.
DATA: BEGIN OF I_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,"MATERIAL NUMBER
WERKS LIKE MARC-WERKS,"PLANT
LVORM LIKE MARC-LVORM,"FLAG MATERIAL FOR DELETION AT PLANT
"LEVEL
PSTAT LIKE MARC-PSTAT,"MAINTENANCE STATUS
DISPO LIKE MARC-DISPO,"MRP CONTROLLER
END OF I_MARC.
DATA: BEGIN OF I_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,"MATERIAL NUMBER
MAKTX LIKE MAKT-MAKTX,"MATERIAL DESCRIPTION
END OF I_MAKT.
DATA: BEGIN OF I_MVKE OCCURS 0,
MATNR LIKE MVKE-MATNR,"MATERIAL NUMBER
VKORG LIKE MVKE-VKORG,"SALES ORGANIZATION
VTWEG LIKE MVKE-VTWEG,"DISTRIBUTION CHANNEL
END OF I_MVKE.
DATA: BEGIN OF I_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,"MATERIAL NUMBER
LGORT LIKE MARD-LGORT,"STORAGE LOCATION
LABST LIKE MARD-LABST,"VALUATED STOCK WITH UNRESTRICTED USE
END OF I_MARD.
DATA: BEGIN OF I_OUT OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
LVORM LIKE MARC-LVORM,
PSTAT LIKE MARC-PSTAT,
DISPO LIKE MARC-DISPO,
MBRSH LIKE MARA-MBRSH,
MEINS LIKE MARA-MEINS,
MAKTX LIKE MAKT-MAKTX,
VKORG LIKE MVKE-VKORG,
VTWEG LIKE MVKE-VTWEG,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
END OF I_OUT.
DATA : TOT TYPE I. " TOT - TOTAL TO PRINT STOCK
*& S E L E C T I O N - S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-100.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY.
PARAMETERS: P_WERKS LIKE MARC-WERKS OBLIGATORY.
SELECT-OPTIONS: S_LGORT FOR MARD-LGORT,
S_DISPO FOR MARC-DISPO.
SELECTION-SCREEN END OF BLOCK B1.
*& I N I T I A L I Z A T I O N *
INITIALIZATION.
S_MATNR-SIGN = 'I'.
S_MATNR-OPTION = 'EQ'.
S_MATNR-LOW = 'M-14'.
S_MATNR-HIGH = 'M-18'.
P_WERKS = '3000'.
S_LGORT-SIGN = 'I'.
S_LGORT-OPTION = 'EQ'.
S_LGORT-LOW = '0001'.
S_LGORT-HIGH = '0004'.
S_DISPO-SIGN = 'I'.
S_DISPO-OPTION = 'EQ'.
S_DISPO-LOW = '001'.
S_DISPO-HIGH = '002'.
APPEND S_DISPO.
APPEND S_LGORT.
APPEND S_MATNR.
CLEAR S_DISPO.
CLEAR S_LGORT.
CLEAR S_MATNR.
*& S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
SELECT MATNR WERKS LVORM DISPO FROM MARC
INTO CORRESPONDING FIELDS OF TABLE I_MARC
WHERE WERKS EQ P_WERKS
AND MATNR IN S_MATNR
AND DISPO IN S_DISPO
AND WERKS = P_WERKS.
IF I_MARC[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARC'.
EXIT.
ENDIF.
SELECT MATNR LGORT LABST FROM MARD INTO TABLE I_MARD
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR
AND WERKS EQ P_WERKS
AND LGORT IN S_LGORT.
IF I_MARD[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARD'.
EXIT.
ENDIF.
SELECT MATNR VKORG VTWEG FROM MVKE INTO TABLE I_MVKE
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR.
IF I_MVKE[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MVKE'.
EXIT.
ENDIF.
LOOP AT I_MARC.
MOVE-CORRESPONDING I_MARC TO I_OUT.
CLEAR MARC.
SELECT SINGLE MATNR MBRSH MEINS FROM MARA
INTO CORRESPONDING FIELDS OF MARA
WHERE MATNR = I_OUT-MATNR.
IF SY-SUBRC = 0.
MOVE: MARA-MBRSH TO I_OUT-MBRSH,
MARA-MEINS TO I_OUT-MEINS.
ELSE.
CONTINUE.
ENDIF.
SELECT SINGLE MATNR MAKTX FROM MAKT
INTO CORRESPONDING FIELDS OF MAKT
WHERE MATNR = I_OUT-MATNR.
IF SY-SUBRC = 0.
MOVE: MAKT-MAKTX TO I_OUT-MAKTX.
ELSE.
CONTINUE.
ENDIF.
LOOP AT I_MARD WHERE MATNR = I_MARC-MATNR.
MOVE: I_MARD-LABST TO I_OUT-LABST,
I_MARD-LGORT TO I_OUT-LGORT.
APPEND I_OUT.
ENDLOOP.
LOOP AT I_MVKE WHERE MATNR = I_MARC-MATNR.
MOVE: I_MVKE-VKORG TO I_OUT-VKORG,
I_MVKE-VTWEG TO I_OUT-VTWEG.
APPEND I_OUT.
ENDLOOP.
CLEAR I_OUT.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\matstk.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = I_OUT.
*& T O P - O F - P A G E *
TOP-OF-PAGE.
WRITE:/ 'DATE:' ,SY-DATUM.
*& E N D - O F - P A G E *
END-OF-PAGE.
WRITE: / SY-ULINE,
/100 'PAGNO: ',SY-PAGNO,
SY-ULINE.
*& E N D -- O F -- S E L E C T I O N *
END-OF-SELECTION.
LOOP AT I_OUT.
AT FIRST.
WRITE :/ 'MATERIAL EXTRACTION REPORT',
SY-ULINE.
ENDAT.
WRITE:/ SY-VLINE,
I_OUT-MATNR,SY-VLINE,
I_OUT-MEINS,SY-VLINE,
I_OUT-WERKS,SY-VLINE,
I_OUT-LVORM,SY-VLINE,
I_OUT-PSTAT,SY-VLINE,
I_OUT-DISPO,SY-VLINE,
I_OUT-MBRSH,SY-VLINE,
I_OUT-MAKTX,SY-VLINE,
I_OUT-VKORG,SY-VLINE,
I_OUT-VTWEG,SY-VLINE,
I_OUT-LGORT,SY-VLINE,
I_OUT-LABST,SY-VLINE.
TOT = TOT + I_OUT-LABST.
AT NEW MATNR.
WRITE : 'NEW RECORD',
SY-VLINE.
ENDAT.
AT END OF LABST.
WRITE : 'STOCK = ',
TOT,
SY-VLINE,
SY-ULINE.
ENDAT.
AT LAST.
FORMAT COLOR 7 INTENSIFIED OFF.
WRITE : /159 'TOTAL STOCK = ',
TOT.
ENDAT.
ENDLOOP.
WRITE : /159 'TOTAL STOCK = ',
TOT.
regards,
srinivas
<b>*reward for useful answers*</b> -
Custom Report for the Stock and Stock value for a specific date
Hi SAP Gurus,
Is there any SAP standard t-code or any logic to get the transcations (additions (for example: Purchases) and subtractions (Sales) to the inventory) for a particular materials in a plant and with Total Stock and also Total Stock value when that particular transaction happened?
Our system is R/3 4.7
I looked at the MB5B, MBCE, MBCA, MC44, MB51 and some other standard T-codes but could not find the total stock value at the time of Transaction happened.
The history tables MBEWH and MARDH are updated after the month end closing procedures, right, which means I will have the inventory value changing every month if material has Price "S".
Thank you,
-HarterHi Harter,
Unfortunately, you cannot see in a single tcode the value of stock and stock quantity on a specific date. As you yourself have pointed out, we only have to make use of the history table MBEWH, MARDH for the month wise stock quantity and value. Along with that you should also make use of the table MBEW to take teh stock quantity and value. So the total value of stock on a particular date will be
Stock qnty = MBEWH value until the previous month (for teh specific valuation class, period etc) + MBEW value for the present date.
But this will nto work out if you want to find out teh stock quantity and stock value on a past date basis. For past data, only m onthwise data is available. For this anyway you can refer to MC.1 and so on reports. -
R12: How to filter Open Item Revaluation Report based on GL Date
Hi,
Anybody know how to filter Open Item Revaluation Report based on GL Date from and GL Date to in R12?
Since we just upgraded from 11.5.10 to 12.1.3 and found we cannot filter those report for specific date. It shown all data included the old data from 8 years ago also.
We need to run the report only for specific date only. Please share with me if anyone know about this.
Thanks.Pl do not post duplicates - R12: How to filter Open Item Revaluation Report based on GL Date
-
How to get start date of the period for a given date from cube
I have a situation where i need to find the start day of the period for a given date. is there a way to know that. i want to use that in my report. i enter the date from my report(i have date parameter), depends on the date, i want to display the start day
of the period. how can i write expression for that in my report?
ramHi ramprasad74,
According to your description, you are using Analysis Services as a data source for the report, the cube has hierarchy: Fyear, FQuarter, FPeriod, fweek, Fdate. You want to add a date parameter to the report, after you changed value of the parameter, the
report will return the first day of FPeriod.
To achieve your goal, we need to add a parameter to the report, then use the parameter in mdx query. For detail information, please refer to the following steps:
In the Report Data pane, right-click on a dataset created from a SQL Server Analysis Services data source type, and then click Query. The MDX query designer opens in Design mode.
On the toolbar, click Design to toggle to Query mode.
On the MDX query designer toolbar, click Query Parameters symbol. The Query Parameters dialog box opens.
In the Parameter column, click <Enter Parameter>, and then type the name of a parameter.
In the Dimension column, choose a value from the drop-down list.
In the Hierarchy column, choose a value from the drop-down list.
In the Default column, from the drop-down list, select a single value.
Click OK.
In query designer dialog box, type the mdx query like below:
with member [Measures].[FirstChild]
as
[Date].[Fiscal].currentmember.parent.firstchild.name
select {[Measures].[FirstChild]} on 0,
[Date].[Fiscal].[Date].members on 1
from
( SELECT ( STRTOSET(@ParameterName, CONSTRAINED) ) on 0
from
[Cube]
Here are relevant threads you can reference:
https://social.msdn.microsoft.com/forums/sqlserver/en-US/c7146ac3-40ea-4d53-b321-c707aebbd405/how-to-pass-date-parameter-to-mdx-query
https://social.msdn.microsoft.com/forums/sqlserver/en-US/fd12a865-bc90-4a65-af42-ce38a8cfa29b/pass-date-time-parameter-to-mdx-query-ssrs
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here. -
Block stock calculation from mseg table for any given date.
I am calculating stock from mseg table for any given date. Not just month end stock or current stock. It could be back date also. It is tallying also with MB5B stock report of that date. Now I have to bifurcate that stock into unrestricted stock, quality stock and block stock.
I have checked INSMK and ZUSTD field in mseg table, but could not concluded. Should I check movement type wise? Block/ Quality stock could be transferred into unrestricted stock also. That also I have to take care.
Can anyone clearly explain how the stock type posting takes place in mseg table when goods receipt as block / quality stock and when the same goods transferred in unrestricted stock, what are the reference indication.DATA : LIST_TAB TYPE TABLE OF ABAPLIST.
DATA: BEGIN OF VLIST OCCURS 0,
FIELD1(5) TYPE C,
FIELD2(19) TYPE C,
FIELD3(16) TYPE C,
FIELD4(17) TYPE C,
FIELD5(25) TYPE C,
FIELD6(24) TYPE C,
FIELD7(25) TYPE C,
FIELD8(25) TYPE C,
END OF VLIST.
TYPES : BEGIN OF ITAB,
MATNR(18) TYPE C,
WERKS(5) TYPE C,
END_MENGE(20) TYPE C,
END OF ITAB.
DATA : ITAB TYPE STANDARD TABLE OF ITAB WITH HEADER LINE,
WA_TAB TYPE ITAB.
----submit command to run mb5b in the background and -
----push the data into an internal table -
" Calling MB5B for displaying the Closing Stock
SUBMIT RM07MLBD USING SELECTION-SCREEN '1000'
WITH DATUM BETWEEN S_DATE-LOW AND S_DATE-HIGH
WITH MATNR IN S_MATNR WITH WERKS IN S_WERKS
WITH BWART-LOW = '601' EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LIST_TAB
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = VLIST
LISTOBJECT = LIST_TAB
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
LOOP AT VLIST WHERE FIELD1 CS '|'.
CHECK SY-TABIX GE 4.
MOVE : VLIST-FIELD1+1(4) TO ITAB-WERKS,
VLIST-FIELD2+1(18) TO ITAB-MATNR,
VLIST-FIELD8 TO ITAB-END_MENGE.
APPEND ITAB.
ENDLOOP.
This is the program to call MB5B and the standard program and use the following settings for the closing stock opening stock and block stock -
How to get the date of first day of a week for a given date
Hi gurus
can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
Thanks
RavHi,
The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
RP_CALC_DATE_IN_INTERVAL
Regards,
Durgesh. -
How can i find differnet output types for a given sales order ?
hi all,
answer my question please........?
how can i find differnet output types for a given sales order ?hi
check in NACO transaction if you have assigned access sequence to your output ytpes and if you have ticked checkbox "Access to output conditions" - otherwise it will not even try to access condition records.
From help :
Access to output conditions
Indicates whether the system determines the output by searching for valid
condition records.
Procedure
If you want the system to search condition records for the appropriate
output, mark the field.
Note
If you leave the field blank and if you are processing sales, shipping,
or billing documents, the system automatically determines output from
information stored in the customer master record.
regards
ravish
<b>plz reward points if helpful</b> -
C Programming: How can we get the filesystem name for a given file-path?
C Programming: How can we get the filesystem name for a given file-path?
Say I have a filepath=/mnt1/file1
Using some OS API like stat, can I get the Filesystem /mnt ?
Thanks in advance,
-VEnter the command up to the point of entering the file path and add a space, then drag the file into the terminal window. It will fill out the path.
If you need to go further into the contents of the Application package, you can continue with /Contents...
Another way is to start typing and then hit Tab to auto-complete. It will stop where it can't determine the next letter.
So, type /App tab and it will fill in /Applications. Type a / and start with the name of the app, then tab and it should complete. Continue till you have the correct path.
Spaces will be replaced with \<space>, so, App Store would end up as /Applications/App\ Store.app -
How do you prepare a PDF file for 4 signatures & dates?
How do you prepare a PDF file for 4 signatures & dates?
Hi,
You can achieve this by using text tags. EchoSign Text Tags are specially formatted text that can be placed anywhere within the content of your
document specifying the location, size, type of fields such as signature and initial fields, check boxes, radio buttons and form fields, and advanced optional field processing rules. Text Tags can also be used as names of PDF Form fields.
Text Tags are converted into EchoSign form fields when the document is sent for signature or uploaded to the EchoSign Document Library. EchoSign Text Tags can be placed in any document type such as PDF, Microsoft Word, PowerPoint, Excel and text files (.txt, .rtf)
Please refer to page 5 ( date) and 10 (signature) of the Creating Adobe Echosign Forms With Text Tags.The document can be found here
Thanks,
Jat -
How to get the week number for a given date?
hi guys,
what is coding to get the week number for a given date?
For example, 1/1/05 is week 1. then 8/1/05 is week 2.The second parameter to pass to the method is supposed to be one of the month constants JANUARY - DECEMBER. It happens to be that their numerical values are 0-11, not 1-12, so your "12" refers to the "13th" month of the year.
givenDate = new GregorianCalendar(2003, Calendar.DECEMBER, 31);
If you want to construct dates and times from strings like you seem to be, look into SimpleDateFormat http://javaalmanac.com/egs/java.text/ParseTime.html
(even still I got WEEK_OF_YEAR as 1 which is true but not really what I expected, excuse my previous reply but I wanted to check the facts before posting this) -
How to find the Day on a Week for any given Date
Hi..... I need your help to find out the Day on a Week for any given Date .
Say if the Date is 31/12/2009 , what would be the Day on a Week for this Date.
Are there any fucntions available to determine the same?
Please let me know....Thanks in Advance
Regards
SmitaHi ,
You can using the following peice of code to get the Day of a Week for the given date :
Calendar now = Calendar.getInstance();
System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1)
+ "-" + now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
//create an array of days
//Day_OF_WEEK starts from 1 while array index starts from 0
String[] strDays = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thusday", "Friday", "Saturday" };
String day_of_week = strDays[now.get(Calendar.DAY_OF_WEEK) - 1];
System.out.println("Current day is : " + strDays[now.get(Calendar.DAY_OF_WEEK) - 1] );
Edited by: Ritushree Saha on Jun 4, 2009 1:09 PM
Maybe you are looking for
-
I cannot update my ipad2 to ios5. Updating through iTunes on pc Windows Vista, Error message reads "cannot connect to iPad Software Update Server. Tried resetting network settings, still not connecting. Tried updating iTunes, still not connecting.
-
Ok, so now that i've finished the project i've been working on forever (a 3 min videoclip w/tons of effects), i wonder what my best move is. I'm looking to do 2 things with it 1)Project it publically on a big screen, so i need the best quality possib
-
C# Wrapper for Berkeley Db is not ptting proper key and data values
Hi All, I am using C# wrapper for Berkeley Db which is available at sourceforge.net. Now when i am putting an integer as key value, it returns keysize as 9, instead of returning 4. That C# Wrapper contains a serialzing class called BDBFormatter which
-
Can't install Nokia Podcasting application on the ...
Is Nokia Podcasting compatible with the N86? Always get an error when installing it. If not, what other Podcasting applications are available? Thanks Solved! Go to Solution.
-
Hi All, We Have BOBJ 4.1 SP05 Edge edition and Dashboard(Xcelsius) 4.1. What is Dashboard manager how can i install dashboard manager or can i use Dashboard itself. Can some one tell me how can i install dashboard manager.