See there is the coding where i am doing wrong
I am getting the data based on article and site but not based on date.
Please check and say where is the fault?
SELECT budat sgtxt B~matnr erfmg hsdat vfdat werks bwart INTO
CORRESPONDING FIELDS OF TABLE ITAB FROM MKPF AS A INNER JOIN MSEG AS B
ON AMBLNR = BMBLNR INNER JOIN MARA AS C ON BMATNR = CMATNR
WHERE WERKS IN SITE AND b~MATNR IN
ARTICLE AND CMHDHB <> ' ' OR CMHDRZ <> ' '.
loop at itab where werks in site and matnr in article .
move itab-budat to jtab-budat.
move itab-bwart to jtab-bwart.
move itab-hsdat to jtab-hsdat.
move itab-vfdat to jtab-vfdat.
move itab-werks to jtab-werks.
move itab-erfmg to jtab-erfmg.
move itab-sgtxt to jtab-sgtxt.
move itab-matnr to jtab-matnr.
append jtab.
endloop.
sort jtab by budat.
delete jtab where sgtxt is initial.
loop at jtab where budat in date.
write : / jtab-budat,jtab-sgtxt,jtab-werks,jtab-matnr,jtab-erfmg201.
endloop.