ABAP 報告的原始碼無限制


如果您必須使用 RFC,可以編寫啟用 RFC 的函式模組。您可以編寫一個新的 FM,以便檢索程式原始碼。首先,您需要建立一個如下所示的結構,然後基於該結構建立一個表型別。此表可以傳遞給 RFC 函式。


以下是您可以在函式模組中使用的表型別

下一步是建立一個啟用 RFC 的函式模組。建立函式模組時必須傳遞引數。

function zsrcex_extractor .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PACKAGE_SIZE) TYPE  I DEFAULT 250
*"     VALUE(SELECT_AFTER) TYPE  PROGNAME OPTIONAL
*"     VALUE(LANGU) TYPE  SYLANGU DEFAULT SY-LANGU
*"  EXPORTING
*"     VALUE(EXTRACT) TYPE  ZSRCEX_T
*"     VALUE(NO_MORE_DATA) TYPE  CHAR1
*"----------------------------------------------------------------------
 
  data: table_lines type i.
  statics: last_progname type progname.
  statics: s_no_more_data type char1.
  data: progs type table of progname with header line.
  data: extract_line type zsrcex.
  data: texts type table of textpool with header line.
  data: source type table of text1000 with header line.
  data: nl type abap_char1 value cl_abap_char_utilities=>newline.
  data: tab type abap_char1 value cl_abap_char_utilities=>horizontal_tab.
  clear: extract[].
* If we have previously (from last call) determined that there
* is no more data, exit the function
  if s_no_more_data = 'X'.
    no_more_data = 'X'. "Keep informing caller
    return.
  endif.
* Start selecting after specified program name, if supplied
  if not select_after is initial.
    last_progname = select_after.
  endif.
* Read a number of source objects specified by package_size
  select progname from reposrc
    into table progs
    up to package_size rows
    where progname > last_progname
* This list is probably not comprehensive,
* it's just for demonstration purposes:
      and ( progname like 'Z%' or progname like 'Y%'
      or progname like 'SAPMZ%' or progname like 'SAPMY%'
      or progname like 'SAPLZ%' or progname like 'SAPLY%'
      or progname like 'LZ%' or progname like 'LY%' )
* To retrieve EVERYTHING, just comment out the above 4 lines
      and r3state = 'A'. "Active sources only
* Check whether we should stop selecting yet
  describe table progs lines table_lines.
  if table_lines lt package_size.
    s_no_more_data = 'X'.
  endif.
* Process the selected programs
  loop at progs.
    clear: extract_line, texts[].
    extract_line-progname = progs.
* The following does not work e.g. for type pools
    read report progs into source.
    read textpool progs into texts language langu.
* Don't pass back programs with neither texts not source
    if source[] is initial and texts[] is initial.
      continue.
    endif.
* Put source into one string into EXTRACT
    loop at source.
      concatenate extract_line-source source nl into extract_line-source.
    endloop.
* Put texts into single string
    loop at texts.
      concatenate extract_line-texts texts-id tab texts-key tab
                  texts-entry nl
                  into extract_line-texts.
    endloop.
* Store program title separately
    read table texts with key id = 'R'.
    if sy-subrc = 0.
      extract_line-title = texts-entry.
    endif.
    append extract_line to extract.
  endloop.
* Return determined value of no_more_data indicator
  no_more_data = s_no_more_data.
endfunction.

您可以呼叫此函式模組來提取程式源資訊併為其編制索引。有關更多詳細資訊,請參閱連結 -

http://ceronio.net/2009/06/improved-abap-source-code-search/

更新於:14-Feb-2020

366 次瀏覽

開啟你的職業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.