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

hi

can any one tell how can we compare the colum values in ABAP like

121

134

145

167

134 has to check with 121

145 has to check with 134 and 121

167 has to check with 121,134 and 145 and so on.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 01:05 PM

    Hi

    In the loop of ITAB

    read it and move the value intoa variable

    in the next loop pass compare that field value with the variable value

    if you wants to compare with all previous ones put them in different variables and check

    Regards

    Anji

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Check this code logic just copy and paste to ur editor,

      data: begin of t_test,

      a type i,

      end of t_test.

      data: lt_test like STANDARD TABLE OF t_test,

      wa_test like LINE OF lt_test,

      lt_test1 like TABLE OF t_test,

      wa_test1 like LINE OF lt_test1.

      wa_test-a = 123.

      append wa_test to lt_test.

      wa_test-a = 133.

      append wa_test to lt_test.

      wa_test-a = 143.

      append wa_test to lt_test.

      wa_test-a = 165.

      append wa_test to lt_test.

      wa_test-a = 177.

      append wa_test to lt_test.

      loop at lt_test into wa_test.

      if lt_test1 is NOT INITIAL.

      loop at lt_test1 into wa_test1.

      if wa_test-a <= wa_test1-a.

      write:/ wa_test-a, 'is less than equal to ', wa_test1-a.

      else.

      write:/ wa_test-a, 'is grater than equal to ', wa_test1-a.

      ENDIF.

      endloop.

      endif.

      wa_test1-a = wa_test-a.

      append wa_test1 to lt_test1.

      endloop.

      change me if im wrong

      <b>Reward points if useful.</b>

      Regards,

      Vimal

      Message was edited by:

      Vimal Kumar

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 01:20 PM

    if u want to used read statement,

    in read statement u can check the condition with sy-tabix < sy-index

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 01:35 PM

    Hi,

    try this:

    DATA: BEGIN OF ITAB0 OCCURS 0,

    C(4),

    END OF ITAB0.

    *

    DATA: BEGIN OF ITAB1 OCCURS 0,

    C(4),

    END OF ITAB1.

    *

    ITAB0-C = '121'. APPEND ITAB0.

    ITAB0-C = '134'. APPEND ITAB0.

    ITAB0-C = '145'. APPEND ITAB0.

    ITAB0-C = '121'. APPEND ITAB0.

    ITAB0-C = '145'. APPEND ITAB0.

    ITAB0-C = '167'. APPEND ITAB0.

    ITAB0-C = '178'. APPEND ITAB0.

    *

    CLEAR: ITAB1[].

    LOOP AT ITAB0.

    READ TABLE ITAB1 WITH KEY C = ITAB0-C.

    IF SY-SUBRC = 0.

    WRITE: / ITAB0-C, ITAB1-C.

    ENDIF.

    ITAB1-C = ITAB0-C. APPEND ITAB1.

    ENDLOOP.

    Regards, Dieter

    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.