Way of passing parameters

DATA: I_NUM1 TYPE VALUE 10,
      I_NUM2 TYPE VALUE 20,
      I_NUM3 TYPE I.

WRITE'I_NUM1=',I_NUM1,
       'I_NUM2=',I_NUM2,
       'I_NUM3=',I_NUM3.
SKIP.
PERFORM CALCULATOR USING I_NUM1 I_NUM2 CHANGING I_NUM3.


WRITE:  /'I_NUM1=',I_NUM1,
        'I_NUM2=',I_NUM2,
        'I_NUM3=',I_NUM3.
SKIP.
"First, the address (ADDRESS) of the parameters passed to the subroutine when the transfer parameters, i.e. the parameter value of the shared variable subprogram address in the external program parameter variables.
" Called CALL BY ADDRESS, if the subroutine the value of the parameter variable has changed, then the actual value of the variable external program is also changed.
. * The FORM CALCULATOR the USING NUM1 NUM2 CHANGING NUM3
*
. * NUM3 = NUM1 + NUM2
* the WRITE: 'NUM1 =', NUM1,
* 'NUM2 =', NUM2,
. * 'NUM3 =', NUM3
. * EndForm

"Second, the value of delivery is to copy the value of the parameter to a memory address to another, a change of the value of the parameter does not affect the value of the external variable real variables in the program subroutine.
the FORM CALCULATOR  the USING  of vALUE (NUM1 of vALUE (NUM2 cHANGING  the SUM .
  the SUM  = NUM1 + NUM2 .
  NUM1  = NUM1 * NUM2 .
  NUM2  = NUM1 * NUM2.
  The WRITE : / '= NUM1' , NUM1 ,
         'NUM2 =' , NUM2 ,
         'the SUM =' , the SUM .
EndForm .
"Third, in the same manner with the transmission parameters passed by value, but in the end of the subprogram is executed will pass the final value of the return of a parameter variable to the external program variables.
* NUM1 the FORM NUM2 the USING CHANGING of vALUE CALCULATOR (TOTAL).
* TOTAL = NUM1 + NUM2.
* the WRITE: / '= NUM1', NUM1,
* 'NUM2 =', NUM2,
* 'TOTAL =', TOTAL,
* '= I_NUM3', I_NUM3.
* EndForm.

Guess you like

Origin www.cnblogs.com/salah/p/11917014.html