• 如何获取ABAP程序执行的调用堆栈 [SYSTEM_CALLSTACK]


    介绍一个有趣的函数SYSTEM_CALLSTACK(),这个函数可以得到abap程序执行的堆栈,包括事件(event),form。。。

    例子代码如下:

    REPORT ztest_stack.
    DATA: num1 TYPE i,
          num2 TYPE i,
          sum  TYPE i.
    
    num1 = 2. num2 = 4.
    PERFORM frm_call.
    
    *&---------------------------------------------------------------------*
    *&      Form  frm_call
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM frm_call.
      sum = num1 + num2.
      PERFORM frm_output.
    ENDFORM.                    "frm_call
    
    *&---------------------------------------------------------------------*
    *&      Form  frm_output
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM frm_output.
      FIELD-SYMBOLS: <fs> TYPE any.
      DATA: l_cstack_tab  TYPE sys_callst,
            ls_cstack_tab LIKE LINE OF l_cstack_tab.
    
      WRITE: / 'Sum of', num1, 'and', num2, 'is', sum.
      CALL FUNCTION 'SYSTEM_CALLSTACK'
        IMPORTING
          et_callstack = l_cstack_tab. " internal table
    * l_cstack_tab 里就是abap的调用堆栈
      WRITE: sy-uline.
      LOOP AT l_cstack_tab INTO ls_cstack_tab.
    
        WRITE: / sy-tabix, ls_cstack_tab-eventtype,  ls_cstack_tab-eventname.
    
        CLEAR: ls_cstack_tab.
      ENDLOOP.
    
    ENDFORM.                    "frm_output

    执行结果,先触发事件 start-of-selection,然后调用frm_call,最后是frm_output.

    2017-02-25_20-13-29

    以上

  • 相关阅读:
    hdu 1142 用优先队列实现Dijkstra
    POJ 2063 Investment 完全背包
    POJ 3260 多重背包+完全背包
    bignum 大数模板
    POJ 3468(树状数组的威力)
    POJ 3468 线段树裸题
    hdu 1058 Humble Numbers
    CodeForces 185A 快速幂
    POJ 1990 MooFest 树状数组
    设计模式(20)策略模式
  • 原文地址:https://www.cnblogs.com/datie/p/11435767.html
Copyright © 2020-2023  润新知