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

change a table within a method

Former Member
0 Likes
1,404

Hi,

I am implementing a new method that has an internal table as a changing parameter. But it is passed by value.

How can I do to change the data of it within the method?

Thanks in advance.

Nerea.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
949

Hello Nerea

If you have a CHANGING parameter which is a table type (guess that is your situation) you simply work directly on this parameter (e.g. ct_itab). Whether it is passed by value or reference should not matter because when you leave the method the changes will be reflected in the CHANGING parameter. It may make a difference if the flow is prematurely aborted by an exception but I do not know more about that (just give it a try).

Regards

Uwe

3 REPLIES 3
Read only

dani_mn
Active Contributor
0 Likes
949

HI,

To change the values of the passed parameter you should pass it 'BY REFERENCE'.

You can't modify the actuall contents if if is passed by value. because a local copy is made for the variable in the method.

OR

You can copy the contents to the original table in last statement of the method if the table declaration is global.

Regards,

Read only

uwe_schieferstein
Active Contributor
0 Likes
950

Hello Nerea

If you have a CHANGING parameter which is a table type (guess that is your situation) you simply work directly on this parameter (e.g. ct_itab). Whether it is passed by value or reference should not matter because when you leave the method the changes will be reflected in the CHANGING parameter. It may make a difference if the flow is prematurely aborted by an exception but I do not know more about that (just give it a try).

Regards

Uwe

Read only

0 Likes
949

Hi,

thanks Uwe for your answer. I have tried changing the internal table data and it works.

Whether the parameter is passed by value or by reference, thoufh, does matter. Or at least that's what I have found out:

refering to it direcly (e.f. ct_itab) did not work at all, the process jumped the LOOP.

But when I referenced the internal table before the loop, it processed the loop and inside it I could directly refer to the internal table:

CLEAR data_ref.

GET REFERENCE OF it_zeitsatz INTO data_ref.

CLEAR d_linea.

LOOP AT it_zeitsatz INTO d_linea.

CLEAR d_linea.

MODIFY it_zeitsatz FROM d_linea.

ENDLOOP.

Regards

Nerea