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

Read Table with OR condition

how can i check "OR" condition in: Read table itab with key...

ie, Read Table itab With Key f1 = '1000' or f2 = '5000'.

pls give me the syntax............

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:43 AM

    hiii

    Read Table itab With Key f1 = '1000' .
     
    if sy-subrc NE  0.
     
    Read Table itab With Key f1 = '5000' 
    endif.

    reward if useful

    thx

    twinkal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:42 AM

    Hi

    It can't do it, it needs to replace that statament with LOOP/ENDLOOP

    LOOP AT ITAB WHERE F1 = '1000'
                                   OR F2 = '5000'.
        EXIT.
    ENDLOOP.

    If you insert the EXIT into the loop, that statament will be like READ TABLE

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:43 AM

    Hi,

    You can use only '=' with read statement.

    So it is best if you use two read statements to achieve your functionality like

    Read Table itab With Key f1 = '1000' .

    If sy-ssubrc eq 0.

    • continue with priocessing

    else.

    Read Table itab With Key f2 = '5000'

    IF sy-subrc eq 0.

    • continue with priocessing

    endif.

    endif..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:43 AM

    Hi,

    you could use:

    LOOP AT itab INTO wa WHERE f1 = '1000' OR f2 = '5000'.
    * Do Something
    ENDLOOP.

    Regards

    Mark-André

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:42 AM

    hiiii

    you can not use OR or AND in READ statement..

    but you can do the same thing differently like below

    Read Table itab With Key f1 = '1000' .
    
    if sy-subrc <> 0.
    
    Read Table itab With Key f1 = '5000' 
    endif.

    it will give you same result as you want to get.

    reward if useful

    thx

    twinkal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:42 AM

    You cant use AND and OR operators in read statement

    better to use if statement

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 07:44 AM

    Hi Babu ,

    I dont think that is possible when you use a read statement.

    Regards

    Arun

    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.