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

pass

Former Member
0 Likes
592

what is the exact difference between pass by value and pass by reference particularly regaring subroutines,methods,function modules what will we do

1 ACCEPTED SOLUTION
Read only

graghavendra_sharma
Contributor
0 Likes
570

if you pass the parameters (formal paramters) by value, whatever the changes done to them inside the method or subroutine will not reflect back. but if you pass by reference the changes done inside method or subroutine will reflect back.

REPORT z_grs_pass_by_value .

DATA: i1 TYPE i, i2 TYPE i, i3 type i.

i1 = 10.

i2 = 20.

i3 = 30.

WRITE: / 'Before calling Subrouting'.

WRITE: / i1, i2, i3.

PERFORM pass USING i1 i2 CHANGING i3.

WRITE: / 'After calling Subrouting'.

WRITE: / i1, i2, i3.

&----


*& Form pass

&----


  • text

----


  • -->P_I1 text

  • -->P_I2 text

----


FORM pass USING p_i1

value(p_i2)

p_i3.

p_i1 = 11.

p_i2 = 12.

p_i3 = 13.

WRITE: / 'Inside Subrouting'.

WRITE: / p_i1, p_i2, p_i3.

ENDFORM. " pass

OUTPUT:

-


Before calling Subrouting

10 20 30

Inside Subrouting

11 12 13

After calling Subrouting

11 20 13

Message was edited by:

raghav sharma

3 REPLIES 3
Read only

Former Member
0 Likes
570

hi,

For pass-by-value u will directly pass the value and for Pass-by-reference u need to pass a reference variable for that particular variable.

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
570

Hi

In Pass-By-Value : Values of actual parameters will be passed to formal parameters.

Pass-By-Reference : Copy of values of actual parameters will be passed to formal parameters.

Regards,

Sree

Read only

graghavendra_sharma
Contributor
0 Likes
571

if you pass the parameters (formal paramters) by value, whatever the changes done to them inside the method or subroutine will not reflect back. but if you pass by reference the changes done inside method or subroutine will reflect back.

REPORT z_grs_pass_by_value .

DATA: i1 TYPE i, i2 TYPE i, i3 type i.

i1 = 10.

i2 = 20.

i3 = 30.

WRITE: / 'Before calling Subrouting'.

WRITE: / i1, i2, i3.

PERFORM pass USING i1 i2 CHANGING i3.

WRITE: / 'After calling Subrouting'.

WRITE: / i1, i2, i3.

&----


*& Form pass

&----


  • text

----


  • -->P_I1 text

  • -->P_I2 text

----


FORM pass USING p_i1

value(p_i2)

p_i3.

p_i1 = 11.

p_i2 = 12.

p_i3 = 13.

WRITE: / 'Inside Subrouting'.

WRITE: / p_i1, p_i2, p_i3.

ENDFORM. " pass

OUTPUT:

-


Before calling Subrouting

10 20 30

Inside Subrouting

11 12 13

After calling Subrouting

11 20 13

Message was edited by:

raghav sharma