Application Development and Automation 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: 
Read only

select single in the loop doesn't work !

Former Member
0 Likes
747

Hi guys,

with the bellow code I'd like to fill the column vmsta in my itab from the table vmke.

My question is why the compiler says "The field mvke-matnr unknown". Even if I delete mvke-matnr it would say "The field mvke-vkorg is unknow".

I have already declared the table mvke and itab has head line as well

Thanks for you help.

LOOP AT itab.

SELECT SINGLE vmsta INTO itab-vmsta

FROM mvke

WHERE mvke-matnr = itab-matnr

AND

mvke-vkorg = itab-vkorg.

IF sy-subrc = 0.

MODIFY itab.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

Remove 'MVKE-' from the fields in your where clause. It is not necessary to specify the table name since you are only selecting from MVKE.

Best Regards,

Chris H.

5 REPLIES 5
Read only

naimesh_patel
Active Contributor
0 Likes
696

You don't need to specifiy the Table name in the where condition.

Change query to:


SELECT SINGLE vmsta INTO itab-vmsta
FROM mvke
WHERE MATNR = itab-matnr   " <<
AND
VKORG = itab-vkorg.   "<<

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
697

Remove 'MVKE-' from the fields in your where clause. It is not necessary to specify the table name since you are only selecting from MVKE.

Best Regards,

Chris H.

Read only

0 Likes
696

O no you all are right. I just didn't see it. Sorry guys.

I better stop working today and go home.

Thanks all

Read only

Former Member
0 Likes
696
LOOP AT itab.
SELECT SINGLE vmsta INTO itab-vmsta
FROM mvke
WHERE mvke-matnr = itab-matnr
AND vkorg = itab-vkorg.  <---change to vkorg from mvke-vkorg
IF sy-subrc = 0.
MODIFY itab.
ENDIF.
ENDLOOP.
Read only

Former Member
0 Likes
696

Hi,

LOOP AT itab.

SELECT SINGLE vmsta INTO itab-vmsta

FROM mvke

WHERE matnr = itab-matnr

AND

vkorg = itab-vkorg.

IF sy-subrc = 0.

MODIFY itab.

ENDIF.

ENDLOOP.

hope it will work.

Thanks,

Kamesh