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

Negative Condition checking in read statement

Hi,

i have table, which i have to read, key on which i am going to read that will be determined dynamically. now i have to check the value for the key field is initial or not. i can't use a loop here as it doesn't allow me to mention where condition field dynamically.

thanks & regards,

prabhu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 26, 2009 at 02:18 PM

    check for the key field beforyour read statement.

    say if the dynamic key field is v_key.

    then you can have the code as

    If v_key is not initial.

    read table I_ITAB into WA_ITAB with key colx = v_key.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Prabhu,

      If your internal table is not too large or if you are not too concerned about the performance, here is a solution for you.

      1) Sort the table by the dynamic column you are interested in using DESCENDING option. (SORT can take variable columns.) This sends intial values to the bottom of the table.

      2) Use READ as you discussed in an earlier post.

      3) If the record has INITIAL for the record that was read, then that means there are no records with non-initial value.

  • author's profile photo Former Member
    Former Member
    Posted on May 26, 2009 at 02:22 PM

    Hello,

    Your key field is decided dynamically.

    You can try read statement,

    
    data: w_field type string.
    
    <condition..>
    w_field = <field>.   "<-- give the field name which you want to check
    
    read table <table> with key (w_field) = <value>.
    
    

    Hope this helps you.

    Regrads,

    Sachinkumar Mehta.

    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.