直接上代码:
REPORT ZCALL.
DATA GV_NUM1 TYPE I VALUE 10.
DATA GV_NUM2 TYPE I VALUE 10.
WRITE:/ '引用调用前:',GV_NUM1,GV_NUM2.
PERFORM ADD_NUM_R USING GV_NUM1 CHANGING GV_NUM2.
WRITE:/ '引用调用后:',GV_NUM1,GV_NUM2.
WRITE:/ '值调用前:',GV_NUM1,GV_NUM2.
PERFORM ADD_NUM_V USING GV_NUM1 CHANGING GV_NUM2.
WRITE:/ '值调用后:',GV_NUM1,GV_NUM2.
*&---------------------------------------------------------------------*
*& Form ADD_NUM_R
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ADD_NUM_R USING P_NUM1
CHANGING P_NUM2 .
P_NUM1 = P_NUM1 + 1.
P_NUM2 = P_NUM2 + 1.
ENDFORM. " ADD_NUM
*&---------------------------------------------------------------------*
*& Form ADD_NUM_V
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p1 text
* <--p2 text
*----------------------------------------------------------------------*
FORM ADD_NUM_V USING VALUE(P_NUM1)
CHANGING VALUE(P_NUM2).
P_NUM1 = P_NUM1 + 1.
P_NUM2 = P_NUM2 + 1.
ENDFORM. " ADD_NUM_V
执行结果:
从结果可以看出,引用传递时USING和CHANGING没什么区别,而值传递时CHANGING后的值会改变。
网友评论