2

I would like to retrieve programmatically the source code of the ABAP programs generated using BW.

I would like to have an ABAP program that can retrieve BADIs source using their name as parameter and then save on local disk the source saving each BADI in a file with the name of the program.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
bidi
  • 150
  • 1
  • 14

2 Answers2

1

If you know the name of an implementation, you have to lookup the name of the implementing class. Depending on the BAdI type (classic or fast kernel), you'll have to use different routines to read the class name (try function module SXO_IMPL_FOR_BADI_READ and read the coding of class CL_ENH_BADI_RUNTIME_FUNCTIONS method GET_BADI_SHORTTEXT to get an idea of how to work with the various BAdI types). Then, take a look at the function modules named SEO* - you'll find all the stuff you need to read the structure of a class, its superclasses and its methods (just exporting the source code is not enough, right?).

vwegert
  • 18,371
  • 3
  • 37
  • 55
0

You can achieve this in this way:

SELECT class_name
  INTO TABLE @DATA(lt_badi)
  FROM badi_impl
 WHERE badi_name = 'value'. " <- your badi name

LOOP AT lt_badi ASSIGNING FIELD-SYMBOL(<badi_class>).

  DATA(lo_instance) =  cl_oo_factory=>create_instance( ).
  DATA(lo_source) = lo_instance->create_clif_source( clif_name = CONV string( <badi_class> )
                                                     version   = 'A' ).
  lo_source->get_source( IMPORTING source = DATA(rt_source) ).

ENDLOOP.

Saving internal table with source to file is trivial.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90