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 passed by value

Former Member
0 Likes
2,460

hi,

i am passing an internal table to a BADI method as exporting parameter. In the BADI definition i acept it as importing.

i change the value in the internal table, will it be reflected outside the BADI in the calling program ??

what if i select Pass by value in BADI method parameter definition ? in that case, will the changed value be reflected in the calling program ?

thks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,601

If the pass by value is selected, then what you expected is right.

But, you cannot change the badi method's definition since it is standard.

Regards,

ravi

hi,

i am passing an internal table to a BADI method as exporting parameter. In the BADI definition i acept it as importing.

i change the value in the internal table, will it be reflected outside the BADI in the calling program ??

what if i select Pass by value in BADI method parameter definition ? in that case, will the changed value be reflected in the calling program ?

thks

4 REPLIES 4
Read only

MarcinPciak
Active Contributor
0 Likes
1,601

Hi,

I don't know how it is in BADI's but I think it is simillar to FORMs, where there are 4 types of passing data objects:

- Pass by reference for USING parameters

For the formal parameters p1 p2 ..., no local data object is created in the subroutine. Instead, when it is called, a reference is passed to the specified actual parameter. A change to the formal parameter in the subroutine also changes the value of the actual parameter.

- Pass by reference for CHANGING parameters

The formal parameters p1 p2 ... are handled exactly like those parameters defined for pass by reference using USING.

- Pass by value for USING parameters

For each formal parameter p1 p2 ..., a local object with the same data type as the corresponding actual parameter is created in the subroutine and filled with its values. A change to the formal parameter in the subroutine does not change the value of the actual parameter. The actual parameter also retains its original value even after the subroutine has ended.

- Pass by value for CHANGING parameters

For each formal parameter p1 p2 ..., a local data object with the same data type as the corresponding actual parameter is created in the subroutine and filled with its values. A change to the formal parameter in the subroutine does not directly change the value of the actual parameter. If the subroutine is ended using ENDFORM, RETURN, CHECK or EXIT however, the content of the formal parameter is assigned to the actual parameter. If the subroutine is ended by a message or an exception, the actual parameter remains unchanged.

Anyhow it would be logical to pass all internal tables via its reference. The system would only need to know address of the table to access it, avoiding to copying large contents.

I hope it will help you,

Marcin

Read only

Former Member
0 Likes
1,602

If the pass by value is selected, then what you expected is right.

But, you cannot change the badi method's definition since it is standard.

Regards,

ravi

Read only

0 Likes
1,601

thanks Ravi, but i was talking about a custom BADI.

Read only

0 Likes
1,601

Pass by value can be extremely inefficient for large data structures and tables, since the system makes a copy of the data instead of just passing an address.

This may be a consideration for performance purposes.

Good luck

Brian