Hi Jepoy,
I hope you can use the view WB2_V_MKPF_MSEG2.
Pass the material, plant and storage location to WB2_V_MKPF_MSEG2 table and get the list of material docs for which BLDAT less than the from date given in selection. Get ( LBKUM_I + MENGE_I ) for the latest CPUDT which is less than the from date given in selection and BUSTW_I not equal to blank. Let the value be A.
Special Case: If there is any entry for which BLDAT less than the from date given in selection and CPUDT greater than or equal to the from date given in selection, get the sum of MENGE_I for all those entries for which and BUSTW_I not equal to blank. Let the value be B.
Opening Stock Qty = A + B
Regards
Rajkumar Narasimman