08-11-2010 1:06 PM
Looking for a way to read the enhancement source code that we have created using SAP's new enhancement framework.<br>
SAP Standard searching program RPR_ABAP_SOURCE_SCAN does not allow us to search enhancement implementation source code, only traditional code. Raising an OSS message about this we were told that this functionality is "out of scope".<br>
<br>In an attempt to write a report that we can use to search all of our enhancement implementation code, I need to be able to load the source code of the enhancement implementations. <br>
<br>
The statement "READ REPORT prog INTO itab." does NOT work with enhancement implementations, and so far my digging around in class CL_ENH_TOOL_HOOK_IMPL-> GET_HOOK_IMPLS return variable ENHANCEMENTS-SOURCE looks promising, however I am not sure how to instantiate this, or even if this is possible seeing as this was written for dialog mode. <br>
<br>
The enhancement implementations DO show up in REPOSRC table, as program Z_SD001====================E (if the enhancement is called Z_SD001 in this example), however I also do not know of a way to take the DATA rawstring field at the end of the REPOSRC table and convert that into report source code. <br>
<br>Any help or direction in being able to read the source code would be greatly appreciated.
<br><br>Regards, <br>Eugene
08-11-2010 5:40 PM
I have found the way to do this:
<br>
<br>The following statement DOES return the code, and you are able to get the enhancement names from the table ENHINCINX-ENHINCLUDE.<br>
<br>
i_progname = 'Z_MM014_CHECKS================E'.
READ REPORT i_progname STATE 'A' INTO r_source_tab
MAXIMUM WIDTH INTO r_width.
04-25-2013 4:14 PM
This is my 'Out of scope' answer. It takes me 20 min....
Create a copy of the program (Enhancements are not allowed!). Replace the method get_report_names( ) in this way...
Best regards
Andreas
alogis AG
method get_report_names.
data:
lt_enhancements type standard table of tadir-obj_name,
lr_enhancement type ref to tadir-obj_name.
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
select obj_name into table gt_object
from tadir
where pgmid = 'R3TR'
and object = 'PROG'
and devclass in devclass. "#EC CI_GENBUFF
select obj_name into table lt_enhancements
from tadir
where pgmid = 'R3TR'
and object = 'ENHO'
and devclass in devclass. "#EC CI_GENBUFF
loop at lt_enhancements reference into lr_enhancement.
concatenate lr_enhancement->* '============================='
into lr_enhancement->*.
lr_enhancement->*+30(10) = 'E'.
endloop.
append lines of lt_enhancements to gt_object.
endmethod.
10-12-2014 6:37 AM
Hi Eugene,
I have developed logic for the same.
START-OF-SELECTION.
PERFORM GET_SOURCE USING 'X' ' ' ' ' 'MV45AFZZ'. "report
PERFORM GET_SOURCE USING ' ' 'X' ' ' 'CL_WB_PGEDITOR'. "Class
PERFORM GET_SOURCE USING ' ' ' ' 'X' 'READ_IBAN_EXT'. "fm
*&---------------------------------------------------------------------*
*& Form GET_SOURCE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->U_PROG text
* -->U_CLASS text
* -->U_FM text
* -->U_NAME text
*----------------------------------------------------------------------*
FORM GET_SOURCE USING U_PROG TYPE BOOLEAN
U_CLASS TYPE BOOLEAN
U_FM TYPE BOOLEAN
U_NAME TYPE STRING.
DATA ABAP_EDITOR TYPE REF TO CL_WB_PGEDITOR.
DATA SOURCE_TAB TYPE SEDI_SOURCE.
DATA SOURCE_NAME TYPE SY-REPID.
DATA LV_COUNT TYPE STRING.
CASE 'X'.
WHEN U_PROG.
SOURCE_NAME = U_NAME.
IF SOURCE_NAME IS NOT INITIAL.
CREATE OBJECT ABAP_EDITOR
EXPORTING
P_IS_IN_ADJUSTMENT_MODE = ' '.
CALL METHOD ABAP_EDITOR->READ_SOURCE
EXPORTING
SOURCE_NAME = SOURCE_NAME
INITIALIZE_EDIT_CONTROL = ' '
STATUS = ' '
WITH_IMPL_ENHANCEMENTS = ' '
SINGLE_ENHNAME = ' '
IMPORTING
SOURCE_TAB = SOURCE_TAB
EXCEPTIONS
NOT_FOUND = 1
CANCELLED = 2
READ_PROTECTED = 3.
LV_COUNT = LINES( SOURCE_TAB ).
WRITE : / LV_COUNT.
REFRESH SOURCE_TAB[].
ENDIF.
WHEN U_CLASS.
DATA CLSKEY TYPE SEOCLSKEY.
DATA INCLUDES TYPE SEOP_METHODS_W_INCLUDE.
DATA LS_INCLUDES LIKE LINE OF INCLUDES.
CLSKEY = U_NAME.
CALL FUNCTION 'SEO_CLASS_GET_METHOD_INCLUDES'
EXPORTING
CLSKEY = CLSKEY
IMPORTING
INCLUDES = INCLUDES
EXCEPTIONS
_INTERNAL_CLASS_NOT_EXISTING = 1.
CASE SY-SUBRC.
WHEN 0.
LOOP AT INCLUDES INTO LS_INCLUDES.
SOURCE_NAME = LS_INCLUDES-INCNAME.
IF SOURCE_NAME IS NOT INITIAL.
CREATE OBJECT ABAP_EDITOR
EXPORTING
P_IS_IN_ADJUSTMENT_MODE = ' '.
CALL METHOD ABAP_EDITOR->READ_SOURCE
EXPORTING
SOURCE_NAME = SOURCE_NAME
INITIALIZE_EDIT_CONTROL = ' '
STATUS = ' '
WITH_IMPL_ENHANCEMENTS = ' '
SINGLE_ENHNAME = ' '
IMPORTING
SOURCE_TAB = SOURCE_TAB
EXCEPTIONS
NOT_FOUND = 1
CANCELLED = 2
READ_PROTECTED = 3.
LV_COUNT = LINES( SOURCE_TAB ).
WRITE : / LV_COUNT.
REFRESH SOURCE_TAB[].
ENDIF.
ENDLOOP.
ENDCASE.
WHEN U_FM.
DATA FUNCNAME TYPE RS38L-NAME.
DATA R3STATE TYPE D010SINF-R3STATE.
DATA PTFDIR TYPE STANDARD TABLE OF TFDIR.
DATA PTFTIT TYPE STANDARD TABLE OF TFTIT.
DATA PFUNCT TYPE STANDARD TABLE OF FUNCT.
DATA PENLFDIR TYPE STANDARD TABLE OF ENLFDIR.
DATA PTRDIR TYPE STANDARD TABLE OF TRDIR.
DATA LS_PTRDIR LIKE LINE OF PTRDIR.
DATA PFUPARAREF TYPE STANDARD TABLE OF SFUPARAREF.
DATA UINCL TYPE STANDARD TABLE OF ABAPTXT255.
FUNCNAME = U_NAME.
CALL FUNCTION 'FUNC_GET_OBJECT'
EXPORTING
FUNCNAME = FUNCNAME
* R3STATE = 'A'
TABLES
PTFDIR = PTFDIR
PTFTIT = PTFTIT
PFUNCT = PFUNCT
PENLFDIR = PENLFDIR
PTRDIR = PTRDIR
PFUPARAREF = PFUPARAREF
UINCL = UINCL
EXCEPTIONS
FUNCTION_NOT_EXIST = 1
VERSION_NOT_FOUND = 2.
CASE SY-SUBRC.
WHEN 0.
READ TABLE PTRDIR INTO LS_PTRDIR INDEX 1.
CASE SY-SUBRC.
WHEN 0.
IF LS_PTRDIR-NAME IS NOT INITIAL.
SOURCE_NAME = LS_PTRDIR-NAME.
IF SOURCE_NAME IS NOT INITIAL.
CREATE OBJECT ABAP_EDITOR
EXPORTING
P_IS_IN_ADJUSTMENT_MODE = ' '.
CALL METHOD ABAP_EDITOR->READ_SOURCE
EXPORTING
SOURCE_NAME = SOURCE_NAME
INITIALIZE_EDIT_CONTROL = ' '
STATUS = ' '
WITH_IMPL_ENHANCEMENTS = ' '
SINGLE_ENHNAME = ' '
IMPORTING
SOURCE_TAB = SOURCE_TAB
EXCEPTIONS
NOT_FOUND = 1
CANCELLED = 2
READ_PROTECTED = 3.
LV_COUNT = LINES( SOURCE_TAB ).
WRITE : / LV_COUNT."Print lines of souce code with enahncement lines as well
REFRESH SOURCE_TAB[].
ENDIF.
ENDIF.
ENDCASE.
ENDCASE.
ENDCASE.
ENDFORM. "get_source
regards,
Rahul Bhayani