Syntax error Source code of ABAP reports without restriction

Source code of ABAP reports without restriction



If you have to use RFC, you can write RFC enabled function module. You can write a new FM that allows you to retrieve program source code. To start with, you need to create a structure as shown in below and based on which you have to create a table type. This table can be passed to a RFC function.


Here shows a table type that you can use in Function Module:

Next step is to create a function module with RFC-enabled. You have to pass parameters while creating function module.

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.

You can call this Function module to extract program source information and index them. Refer to link for more details −

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

Updated on: 2020-02-14T08:00:24+05:30

485 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements