美文网首页
ABAP开发之引用传递和值传递

ABAP开发之引用传递和值传递

作者: JayDragon | 来源:发表于2017-09-01 15:06 被阅读0次

    直接上代码:

    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
    

    执行结果:

    从结果可以看出,引用传递时USINGCHANGING没什么区别,而值传递时CHANGING后的值会改变。

    相关文章

      网友评论

          本文标题:ABAP开发之引用传递和值传递

          本文链接:https://www.haomeiwen.com/subject/jaahjxtx.html