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

Comparing two internal tables

Hi,

i have 2 internal tables ITAB & ITAB1.

In loop of ITAB, ITAB1 is looped and it should exit the ITAB1 loop where header of ITAB1 matches with ITAB.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • Posted on Jan 11, 2007 at 11:34 AM

    Loop at itab1.

    Loop at itab2.

    if matches.

    EXIT

    Endloop.

    Endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 11:34 AM
    loop at itab into wa_itab.
      loop at itab1 into wa_itab1..
         if wa_itab1 eq wa_itab.
           exit.
        endif.
     endloop.
    endloop.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 11:34 AM

    Hai

    check the following Code

    LOOP AT ITAB1.

    LOOP AT ITAB2 WHERE FLD =ITAB1-FLD.

    MOVE ITAB2 TO ITAB3.

    APPEND ITAB3.

    ENDLOOP.

    ENDLOOP.

    Regards

    Sreeni

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 11:34 AM

    try to do like this.

    loop at itab.

    read table itab1 with key <fieldname> = itab-<fieldname>.

    if sy-subrc = 0.

    <here record matches>.

    else.

    <no matching records>.

    endif.

    endloop.

    but sorry i didnot get your exact requirement. check whether it is working or not?

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 11:35 AM

    Hi Darshan,

    Use <b>EXIT</b> statement to come out of the LOOP..ENDLOOP.

    LOOP AT ITAB.

    LOOP AT ITAB1.

    IF ITAB-<FIELD1> = ITAB1-<FIELD2>.

    EXIT.

    ELSE.

    >>Do some other operation.

    ENDIF.

    ENDLOOP.

    ENDLOOP.

    Thanks,

    Vinay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 11:36 AM

    HI,

    LOOP AT ITAB.

    LOOP AT ITAB1.

    IF itab1-field1 = itab-field1 and

    itab1-field2 = itab-field2 and

    itab1-field3 = itab-field3.

    EXIT. " this will exit from the loop ITAB1

    ENDIF.

    ENDLOOP.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 11:36 AM

    loop at itab into wa1.

    loop at itab1 into wa2.

    if wa2 eq wa1.

    exit.

    endif.

    endloop.

    endloop.

    Award Points

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 12:03 PM

    if itab1[] eq itab2[]

    message 'both are equal'.

    endif.

    Reward points if the answer is helpful to you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 12:04 PM

    if itab1[] eq itab2[]

    message 'both are equal' type 'I'.

    endif.

    Reward points if the answer is helpful to you.

    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.