Application Development 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: 

return value

spandana_babu
Participant
0 Kudos
142

hi

can any body gives the diffrence b/w

importing u type i,

importing value( u) type i.

regards

Spanadana

4 REPLIES 4

Sm1tje
Active Contributor
0 Kudos
108

by reference or by value.

especially for internal tables, this can result in loss of performance. So use the reference and not the 'pass by value'.

Edited by: Micky Oestreich on May 16, 2008 11:11 AM

0 Kudos
108

hi

please see once

class sl definition.

public section.

data : v_a type i,

v_b type i.

methods : add importing p_a type i

p_b type i

returning value(p_c) type i.

protected section.

private section.

endclass.

class sl implementation.

method add.

p_c = p_a + p_b.

endmethod.

endclass.

START-OF-SELECTION.

data: obj type ref to nsl,

b1 type i.

create object obj.

call method obj->add( exporting p_a = 10 p_b = 20 ).

up to now coding is fine if i replace last statement with

belovw code

b1 = obj->add( exporting p_a = 10 p_b = 20 ).

it show error that p_a unable to interrput.

plesse provide the solution.

if i am taking single parameters it is working ok

where as i am taking 2 parametrs it is not working..

please give solution.

Regards

spandana

Former Member
0 Kudos
108

importing u type i, is pass by reference

importing value( u) type i.is pass by value.

In pass by reference, the change in formal parameter will affect the actual parameter. where as in case of pass by value, it wont.

reward points if helpful.

Former Member
0 Kudos
108

Hi,

We can pass parameters in 3 ways

Pass by value

Pass by reference

Pass by values and result.

The example which you gave comes under the category of pass by value.

In general if you use

"importing u type i, it means you are passing the variable with reference to actual parameter. so if you change the value i, it directly affects the actual parameter.

if you use "importing value( u) type i" then it is pass by value i.e you are just using a formal parameter and it does not affect the actual parameter .

example:

data: f1 value 'A'.

perform s1 using f1.

write / f1.

form s1 using value(p1).

p1 = 'X'.

write / p1.

endform.

output will be

X

A

Reward points if helpful.

Thanks and regards.