Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

help to make a propper selection on the table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

8 REPLIES 8

GauthamV
Active Contributor
0 Kudos

hi,

check MMBE and MB52 transactions.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

hI,

Don't post duplicate threads it is against the Forum Rules!!!

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi,

you can use the following logic.

year = sy-datum+0(4)

mon = sy-datum+4(2).

-Raj

Former Member
0 Kudos

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.

Former Member
0 Kudos

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