cancel
Showing results for 
Search instead for 
Did you mean: 

Can anybody tell me how to show values based on date

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Assuming that DATE is a select option in the selection screen which is in reference with SY-DATUM, u can direclty use it in select statement in order to avoid all the processing of filteration.

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

<b>AND A~BUDAT IN DATE</b>

AND C~MHDHB <> ' '

OR C~MHDRZ <> ' '

AND sgtxt eq ' '.

loop at itab.

write : / itab-budat,itab-sgtxt,itab-werks,itab-matnr,itab-erfmg201.

endloop.

andreas_mann3
Active Contributor
0 Kudos

Hi Mave,

try that:

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 a~mblnr = b~mblnr INNER JOIN mara AS c ON b~matnr = c~matnr
       WHERE werks IN site
         AND b~matnr IN article
         AND budat IN date
         AND ( c~mhdhb <> ' '
          OR c~mhdrz <> ' ' ).

i've set parenthesis - i think you mean it in this way ?

Andreas

Former Member
0 Kudos

Mave,

You have not included the WHERE condition for the DATE in the select statement.

I am not sure if you have removed that because its not working. If that is the case can you tell us which of these tables has the field BUDAT and what is the statement that you have used?

Regards,

Ravi