Skip to Content
author's profile photo
Former Member

Can anybody tell me how to show values based on date

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Oct 04, 2005 at 07:12 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 04, 2005 at 07:36 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 04, 2005 at 07:41 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded