ABAP学习(32):ABAP Source Scan

ABAP Source Scan

ABAP提供Report扫描程式,Program:RS_ABAP_SOURCE_SCAN

定义Class:lcl_source_scan;

主要方法:

get_source_names,获取各种类型代码源代码object name;

get_report_names,获取report类型源代码object name;

get_function_names,获取function类型源代码object name;

get_class_names,获取class类型源代码object name;

get_interface_names,获取interface类型源代码object name;

get_includes,获取include类型源代码object name;

示例:添加Web Dynpro Application程式扫描方法

Selection Screen中添加Web Component名输入框,wdaname保存输入的component name;

BEGIN OF BLOCK a14.
SELECT-OPTIONS    wdaname FOR wdy_wb_geninfo-component_name.
SELECTION-SCREEN: END OF BLOCK a14,

在Selection Screen中package选项添加是否检查wda check box,表示直接查询package时,是否扫描package中wda代码;

SELECT-OPTIONS    devclass FOR tadir-devclass.
PARAMETERS        p_cwda TYPE char1 AS CHECKBOX .
SELECTION-SCREEN: END OF BLOCK a11,

class中添加 get_wda_names方法,其中WDA程式在table:tadir中object类型为WDYN

  METHOD get_wda_names.
    DATA:lt_wdaid TYPE STANDARD TABLE OF WDY_COMPONENT_NAME.
    DATA:ls_wdaid TYPE WDY_COMPONENT_NAME.
    DATA:lt_wb_geninfo TYPE STANDARD TABLE OF WDY_WB_GENINFO.
    DATA:ls_wb_geninfo TYPE WDY_WB_GENINFO.
    DATA:lt_r_actname TYPE RANGE OF trdir-name.
    DATA:ls_r_actname LIKE LINE OF lt_r_actname.

    IF wdaname[] IS NOT INITIAL.
      "根据component,WDA对应的WDA程式id
      SELECT * FROM wdy_wb_geninfo APPENDING TABLE lt_wb_geninfo
        WHERE component_name IN wdaname
         AND controller_name = space.
    ENDIF.

    IF p_cwda = 'X'.
      "通过package,获取package中WDA程式
      SELECT obj_name INTO TABLE lt_wdaid
         FROM tadir
         WHERE pgmid  = 'R3TR'
         AND   object = 'WDYN'
         AND   devclass IN devclass.                       "#EC CI_GENBUFF
      IF lt_wdaid IS INITIAL.
        EXIT.
      ENDIF.
      "WDA对应的WDA程式id
      SELECT * FROM wdy_wb_geninfo APPENDING TABLE lt_wb_geninfo
        FOR ALL ENTRIES IN lt_wdaid
        WHERE component_name = lt_wdaid-table_line
         AND controller_name = space.
    ENDIF.
   "实际WDA对应的WDA程式id,/1BCWDY/开头
    LOOP AT lt_wb_geninfo INTO ls_wb_geninfo.
      CLEAR ls_r_actname.
      ls_r_actname+0(3) = 'ICP'.
      ls_r_actname-low = '/1BCWDY/' && ls_wb_geninfo-guid && '*'.
      APPEND ls_r_actname TO lt_r_actname.
    ENDLOOP.
    SORT lt_r_actname.
    DELETE ADJACENT DUPLICATES FROM lt_r_actname.

    SELECT name APPENDING TABLE gt_object
       FROM trdir
       WHERE name IN lt_r_actname.

  ENDMETHOD.  "get_wda_names

修改get_source_names方法,添加get_wda_names逻辑

    IF devclass[] IS NOT INITIAL.
      get_report_names( ).
      get_function_names( ).
      get_class_names( ).
      get_interface_names( ).
    "查询package时,添加查询wda source code
      IF p_inwda = 'X'.
        get_wda_names( ).
      ENDIF.
    ENDIF.
  "新增wda source code查询
    IF wdaname[] IS NOT INITIAL.
      get_wda_names( ).
    ENDIF.

 

posted @ 2022-04-09 10:33  渔歌晚唱  阅读(207)  评论(0编辑  收藏  举报