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

Help..

Masters!!

I have two fields in one internal table..namely field1 and field2..each field has a corresponding value..my problem is I want to get their last value..example:

field1

1

2

3

field2

1

2

3

4

since field1 has its last value of 3 and field2 has its value of 4..

I need to get those value..

field1 = 3 and field2 = 4.

Could you help me to compose my logic and my coding..please help me..

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 Dec 03, 2007 at 01:36 AM

    There are many ways to do this, but you can try:

    SORT itab BY field1 DESCENDING.
    READ TABLE itab index 1.                      "Last value of field1.
    
    SORT itab BY field2 DESCENDING.
    READ TABLE itab index 1.                     "Last value of field2.
    

    Rob

    Message was edited by:

    Rob Burbank

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 03:58 AM

    Hi Salma,

    I want o ask one thing in this .

    Suppose

    field1

    1

    3

    2

    field1

    2

    3

    1

    If this is the case then you want 2 in field1 and 1 in field 2.

    If it is not the case , Then you just sort these two fields in decending order and get the topmost value.

    here is the code:-

    sort itab1 by field1 descending.

    move: itab1-field1 to wa_field1.

    sort itab2 by field2 descending.

    move: itab2-field2 to wa_field2.

    Now use these variables for your further logic.

    Thanks & Regards,

    Mamta

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2007 at 05:10 AM

    Hi Salma..

    suppose you want the perticular value you can go for the below code:

    SORT itab BY field1 DESCENDING.

    READ TABLE itab where field1 eq 3 .

    SORT itab BY field2 DESCENDING.

    READ TABLE itab where field2 eq 4.

    otherwise if want only the last values,then as others told,you can code in your program.

    reward if helpful.

    Thanks

    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.