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

Need help reading an internal table

Howdy,

I have an internal table (itab_knvh) that contains all the entries from table KNVH for a specified sales area.

Now I have another internal table (itab_kunnr) that contains all the customers that I need data for.

How can I read all the entries from itab_knvh where the 'date from' value (datab) is greater than today's date?

At the moment I have:

<b> LOOP AT itab_kunnr.

<i>READ TABLE itab_knvh WITH KEY kunnr = itab_kunnr-kunnr.</i>

IF sy-subrc = 0.

IF itab_knvh-datab GE p_validh.

WRITE:/ itab_kunnr.

ENDIF.

ENDIF.

ENDLOOP.</b>

but I don't think this will work if more than one customer entry exists in itab_knvh.

So is there a way of writing:

READ TABLE itab_knvh WITH KEY kunnr = itab_kunnr-kunnr

datab GE sy-datum.

Any ideas???

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 12:31 PM

    Thansk for the help.

    Unfortuantely the logic routines that you stated caused duplicate entries to appear - but his is mostly due to me not explainging my problem properly.

    anyhow If someone could explain how to do the following then that would be really great:

    I just need to pass the values from a select into fields of an internal table (whose names i am not allowed to chnage):

    currently I have :

    <b>if sy-subrc ne 0.

    select single hkunnr datab hzuor from knvh

    (itab_hier_output-old_datab

    itab_hier_output-old_kunnr

    itab_hier_output-old_hzuor)

    where kunnr = itab_kunnr-kunnr

    and datbi = itab_hier_output-new_datab.

    endif.</b>

    but this doesn't work...

    Anyone got any ideas....

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Steve,

      If you have written <i>exactly</i> the same SELECT statement as you have posted here, then it is in error.

      Try this one out, instead.

      select single hkunnr 
                    datab 
                    hzuor  
               from knvh 
               into (itab_hier_output-old_kunnr,
                     itab_hier_output-old_datab,
                     itab_hier_output-old_hzuor)
              where kunnr = itab_kunnr-kunnr
                and datbi = itab_hier_output-new_datab.

      Regards,

      Anand Mandalika.

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 11:30 AM

    Hi Steve,

    You can use this instead of the read statement.

    loop at itab_knvh where kunnr = itab_kunnr
                            datab gt sy-datum.
      exit.
    endloop.
    if sy-subrc eq 0.
      write itab_kunnr.
    endif.

    Regards,

    Anand Mandalika.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 11:40 AM

    Hey Steve,

    I guess you could choose to reverse the loops as well.

    loop at itab_knvh where datab gt sy-datum.
      read table itab_kunnr with key itab_kunnr eq itab_knvh-kunnr 
                                     transporting no fields.
      if sy-subrc eq 0.
        write: / itab_knvh-kunnr.
      endif.
    endloop.

    What say ?

    Regards,

    Anand Mandalika.

    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.