Select Query Help
I trying to write a select query on MBEWH table. , The logic needs to find the first u2018previousu2019 month based on the given inputs.
LINV Count Date = 01/14/2008
MBEWH has entries for Month 6 Year 2008, price = 1.45
Month 3 Year 2008, price = 1.40
Month 12 Year 2007, price = 1.35
Month 11 Year 2007, price = 1.30
The logic needs to select Month 12 Year 2007 with price = 1.35 as it is nearest to LINV Count date.
I have written the below Query but not working as it is taking the month and year as individual values but it should take as combined year and month and should compare it with 200801.
MYEAR = WA_LINV-IDATU(4).
MMONT = WA_LINV-IDATU+4(2).
SELECT LFGJA LFMON VERPR PEINH FROM MBEWH INTO TABLE T_MBEWH WHERE
AND BWKEY = WA_LINV-WERKS
AND LFGJA < MYEAR
AND LFMON < MMONT.
I appreciate if someone can help in getting the correct solution.
data: INPUT_PERIOD LIKE CKMLPP-POPER,
INPUT_YEAR LIKE CKMLPP-BDATJ.
CALL FUNCTION 'CKML_F_GET_PREVIOUS_PERIOD'
INPUT_PERIOD = input_period
INPUT_YEAR = input_year
INPUT_PERIV = 'AL'
PREVIOUS_PERIOD = input_period
PREVIOUS_YEAR = input_year
if sy-subrc = 0.
it_prev-spbup+0(4) = input_year.
it_prev-spbup+4(2) = input_period.
Suresh, Check your INPUT_PERIV = 'AL'
parameter, Dont exactly use this. Change the value. check the customized setup for this value in your system
Go to T009c table and check the "Fiscal Input Variant values" t009c-periv values by clicking f4. give the appropriate value and put in this function module. now it will work.
Santosh Kumar Mukka.