Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Loop problem

Former Member
0 Kudos

HI Experts,

in my program, i dont know why its not getting inside the loop. below is my code. I have seen in the debugger mode that as the arror comes on Loop statement, after that it directly goes to next select statement. why it is not going inside the Loop. is there any thing missing in my code. plz help .its urgent.

IF SY-SUBRC = 0.

SORT IT_TRFRATE BY MATNR_TR.

LOOP AT IT_TRFRATE.

IF IT_EKKO-MATNR_LI = IT_TRFRATE-MATNR_TR AND N = 1.

IT_EKKO-TRFRATE = IT_TRFRATE-TRFRATE.

N = N + 1.

ENDIF.

ENDLOOP.

SELECT BEDAT RESWK INTO (IT_EKKO-BEDAT, IT_EKKO-RESWK)

FROM EKKO

WHERE EKKO~EBELN = IT_EKKO-EBELN.

ENDSELECT.

ELSE.

******************************************************************************************

Thanks.

Khan.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

As control is not going inside loop..endloop , there must be no data in the Internal table.

Regards,

Sankar

8 REPLIES 8

Former Member
0 Kudos

Hi,

As control is not going inside loop..endloop , there must be no data in the Internal table.

Regards,

Sankar

0 Kudos

thanks alot for the help. now the control is going inside as I filled the IT_trfrate.

NOw I need to transfer the respective rates to it_ekko. it_trfrate table has MATNR AND TRFRATE fields. what ever material currently in it_ekko-matnr_li, I want to searche the whole table it_trfrate for that MATNR.

*************************************************************************************

WHAT DO i MAKE CHANGE IN MY CODE.

LOOP AT IT_TRFRATE.

IF IT_EKKO-MATNR_LI in IT_TRFRATE AND N = 1.

IT_EKKO-TRFRATE = IT_TRFRATE-TRFRATE.

N = N + 1.

ENDIF.

ENDLOOP.

**************************************************************************************

THANKS.

kHAN

Former Member
0 Kudos

Hi

Write like this and see

IF SY-SUBRC = 0.

SORT IT_TRFRATE BY MATNR_TR.

LOOP AT IT_TRFRATE.

<b>IF ( ( IT_EKKO-MATNR_LI = IT_TRFRATE-MATNR_TR ) AND N = 1 ).</b>

IT_EKKO-TRFRATE = IT_TRFRATE-TRFRATE.

N = N + 1.

ENDIF.

ENDLOOP.

SELECT BEDAT RESWK INTO (IT_EKKO-BEDAT, IT_EKKO-RESWK)

FROM EKKO

WHERE EKKO~EBELN = IT_EKKO-EBELN.

ENDSELECT.

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos

Hi

read IT_EKKO table in loop with read stt.

regards

sandhya

Former Member
0 Kudos

HI,

if the internal table IT_TRFRATE is empty it will not go inside the loop.

first check whether data is there in that are not.

rgds,

bharat.

Former Member
0 Kudos

possibilities:

1. check sort statement.

2. check no of entries in internal table.

still not solved revert me back

Sameer

Former Member
0 Kudos

hi

if sy-subrc =0 ur putting if the above query fails then how this loop will execute

so try to find what exactly problem with the above statement

reward if usefull

former_member404244
Active Contributor
0 Kudos

Hi,

as the control is not going inside the loop ,u need to check the internal table(IT_TRFRATE) has some values or not..plz check the initiality before loop .Also correct the statement after loop..

IF ( ( IT_EKKO-MATNR_LI = IT_TRFRATE-MATNR_TR ) AND N = 1 ).

Regards,

Nagaraj