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: 

Query - Standard Price Difference Between two periods

antonio_bruno
Participant
0 Kudos
174

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

3 REPLIES 3

Former Member
0 Kudos
129

Hi ,

you can check tables S031/32....ref standard report. MC.9

regards

Prabhu

0 Kudos
129

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

0 Kudos
129

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