12-09-2008 8:58 AM
Hi There,
I need to do a selection at the table MARD for the checking the current stock at storage location, but there is a problem. In the table MARD there are stock values also for previous period.
Can you please tell me haow I can do the selection on current date?
For example If I want to get the current stock I need to fill in also the curent year and month. How can I write a selection, where the year and month will be copied from the system date.
SELECT * FROM MARD WHERE ( MATNR IN MATNR ) AND
( LGORT IN LGORT) AND
( WERKS IN WERKS ) AND
***********LFGJA is the year taken from the current date '2008' AND
***********LFMON is the month taken from the current date '12'
Thanks in advance for your help,
BR
Saso
12-09-2008 9:07 AM
HI,
try this....
data:
Year type char4,
month type char2.
year = sy-datum(4).
month = sy-datum+4(2).
SELECT * FROM MARD WHERE ( MATNR IN MATNR ) AND
( LGORT IN LGORT) AND
( WERKS IN WERKS ) AND
***********LFGJA EQ year AND
***********LFMON EQ month.
12-09-2008 9:02 AM
12-09-2008 9:16 AM
Hi Saso
You can this approach for you case -
Select * into table it_mard
from mard
where matnr in s_mat
and LFGJA = sy-datum(4)
and LFMON = sy-datum+4(2).
Thanks
12-09-2008 9:04 AM
Hi,
Just declare two variables of integer type and store the value of current year and month
and put thes var in your select statement.
Just check this code snippet.
DATA: year TYPE i,
month TYPE i.
year = sy-datum(4).
month = sy-datum+4(2).
SELECT * FROM MARD
WHERE ( MATNR IN MATNR ) AND ( LGORT IN LGORT)
AND ( WERKS IN WERKS ) AND LFGJA = year
AND LFMON = month.
Thanks
Nitesh
12-09-2008 9:04 AM
12-09-2008 9:05 AM
hi
use below query
data : v_year type LFGJA ,
v_date type LFMON.
v_year = sy-datum+4(4).
v_date = sy-datum+2(2).
SELECT * FROM MARD WHERE ( MATNR IN MATNR ) AND
( LGORT IN LGORT) AND
( WERKS IN WERKS ) AND
LFGJA EQ v_year and
LFMON EQ v_date.
clear : v_year, v_date.
12-09-2008 9:06 AM
Hi,
you can use the following logic.
year = sy-datum+0(4)
mon = sy-datum+4(2).
-Raj
12-09-2008 9:07 AM
HI,
try this....
data:
Year type char4,
month type char2.
year = sy-datum(4).
month = sy-datum+4(2).
SELECT * FROM MARD WHERE ( MATNR IN MATNR ) AND
( LGORT IN LGORT) AND
( WERKS IN WERKS ) AND
***********LFGJA EQ year AND
***********LFMON EQ month.
12-09-2008 9:24 AM
hi,
The fields LFGJA and LFMON are fiscal year and period, so pass the current date that is sy-datum to
funtion module FTI_FISCAL_YEAR_MONTH_GET.
pass company code (BUKRS) and budat (date) say current date 12/9/2008
u will get current fiscal year and period..
based on the above values write a select statement..
our frnds gave the select stmt...u can make use of it..
Rgds.,
subash