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

Internal Tables

Former Member
0 Likes
990

Why are internal tables always passed by reference and not by value?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
916

Hi ,

Internal tables are always passed through reference and not by value as if we pass through values always a copy of the the variable is stored and as internal tables are very large in size so keeping a copy in the application server will affect the performance.

Regards ,

Debojyoti.

7 REPLIES 7
Read only

bpawanchand
Active Contributor
0 Likes
916

Hi

You can even pass a internal table by value also by using CHANGING VALUE(tab) addition basically if we pass the internal by reference then the changes are visible to the MAIN program or the calling program if we pass the internal table by VALUE then any changes made to the table are not visible to the external program or main program from which you are calling the subroutine

[Check the Example|http://help.sap.com/saphelp_nw70/helpdata/en/9f/db979035c111d1829f0000e829fbfe/content.htm]

Regards

Pavan

Read only

Former Member
0 Likes
916

Hi Arnab.

I would like to suggest,

Pass by Reference means passing the Address itself (Reference).

Pass by Value means passing a copy of the value to be passed.

For Database Performance purposes, we pass Internal table by Reference.

I would like to suggest a reference,

[SDN - Reference - Passing by value and Passing by reference - Internal Table|;

Hope that's usefull.

Good Luck & Regards.

Harsh Dave

Read only

0 Likes
916

> Pass by Reference means passing the Address itself (Reference).

> Pass by Value means passing a copy of the value to be passed.

> For Database Performance purposes, we pass Internal table by Reference.

You are correct in your statement with regards to what the difference is between them but I would like to point out that it has nothing to do with "Database Performance purposes". The performance concern would be not related to the database but instead with the application server performance and the usage of memory.

~Ian

Read only

Former Member
0 Likes
916

HI,

We send Internal table always passed by reference because internal table is a complex data type.

We can send internal table by value or by CHANGING. But then a copy of the TAble will created and the Actual table remains Data less.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
916

Hi Arnab,

when we use pass by reference to pass variable or internal table then we pass the address of the internal table or variable.

So whatever changes is made in side the subrouitne it is reflected in the internal table or variable in the main program.

But if we use pass by value then in the subroutine formal parameters are created as a copy of the actual parameter in the main program.Formal parameter has it own memory.So whatever changes you make inside the subrouitne has no effect in the internal table or variable of the main progarm ie. on the actual parameter.

So it depends on your requirement whether you want to get the changed value or you want that main program internal table should not change.

As per the requirement you choose Pass by value or Pass by reference.

Hope you get it.

Regards,

Sujit

Read only

Former Member
0 Likes
917

Hi ,

Internal tables are always passed through reference and not by value as if we pass through values always a copy of the the variable is stored and as internal tables are very large in size so keeping a copy in the application server will affect the performance.

Regards ,

Debojyoti.

Read only

Former Member
0 Likes
916

Hi!

We pass internal tables by reference because internal table contains lots of data.

When you pass an internal table by value a copy of internal table is made and then it is passed to your subrotuine. So it requires a lot of memory.

But when you pass an internal table by reference just address of that internal table is passed. This means that no copy of internal table is made.

That why internal table is generally passed by reference

Regards

Abhijeet