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: 

Records are getting overwritten in the internal table using Select query.

Former Member
0 Kudos
1,011

Hi All,

I have following query :

Loop at i_salesplant.

select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL

into corresponding fields of table i_zallocpol from mara inner join mvke on

mvkematnr = maramatnr

where MARA~zzobjtype = I_ZZOBJTYPE

and MVKE~VKORG = i_salesplant-vkorg

and MVKE~VTWEG = T_VTWEG.

ENDLOOP.

My Que : For example lets say first it selects all the records for Sales Org 1000. Next when you select the records for the Sales Org 2000 the earlier records are getting overwritten.

Please let me know your valuable inputs.

Thanks,

Chandravadan

1 ACCEPTED SOLUTION

Former Member
0 Kudos
218

Use FOR ALL ENTRIES instead of LOOP.

select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL

into corresponding fields of table i_zallocpol from mara inner join mvke on

mvkematnr = maramatnr

FOR ALL ENTRIES IN i_salesplant

where MARA~zzobjtype = I_ZZOBJTYPE

and MVKE~VKORG = i_salesplant-vkorg

and MVKE~VTWEG = T_VTWEG.

Thanks,

Srinivas

6 REPLIES 6

Former Member
0 Kudos
218

Try in this way

APPENDING CORRESPONDING FIELDS OF TABLE itab

for the select statement

0 Kudos
218

Hi,

Thanks alot for the reply.

I changed query using appending as follows :

Loop at i_salesplant.

select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL

into appending corresponding fields of table i_zallocpol from mara inner join mvke on

mvkematnr = maramatnr

where MARA~zzobjtype = I_ZZOBJTYPE

and MVKE~VKORG = i_salesplant-vkorg

and MVKE~VTWEG = T_VTWEG.

ENDLOOp.

But it is giving error saying " Field "APPENDING" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "

Please suggest.

Thanks,

Chandravadan

0 Kudos
218

Write this way it will not overwrite the table but it will append the records into the table

Loop at i_salesplant.

select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL

appending corresponding fields of table i_zallocpol from mara inner join mvke on

mvkematnr = maramatnr

where MARA~zzobjtype = I_ZZOBJTYPE

and MVKE~VKORG = i_salesplant-vkorg

and MVKE~VTWEG = T_VTWEG.

ENDLOOP.

0 Kudos
218

u should remove into and replace it by appending

0 Kudos
218

Hi Shrinivas,

I used Select for all entries, it is working fine.

Thanks a lot for the response.

Points Rewarded.

Regards,

Chandravadan

Former Member
0 Kudos
219

Use FOR ALL ENTRIES instead of LOOP.

select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL

into corresponding fields of table i_zallocpol from mara inner join mvke on

mvkematnr = maramatnr

FOR ALL ENTRIES IN i_salesplant

where MARA~zzobjtype = I_ZZOBJTYPE

and MVKE~VKORG = i_salesplant-vkorg

and MVKE~VTWEG = T_VTWEG.

Thanks,

Srinivas