Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Difference between Using and Changing in Subroutines

Hi All,

I am using a Subroutine Example in My Program. I know the basic differences between using and changing each pointing to Call by value and Call by reference respectively. I know that using Call by Value in Subroutines won't change change the values in Actual parameters whatever happens to formal parameters. I am using the following code,

DATA : A TYPE I,

        B TYPE I,

        C TYPE I,

        D TYPE I,

        E TYPE I,

        F TYPE I.

A = 3.

B = 4.

D = 5.

E = 7.

PERFORM ADD USING A B C.

PERFORM ADD USING D E F.

FORM ADD  USING    P_A TYPE I

                                  P_B TYPE I

                                 P_C TYPE I.

P_C = P_A + P_B.

ENDFORM.


Using this code, as per definition in Call by value whatever changes happen to Formal Parameter (P_C) , Value of Actual Parameter (C or F) shouldn't change. But the values of actual parameters ( C and F ) are changing after 'Perform' statement even if I use that in after 'Using' in Subroutine call.


Kindly help me understand this.


Thanks & Regards,


Jai.

Former Member
Former Member replied

Hi All,

Got the Solution. I have to use 'Value' after 'Using' for each variables in 'FORM' statement like this,

FORM ADD USING VALUE(P_A) VALUE(P_B) VALUE(P_C).

By using this, Value of Actual Parameters aren't changing.

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question