Skip to Content
author's profile photo Former Member
Former Member

select querry error

Hi,

while debugging values are populating for mkpftbl but not to msegtbl. can anyone suggest where i am going wrong.

if sy-batch = 'X'.

select mblnr mjahr bldat cputm

from mkpf

into table mkpftbl

where bldat eq wtoday

and tcode2 eq ctcode2.

else.

select mblnr mjahr bldat cputm

into table mkpftbl

from mkpf

where mblnr in mblnr

and mjahr in mjahr

and tcode2 eq ctcode2.

endif.

if not mkpftbl[] is initial.

  • loop at mkpftbl.

select zeile charg matnr werks menge

into corresponding fields of table msegtbl

from mseg

  • Appending table msegtbl

for all entries in mkpftbl

where mblnr eq mkpftbl-wmblnr

and mjahr eq mkpftbl-wmjahr

and bwart eq cbwart

and werks eq splant.

*endloop.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 03:50 AM

    Hi Nihi

    W.r.t the code that i have seen yesterday, i guess your MSEGTBL is declared with fiels like wmblnr, wmjahr etc..

    So use <b>into table</b> instead of <b>into corresponding fields of table</b>.

    INTO CORRESPONDING FIELDS OF TABLE will work only when both the field names are same.

    Also note the order shoould be the same.

    Hope this helps you.

    Kind Regards

    Eswar

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Nihi

      Try making the changes as highlighted below:

      <u><b>Declaration:</b></u>
      data: begin of mkpftbl occurs 0,
              <b>wmblnr like mkpf-mblnr, "Material Document Number
              wmjahr like mkpf-mjahr, "Material Document Year
              wbldat like mkpf-bldat, "Document date in document
              wcputm like mkpf-cputm, "Time of Entry</b>
            end of mkpftbl.
      
      data: begin of msegtbl occurs 0,
      <b>        wmblnr like mseg-mblnr, "Material Document Number
              wmjahr like mseg-mjahr, "Material Document Year
              wzeile like mseg-zeile, "Item in Material Document
              wmatnr like mseg-matnr, "Material number
              wwerks like mseg-werks, "plant
              wcharg like mseg-charg, "batch number
              wmenge like mseg-menge, "Quantity
              wbldat like mkpf-bldat, "Document date in document
              wcputm like mkpf-cputm, "Time of Entry</b>
            end of msegtbl.
      
      <u><b>Routine For Extraction:</b></u>
      data: wrecord type i.
      data: wtime type t.
      data: wtoday type d.
      
      move sy-datum to wtoday.
      move sy-uzeit to wtime.
      
      if wtime eq '000000'.
        wtoday = wtoday - 1.
      endif.
      
      status = 1.
      if sy-batch = 'X'.
        select mblnr mjahr bldat cputm
        from mkpf
        into table mkpftbl
        where bldat eq wtoday
        and tcode2 eq ctcode2.
      else.
        select mblnr mjahr bldat cputm
        into table mkpftbl
        from mkpf
        where mblnr in mblnr
        and mjahr in mjahr
        and tcode2 eq ctcode2.
      endif.
      
      if not mkpftbl[] is initial.
        select <b>mblnr mjahr zeile matnr werks charg menge</b>
        from mseg
        <b>into table msegtbl</b>
        for all entries in mkpftbl
        where mblnr eq <b>mkpftbl-wmblnr</b>
        and mjahr eq <b>mkpftbl-wmjahr</b>
        and bwart eq cbwart
        and werks eq splant.
        status = 0.
      endif.

      Hope this helps you.

      Kind Regards

      Eswar

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 03:47 AM

    Hi,

    In the for all entries..use mkpftbl-mblnr instead of mkpftbl-wmblnr..same for mjahr..

    for all entries in mkpftbl

    where mblnr eq <b>mkpftbl-mblnr</b>

    and mjahr eq <b>mkpftbl-mjahr</b>

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 03:48 AM

    Hi Nihi,

    chk if there are any entries in mseg with the select criteria u had mentioned...ur select statement looks ok

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 16, 2006 at 03:52 AM

    Hi,

    Check in SE11 whether there exists record in mseg table which satisfies the condition

    where mblnr eq mkpftbl-wmblnr

    and mjahr eq mkpftbl-wmjahr

    and bwart eq cbwart

    and werks eq splant.

    Or another easiest way is to command the conditions in where clause one by one and find out which one is not satisfied.Then try in SE11,for the condition.

    Moreover as mentioned,<i>into corresponding fields</i> will work only if the field name matches.

    Message was edited by: Jayanthi Jayaraman

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.