2012 Jan 16 1:28 PM
Hi,
I've created a query that makes the difference between two standard prices (found in MBEWH).
Unfortunately the query has a limit, because if the initial or the final period (selected for the report) haven't datas, the query does not extract any data.
In these cases the datas, if exist, should be considered in the previous period.
Which program i should insert in the infoset to extract these datas?
Thanks.
Best regards.
Antonio
2012 Jan 18 3:30 AM
Hi ,
you can check tables S031/32....ref standard report. MC.9
regards
Prabhu
2012 Feb 01 9:46 AM
Hi,
i've checked but i didn't find the datas that i need.
I think the only way to find the last standard price in the table MBEWH is:
if there is no value
and if the period is not equal to 1, subtract 1 from the period and looking for new value,
else if the period is equal to 1, subtract 1 to the year and the period becomes equal to 12 and looking for new the value.
I've tried unsuccessfully with the following code in the infoset (i've create the additional field PRSTDIN, and the parameter: ESIN-selected year and PERIN-selected period):
clear: PRSTDIN.
select single stprs from mbewh INTO PRSTDIN
where bwkey = 'Z001'
and lfgja = ESIN
and lfmon = PERIN.
if PRSTDIN = ''.
if PERIN = 01.
clear: PRSTDIN.
ESIN = ESIN - 1.
PERIN = 12.
select single stprs from mbewh INTO PRSTDIN
where bwkey = 'Z001'
and lfgja = ESIN
and lfmon = PERIN.
else.
clear: PRSTDIN.
PERIN = PERIN - 1.
select single stprs from mbewh INTO PRSTDIN
where bwkey = 'Z001'
and lfgja = ESIN
and lfmon = PERIN.
endif.
endif.
Thanks.
Antonio
2012 Feb 21 9:28 AM
Hi,
i've solved with:
- new infoset: view on MBEW.
- create parameters about inital/final period/exercise.
- create additonal field to extract from MBEWH the inital/final standard price with the following code:
TABLES MBEWH.
DATA: mat TYPE mbew-matnr,
div type mbew-bwkey.
CLEAR: PRSTDIN, mat, div.
mat = mbew-matnr.
div = mbew-bwkey.
select single stprs from mbewh INTO PRSTDIN
where bwkey = div
and lfgja = ESIN
and lfmon = PERIN
and matnr = mat.
ES1 = ESIN.
PER1 = PERIN.
if sy-subrc <> 0.
while PRSTDIN = '' AND ESIN > '2009'.
if PERIN = 01.
clear: PRSTDIN.
ESIN = ESIN - 1.
PERIN = 12.
select single stprs from mbewh INTO PRSTDIN
where bwkey = div
and lfgja = ESIN
and lfmon = PERIN
and matnr = mat.
ES1 = ESIN.
PER1 = PERIN.
if sy-subrc = 0.
exit.
endif.
else.
clear: PRSTDIN.
PERIN = PERIN - 1.
select single stprs from mbewh INTO PRSTDIN
where bwkey = div
and lfgja = ESIN
and lfmon = PERIN
and matnr = mat.
ES1 = ESIN.
PER1 = PERIN.
IF sy-subrc = 0.
EXIT.
ENDIF.
endif.
endwhile.
endif.
Thanks.
Best regards.
Antonio