‎2006 Aug 30 10:58 AM
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.
‎2006 Aug 30 11:50 AM
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
‎2006 Aug 30 11:03 AM
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,
‎2006 Aug 30 11:50 AM
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
‎2006 Aug 30 12:18 PM
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