abap动态计算公式程序

abap动态计算公式程序

代码摘至程序RSCALC10,部分修改.

REPORT  ZDEMO_FORMULA.

DATA:
;o9S;X a$w$kU15066253      RETCODE      TYPE SY-SUBRC,
9][?kK6v15066253      FUNCNAME(30) TYPE C,
(t;Z-I6M{:N(l3v15066253      MESSAGE(70)  TYPE C,
2F:}%f wk]L]-T;nB(C15066253      POS          TYPE I,ITPUB个人空间z)G�}UE{L
      C            TYPE I.

PARAMETERS FORMEL type formel.

PERFORM. MIN.

FORM. MIN.
T"PN e m$qC8R15066253*check formula
4r L5~pt{v%g15066253  CALL FUNCTION 'CHECK_FORMULA'ITPUB个人空间'r4i'tw3N|+n1\D
       EXPORTING  FORMULA   = FORMEL
h!R5a-y/xN$z15066253       IMPORTING  SUBRC     = RETCODE
]A ] C2^9p2N\z%{B15066253                  FUNCNAME  = FUNCNAMEITPUB个人空间C'ov^t$c D`
                  MESSAGE   = MESSAGEITPUB个人空间!a4x0X0\:t_R1h,Lj*[
                  POS       = POS
.S5}R)hY/d!X~15066253       EXCEPTIONS
zR5^.X's`Gv~{15066253                   ERROR_IN_FORMULA = 1
:fKy1?u$X5Dre@%E15066253                   MISSING_PARAMETER = 2
hD|H`&oO:n.u+A15066253                   THERS = 3.

  IF SY-SUBRC EQ 0."formula is ok

*    IF RETCODE IS INITIAL.

* work out formulaITPUB个人空间1k:J+x(xX]"|)e
       CALL FUNCTION 'EVAL_FORMULA'ITPUB个人空间3H9ld}6s3ER9m
            EXPORTING  FORMULA   = FORMEL
"W{)o^L!n15066253            IMPORTING  VALUE     = C
Sq3I fm5p r YQ15066253            EXCEPTIONS OTHERS    = 1.
,A?\#k1~lX5h15066253       IF SY-SUBRC EQ 0.ITPUB个人空间A lF*d@8|(kl
          WRITE: / 'successful!'.
8T2Y!l4H(Mv?G15066253          write: / .ITPUB个人空间OVP4Ik mCZ{0@
          write: / 'c:', 20 C.
-q Tr;J+Ux15066253       ELSE.ITPUB个人空间7^+b7C+^Q8J7E!V4s
          WRITE: / 'error!'.
,\0@ U+ZZ2U#w15066253          write: / .ITPUB个人空间(FS3jdK*uJ#C(d
          WRITE: / 'sy-subrc:', 20 SY-SUBRC.

       ENDIF.
y^3eY2k/^15066253*    ELSE.ITPUB个人空间3i"[KPJAqM$@
*       WRITE: / FUNCNAME, MESSAGE, POS.ITPUB个人空间(O"oJZ7zl
*    ENDIF.

  ELSE.ITPUB个人空间/q(L Z�q"F`
      WRITE: / 'CHECK_FORMULA',20 'error!'.ITPUB个人空间o^_.e T Uj
  ENDIF.

ENDFORM.

还有另一种方法实现,详细见:http://tolyhuang.itpub.net/post/29951/287361

你可能感兴趣的:(abap)