Skip to Content

Looping Problem-Index

Dear all,

I am unable to get the index read correctly for my IT_DISPLAY table.There are 2 values in plaf table and multible in display table.

how to get the correct index value for my display table?since currently it is on plaf table.due to this index problem,my values get moved incoreectly

code is as follows

SORT IT_AFPO BY PLNUM.

SORT IT_PLAF BY PLNUM.

LOOP AT IT_AFPO INTO WA_AFPO.

LOOP AT IT_PLAF INTO WA_PLAF.

W_INDEX = SY-TABIX.

IF WA_PLAF-PLNUM = WA_AFPO-PLNUM.

MOVE:WA_PLAF-GSMNG TO WA_DISPLAY-GAMNG.

MODIFY IT_DISPLAY INDEX W_INDEX FROM WA_DISPLAY TRANSPORTING GAMNG.

ENDIF.

CLEAR:WA_PLAF,WA_DISPLAY.

ENDLOOP.

CLEAR:WA_AFPO.

ENDLOOP.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Jan 07, 2008 at 06:06 AM

    Hai Rahul try like this..

    SORT IT_AFPO BY PLNUM.

    SORT IT_PLAF BY PLNUM.

    LOOP AT IT_AFPO INTO WA_AFPO.

    read table IT_PLAF INTO WA_PLAF with key PLNUM = WA_AFPO-PLNUM binary search.

    if sy-subrc eq 0.

    W_INDEX = SY-TABIX.

    MOVE:WA_PLAF-GSMNG TO WA_DISPLAY-GAMNG.

    MODIFY IT_DISPLAY INDEX W_INDEX FROM WA_DISPLAY TRANSPORTING GAMNG.

    endif.

    ENDIF.

    CLEAR:WA_PLAF,WA_DISPLAY.

    CLEAR:WA_AFPO.

    ENDLOOP.

    if you have to do a loop in a loop

    SORT IT_AFPO BY PLNUM.

    SORT IT_PLAF BY PLNUM.

    LOOP AT IT_AFPO INTO WA_AFPO.

    LOOP AT IT_PLAF INTO WA_PLAF where PLNUM = WA_AFPO-PLNUM .

    W_INDEX = SY-TABIX.

    MOVE:WA_PLAF-GSMNG TO WA_DISPLAY-GAMNG.

    MODIFY IT_DISPLAY INDEX W_INDEX FROM WA_DISPLAY TRANSPORTING GAMNG.

    CLEAR:WA_PLAF,WA_DISPLAY.

    ENDLOOP.

    CLEAR:WA_AFPO.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 06:06 AM

    hi,

    when ur reading the second internal table read this based on a where condition and that should link both ur tables first.

    Reward points if helpful,

    Regards,

    Sumanjeet.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 06:08 AM

    Better take a variable and keep Incrementing in the inner loop and clear it in the outer loop.

    • Awrd opints if useful*

    Bhupal

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 07, 2008 at 06:12 AM

    SORT IT_AFPO BY PLNUM.

    SORT IT_PLAF BY PLNUM.

    LOOP AT IT_AFPO INTO WA_AFPO.

    LOOP AT IT_PLAF INTO WA_PLAF.

    W_INDEX = SY-TABIX.

    IF WA_PLAF-PLNUM = WA_AFPO-PLNUM.

    MOVE:WA_PLAF-GSMNG TO WA_DISPLAY-GAMNG.

    MODIFY IT_DISPLAY INDEX W_INDEX FROMWA_DISPLAY TRANSPORTING GAMNG.*

    ENDIF.

    CLEAR:WA_PLAF,WA_DISPLAY.

    ENDLOOP.

    CLEAR:WA_AFPO.

    ENDLOOP.

    since IT_DISPLAY is a new table use append IT_DISPLAY.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 06:08 AM

    Hi Rahul ,

    Could you please specify what exactly do you want to do.

    Regards

    Arun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 06:10 AM

    Hi,

    In the given code, it is not clear about IT_DISPLAY internal table. What data does it contain and whether there is any link between WA_PLAF and IT_DISPLAY. It is not clear, why u are trying to use WA_PLAF index to modify IT_DISPLAY.

    If this point is clear, i hope u can easily solve.

    Let us know the relation.

    Add a comment
    10|10000 characters needed characters exceeded

    • Dear Arun/Ramesh,

      IT_DISPLAY is the internal table which contains the data to be displayed.

      My problem is that if there is a planned order quantity of 10,and production order quantity for that planned order is also 10,then no problem.

      But if it is anything less than 10,then the problem is that it shows 0.

      also when a planned order quantity is converted to planned order quantity completely (that is 10 out of 10)

      then from PLAF TABLE no more contains that PLNUM.

      bUT IF IT IS PARTIAL(ANYTHING LESS THAN 10),then that PLNUM IS COMMON in both PLAF AND AFPO.

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.