Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Read source code in BAdi

Former Member
0 Likes
489

Hi All,

Is there any syntax or method to read the source code contains in a BAdi? Which is similar to the functionality of syntax READ REPORT which is use to read the source code in a program.

I need to read the source code and then look for particular syntax in it by a keyword.

Thanks.

1 REPLY 1
Read only

Former Member
0 Likes
378

This snipped of my scan report might be helpful....

Cheers

carsten

      • Get Interface Name for BADIs

SELECT * FROM sxs_inter INTO TABLE gt_sxs_inter

WHERE exit_name IN s_badi.

CHECK sy-subrc EQ 0.

      • Get Implementation Names for BADIs

SELECT * FROM sxc_exit INTO TABLE gt_sxc_exit

FOR ALL ENTRIES IN gt_sxs_inter

WHERE exit_name EQ gt_sxs_inter-exit_name.

      • Get implemented Classes for Interfaces

SELECT * FROM sxc_class INTO TABLE gt_sxc_class

FOR ALL ENTRIES IN gt_sxs_inter

WHERE inter_name EQ gt_sxs_inter-inter_name.

      • Get Methods for Interfaces

LOOP AT gt_sxs_inter.

gv_cifkey = gt_sxs_inter-inter_name.

CALL FUNCTION 'SEO_METHOD_READ_ALL'

EXPORTING

cifkey = gv_cifkey

IMPORTING

methods = gt_meth1[]

EXCEPTIONS

clif_not_existing = 1

OTHERS = 2.

APPEND LINES OF gt_meth1 TO gt_meth. .

ENDLOOP.

gt_meth1[] = gt_meth[].

CLEAR: gt_meth, gt_meth[].

LOOP AT gt_sxs_inter.

LOOP AT gt_sxc_class

WHERE inter_name EQ gt_sxs_inter-inter_name.

LOOP AT gt_meth1

WHERE clsname EQ gt_sxs_inter-inter_name.

      • Get Include names for Interface Methods

gt_meth-clsname = gt_sxc_class-imp_class.

CONCATENATE gt_meth1-clsname '~' gt_meth1-cmpname

INTO gt_meth-cmpname.

APPEND gt_meth.

      • Makro METHOD_TO_INCLUDE ?

  • SYSTEM-CALL QUERY METHOD gs_mtdkey-cpdname

  • OF CLASS gs_mtdkey-clsname

  • INCLUDE INTO gv_filenam. " NO DBLOCK. "470

  • if gv_filenam ne space.

  • s_repid-low = gv_filenam.

  • s_repid-option = 'EQ'.

  • s_repid-sign = 'I'.

  • append s_repid.

  • endif.

ENDLOOP.

ENDLOOP.

ENDLOOP.

ENDIF.

LOOP AT gt_meth.

gs_mtdkey-clsname = gt_meth-clsname.

gs_mtdkey-cpdname = gt_meth-cmpname.

      • Makro METHOD_TO_INCLUDE ?

SYSTEM-CALL QUERY METHOD gs_mtdkey-cpdname

OF CLASS gs_mtdkey-clsname

INCLUDE INTO gv_filenam. " NO DBLOCK. "470

IF sy-subrc EQ 0.

APPEND gv_filenam TO gt_incl.

  • READ REPORT gv_filenam INTO gt_source.

PERFORM read_report USING gv_filenam.

PERFORM scan_source TABLES gt_source

USING gv_filenam '' gt_meth-clsname gt_meth-cmpname

gv_filenam 'METH' 0.

IF p_hist NE space.

PERFORM scan_hist_source USING gt_meth-clsname

gt_meth-cmpname gv_filenam 'METH'.

ENDIF.

ENDIF.

      • Find 'hidden' (redefinitons etc) methods via

      • TRDIR-includes for class not yet found

AT END OF clsname.

PERFORM check_incl_meth USING gt_meth-clsname.

LOOP AT gt_incl.

gv_prognam = gt_incl.

gs_clskey-clsname = gt_meth-clsname.

      • Get MethName via Include

SYSTEM-CALL QUERY METHOD INCLUDE FROM gv_prognam

CLASS INTO gs_clskey-clsname

METHOD INTO gv_mtdname.

CHECK sy-subrc EQ 0.

READ REPORT gt_incl INTO gt_source.

  • perform read_report using gt_incl.

PERFORM scan_source TABLES gt_source

USING gt_incl '' gt_meth-clsname gv_mtdname

gt_incl 'METH' 0.

IF p_hist NE space.

PERFORM scan_hist_source USING gt_meth-clsname

gv_mtdname gt_incl 'METH'.

ENDIF.

ENDLOOP.

REFRESH gt_incl.

ENDAT.

ENDLOOP.