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

code optimization

Former Member
0 Likes
1,155

I have the code as below:

SELECT MATNR

FROM MARA

INTO TABLE IT_MARA

WHERE MTART = 'FERT'.

LOOP AT IT_MARA INTO WA_MARA.

SELECT MAKTX matnr FROM MAKT INTO TABLE IT_MAKT

WHERE MATNR = WA_MARA-MATNR.

LOOP AT IT_MAKT INTO WA_MAKT.

APPEND WA_MAKT to IT_MAKT.

ENDLOOP.

ENDLOOP.

when i run this code i get the following error "No more storage space available for extending an internal table".

please suggest how can i optimise the code.

11 REPLIES 11
Read only

Former Member
0 Likes
1,128

You need to get trained in ABAP. Seriously.

pk

Read only

former_member329859
Participant
0 Likes
1,128

This message was moderated.

Read only

0 Likes
1,128

>

> hi

> LOOP AT IT_MARA INTO WA_MARA.

> SELECT MAKTX matnr FROM MAKT INTO TABLE IT_MAKT

> WHERE MATNR = WA_MARA-MATNR.

>

> use into corresponding field of the table it_makt after checking your table defination for table it_makt

>

> thanx

> gaurav

And this would "optimize the code"?

pk

Read only

Former Member
0 Likes
1,128

This message was moderated.

Read only

Former Member
0 Likes
1,128

Hi Ashu ,

You should take some tutorial related with basics and performance tuning.

There are many posts avaliable on SDN related to these.

Press F1 on for all entries to know an alternate approach for your logic.

Hope this helps you.

Read only

Former Member
0 Likes
1,128

Hi,

Please check

SELECT MATNR
FROM MARA
INTO TABLE IT_MARA
WHERE MTART = 'FERT'.

if sy-subrc eq 0 and it_mara is not initial.

SELECT MAKTX matnr FROM MAKT FOR ALL ENTRIES IN IT_MARA INTO TABLE IT_MAKT
WHERE MATNR = IT_MARA-MATNR.

endif.

what this loop statement is doing.

LOOP AT IT_MAKT INTO WA_MAKT.

APPEND WA_MAKT to IT_MAKT.

ENDLOOP.

Is that you need to populate the internal table with a material and its corresponding material descriptions. ?

thanks,

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,128

Read what you have written

LOOP AT IT_MAKT INTO WA_MAKT.
APPEND WA_MAKT to IT_MAKT.
ENDLOOP.

No, read it actually

Regards,

Raymond

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,128

ROFL ...

Read only

0 Likes
1,128

More seriously, the question, was "When will the LOOP terminate ?"

The answer, is when no more memory or time out is reached...

Regards,

Raymond

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,128

Hello Raymond,

I had got it the first time you had mentioned

Cheers,

Suhas

Read only

Former Member
0 Likes
1,128

Hi,

For Optimising,

1st) Instead of first loop use Select For All Enteries (query)

2nd) Avoid calling select queries from inside of a loop, its not a good pratice.

3rd) regarding the dump error, contact your BASIS for memory settings of SAP.

Thanks!