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

parameter passing - USING

Former Member
0 Likes
926

in parameter passing, if USING and CHANGING serve the same purpose (see my previous post - ) and the only difference is when you use CHANGING you are going to do something with the formal parameter inside the FORM. Does this mean I cannot do operation (like addition if the formal parameter is an integer type) if USING is being used? i tried doing that and i used USING and surprisingly it allowed the operation. anyone can help me understand pls? <b>thanks!</b>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
885

Hi Jabbar

As I told you in the previous post both of them have same function.For better understanding we use Changing parameter.I.e. suppose you are passing two actual parameters to the subroutine.one parameter is being changed in the form and the other one is not getting changed.Now if use only USING also it will work.But for a a person checking the code he cant make ouy which one is getting changed.SO use CHANGING.

In short

The additions USING and CHANGING have exactly the

same meaning. You only need to use one or the other. However, for documentary reasons, it is a

good idea to divide the parameters in the same way in which they occur in the interface

definition.

Message was edited by:

Raghu Reddy

6 REPLIES 6
Read only

Former Member
0 Likes
886

Hi Jabbar

As I told you in the previous post both of them have same function.For better understanding we use Changing parameter.I.e. suppose you are passing two actual parameters to the subroutine.one parameter is being changed in the form and the other one is not getting changed.Now if use only USING also it will work.But for a a person checking the code he cant make ouy which one is getting changed.SO use CHANGING.

In short

The additions USING and CHANGING have exactly the

same meaning. You only need to use one or the other. However, for documentary reasons, it is a

good idea to divide the parameters in the same way in which they occur in the interface

definition.

Message was edited by:

Raghu Reddy

Read only

0 Likes
885

Raghu,

> The additions USING and CHANGING have exactly the

> same meaning. You only need to use one or the other.

This holds good only if all parameters are being passed by 'REFERENCE' (This is default), If you pass the values into the form by 'VALUE' the behavior is different.

This is why you get a syntax check warning whenever you try to pass a 'USING' value by reference to a form.

Read only

0 Likes
885

Hi Srihari,

Thats true.

Read only

Former Member
0 Likes
885

Jabbar,

For better understanding, copy paste this code into a test program and execute, check the results.

DATA: v1 type c VALUE 'A',
      v2 type c VALUE 'A',
      v3 type c VALUE 'A',
      v4 type c VALUE 'A',
      v5 type c VALUE 'A'.


perform check_params USING v1
                           v2
                           v3
                     CHANGING v4
                              v5.

WRITE : / v1, v2, v3, v4, v5.

*&---------------------------------------------------------------------*
*&      Form  CHECK_PARAMS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_V1  text
*      -->P_V2  text
*      -->P_V3  text
*      <--P_V4  text
*      <--P_V5  text
*----------------------------------------------------------------------*
form CHECK_PARAMS  using    VALUE(p_v1)
                            p_v2
                            VALUE(p_v3)
                   changing VALUE(p_v4)
                            p_v5.


p_v1 = 'B'.
p_v2 = 'C'.
p_v3 = 'D'.
p_v4 = 'E'.
p_v5 = 'F'.

WRITE : / p_v1, p_v2, p_v3, p_v4, P_v5.
WRITE : / v1, v2, v3, v4, v5.
endform.                    " CHECK_PARAMS

Hope it helps.

Regards,

Srihari

Read only

Former Member
0 Likes
885

Hi Jabbar,

I think you got the concepts wrong for using and changing.

Just to keep it simple the parameters can be passed to forms by using or changing.

when parameterd passed bu USING it will have diferent memory for formal and actual parameters so the value of actual variable will not changed whatever operation you do in FORMS the same is not true for CHANGING. When any operation done on the parameter the actual value will change as they have the same memory.

Regards,

Atish

Read only

Former Member
0 Likes
885

<b>thanks to all of you!</b>