Skip to Content

As you all know, in SE37 you can request dependency information for a single function module in which other reports, classes or function modules this one is used. Unfortunately this does not work for BI objects. Often you run in troubles if you change a FM, especially import parameters and then you have to find out manually all possible transformations or DTPs where it has been used. You need to have a good documentation and a up-to-date dependency information in which places you’re function module is used. To make life easier I developed a little ABAP program which looks in all transformations and DTPs where a given function module is used in start-, end-, field- or expert routine. The basic tables for this a RSAABAP which holds the lines of codes for the routines by a key field CODEID. This field is referenced in table RSTRAN in columns for start-, end- and expert routine. For field routines you should look in table RSTRANSTEPROUT, which defines the rules for each transformation.

For DTPs it is a bit more complex, because the ABAP code for filters is not stored in tables, but in the ABAP repository. Nevertheless it’s “easy” to get the filter information in ABAP in only three lines of code. All you have to do is:

data: l_r_rsbk_dtp type ref to cl_rsbk_dtp.
data: l_r_rsbc_filter type ref to cl_rsbc_filter.
data: lt_dtprule type mch_t_sourcecode.
 
      l_r_rsbk_dtp = cl_rsbk_dtp=>factory( ls_dtp-dtp ).
      l_r_rsbc_filter = l_r_rsbk_dtp->if_rsbk_dtp_display~get_obj_ref_filter( ).
      lt_dtprules[] = l_r_rsbc_filter->n_t_dtprule[].

 

Now you can collect the necessary information into an internal table and print it as simple list.

With list features in ABAP you can now directly “jump” into the transformation or the DTP in “Display” mode.

For DTP you simply call function module ‘RSBK_DTP_MAINTAIN’. For transformation you call the static method “start” in Class CL_RSTRAN_GUI. This works even outside AWB!

 
      cl_rstran_gui=>start( EXPORTING i_tranid      = ls_tran_out-tranid
                                      i_r_navigator = l_s_navigator
                                      i_fcode       = 'DISPLAY'
                            EXCEPTIONS OTHERS = 1 ).
 

 l_s_navigator returns the AWB navigator instance.

Here is the complete code:

 

*&---------------------------------------------------------------------*
*& Report  ZBW_DEP_INFO_FM
*&
*&---------------------------------------------------------------------*
*& This report returns dependency information as a simple list
*& of a Function module where to be used in a Transformation
*& as part of start, field- or endroutine or in a filter routine
*& of a DTP
*& Click on the line in the list opens the respective object in display mode
*&
*&---------------------------------------------------------------------*
 
REPORT  zbw_dep_info_fm NO STANDARD PAGE HEADING.
types: begin of g_ty_dtp_output,
           dtp type rsbkdtp-dtp,
           objvers type rsbkdtp-objvers,
           source type rsbkdtp-src,
           target type rsbkdtp-tgt,
           line type rsaabap-line,
     end of g_ty_dtp_output.
 
types: begin of g_ty_trfn_output,
           tranid type rstran-tranid,
           objvers type rstran-objvers,
           source type rstran-sourcename,
           target type rstran-targetname,
           line type rsaabap-line,
     end of g_ty_trfn_output.
 
 
 
DATA: lt_rsaabap TYPE TABLE OF rsaabap.
DATA: ls_abap TYPE rsaabap.
DATA: l_fm_name TYPE char80.
DATA: lt_tran TYPE TABLE OF rstran.
DATA: ls_tran TYPE rstran.
DATA: ls_kurztext TYPE rstrant-txtlg.
DATA: ls_tranrout TYPE rstransteprout.
data: l_ok type i.
data: l_r_rsbk_dtp type ref to cl_rsbk_dtp.
data: l_r_rsbc_filter type ref to cl_rsbc_filter.
data: lt_dtprule type mch_t_sourcecode.
data: ls_dtprule type mch_s_sourcecode.
 
DATA: lt_dtps TYPE TABLE OF rsbkdtp.
data: lt_dtp_out type table of g_ty_dtp_output.
data: ls_dtp_out type g_ty_dtp_output.
data: ls_tran_out type g_ty_trfn_output.
data: lt_tran_out type table of g_ty_trfn_output.
DATA: ls_dtp TYPE rsbkdtp.
DATA: lt_sels TYPE TABLE OF tab512.
DATA: lt_rules TYPE TABLE OF tab512.
DATA: lt_vars TYPE TABLE OF tab512.
DATA: ls_rule TYPE tab512.
 
PARAMETERS: fm_name TYPE char32.
 
END-OF-SELECTION.
  TRY.
      l_ok = 0.
      CALL FUNCTION fm_name.
*     successfull call, fm returns parameters only
    CATCH cx_sy_dyn_call_illegal_func.
      WRITE: 'FM  not found! Chosse another name!'.
      l_ok = 1.
    CATCH cx_sy_dyn_call_illegal_type
          cx_sy_dyn_call_param_not_found
          cx_sy_dyn_call_param_missing.
* FM exists but wrong parameters, that'S ok!
* check call in transformations and DTP.
  ENDTRY.
  IF l_ok = 0.
    CONCATENATE '%' fm_name '%' INTO l_fm_name.
    SELECT * FROM rsaabap
      INTO TABLE lt_rsaabap
      WHERE LINE LIKE l_fm_name
        AND objvers = 'A'.
    IF sy-subrc = 0.
      WRITE: 'FM ', fm_name, ' found in following transformations:'.
      NEW-LINE.
      WRITE: AT 1 'Transformation', AT 55 'A/M', AT 60 'Position', AT 100 'Source -> Target'.
      ULINE.
      NEW-LINE.
      LOOP AT lt_rsaabap INTO ls_abap.
       REFRESH lt_tran.
        SELECT * FROM rstran
          INTO TABLE lt_tran
          WHERE startroutine = ls_abap-codeid
           OR expert = ls_abap-codeid
           OR endroutine = ls_abap-codeid.
*              AND objvers = 'A'.
        IF sy-subrc = 0.
          LOOP AT lt_tran INTO ls_tran.
*              select single txtlg into ls_kurztext
*                from rstrant
*                where tranid = ls_tran-tranid
*                  and langu = 'E'
*                 and objvers = ls_tran-objvers.
            ls_tran_out-tranid = ls_tran-tranid.
            ls_tran_out-objvers = ls_tran-objvers.
            ls_tran_out-target = ls_tran-targetname.
            ls_tran_out-source = ls_tran-sourcename.
            IF ls_tran-expert = ls_abap-codeid.
              WRITE: AT 1 ls_tran-tranid, AT 55 ls_tran-objvers, AT 60 'Expertroutine', AT 100 ls_tran-sourcename(10), '-->', ls_tran-targetname(10).
              ls_tran_out-line = 'Expertenroutine'.
            ELSEIF ls_tran-startroutine = ls_abap-codeid.
              WRITE: ls_tran-tranid, AT 55 ls_tran-objvers, AT 60 'Startroutine', AT 100  ls_tran-sourcename(10), '-->', ls_tran-targetname(10).
              ls_tran_out-line = 'Expertenroutine'.
            ELSEIF ls_tran-endroutine = ls_abap-codeid.
              WRITE: ls_tran-tranid, AT 55 ls_tran-objvers, AT 60 'Endroutine', AT 100  ls_tran-sourcename(10), '-->', ls_tran-targetname(10).
              ls_tran_out-line = 'Expertenroutine'.
            ENDIF.
            append ls_tran_out to lt_tran_out.
            NEW-LINE.
          ENDLOOP.
        ELSE.
*         search in field routines of transformation:
          SELECT tranid FROM rstransteprout
            INTO ls_tranrout
            WHERE codeid = ls_abap-codeid.
            SELECT * FROM rstran
              INTO TABLE lt_tran
              WHERE tranid = ls_tranrout-tranid.
            LOOP AT lt_tran INTO ls_tran.
              ls_tran_out-tranid = ls_tran-tranid.
              ls_tran_out-objvers = ls_tran-objvers.
              ls_tran_out-target = ls_tran-targetname.
              ls_tran_out-source = ls_tran-sourcename.
              ls_tran_out-line = 'Fieldroutine'.
              WRITE: AT 1 ls_tran-tranid, AT 55 ls_tran-objvers, AT 60 'Fieldroutine', AT 100 ls_tran-sourcename(10), '->', ls_tran-targetname(10).
              append ls_tran_out to lt_tran_out.
              NEW-LINE.
            ENDLOOP.
          ENDSELECT.
        ENDIF.
      ENDLOOP.
      IF sy-subrc <> 0.
        WRITE: 'FM not found in any transforamation!'.
      ENDIF.
    ENDIF.
* Filter for DTPs:
 
    SKIP.
    SKIP.
    SKIP.
    WRITE: 'FM ', fm_name, ' found in following DTPs as filter:'.
    NEW-LINE.
    WRITE: AT 1 'DTP', AT 55 'A/M', AT 60 'Source -> Target', at 100 'Characteristic'.
    ULINE.
    NEW-LINE.
 
    SELECT dtp objvers src tgt FROM rsbkdtp
      INTO CORRESPONDING FIELDS OF TABLE lt_dtps
      WHERE objvers = 'A'
        OR  objvers = 'M'.
    LOOP AT lt_dtps INTO ls_dtp.
 
      REFRESH: lt_sels, lt_rules, lt_vars.
 
 
      l_r_rsbk_dtp = cl_rsbk_dtp=>factory( ls_dtp-dtp ).
      l_r_rsbc_filter = l_r_rsbk_dtp->if_rsbk_dtp_display~get_obj_ref_filter( ).
      lt_dtprule[] = l_r_rsbc_filter->n_t_dtprule[].
      LOOP AT lt_dtprule INTO ls_dtprule.
        IF ls_dtprule-line CS fm_name.
          ls_dtp_out-dtp = ls_dtp-dtp.
          ls_dtp_out-objvers = ls_dtp-objvers.
          ls_dtp_out-target = ls_dtp-tgt.
          ls_dtp_out-source = ls_dtp-src.
          concatenate ls_dtp-src '->' ls_dtp-tgt into ls_dtp_out-line.
          WRITE: AT 1 ls_dtp-dtp, AT 55 ls_dtp-objvers, AT 60 ls_dtp-src(15), '->', ls_dtp-tgt(15), at 100 ls_dtprule-field.
          append ls_dtp_out to lt_dtp_out.
          NEW-LINE.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
 
  ENDIF.
 
at LINE-SELECTION.
  type-POOLS: RSBC.
  data: ls_tran_lines type i.
  data: ls_tran_lines2 type i.
  data: ls_dtp_lines type i.
  data: ls_dtp_lines2 type i.
  data: ls_dtp_lines3 type i.
  data: ls_dtp_ind type sy-tabix.
  data: ls_tran_ind type sy-tabix.
  data: l_s_navigator type ref to CL_RSAWBN_AWB.
 
  describe table lt_tran_out lines ls_tran_lines.
  describe table lt_dtp_out lines ls_dtp_lines.
  ls_tran_lines2 = ls_tran_lines + 3.
  ls_dtp_lines2 = ls_tran_lines2 + 6.
  ls_dtp_lines3 = ls_dtp_lines2 + ls_dtp_lines.
  if sy-curow > 3 and sy-curow <= ls_tran_lines2.
    clear ls_traN_out.
    ls_tran_ind = sy-curow - 3.
    read table lt_traN_out into ls_tran_out index ls_tran_ind.
    if sy-subrc = 0.
*    create object l_s_navigator.
*    cl_rsawbn_awb=>start( i_view = 'M' ).
      cl_rstran_gui=>start( EXPORTING i_tranid      = ls_tran_out-tranid
                                      i_r_navigator = l_s_navigator
                                      i_fcode       = 'DISPLAY'
                            EXCEPTIONS OTHERS = 1 ).
    endif.
  elseif sy-curow > ls_dtp_lines2 and sy-curow <= ls_dtp_lines3.
    clear ls_tran_out.
    ls_dtp_ind = sy-curow - ls_dtp_lines2.
    read table lt_dtp_out into ls_dtp_out index ls_dtp_Ind.
    if sy-subrc = 0.
      call function 'RSBK_DTP_MAINTAIN'
        EXPORTING
          i_dtp  = ls_dtp_out-dtp
          i_mode = RSBC_C_MODE-DISPLAY.
    endif.
  endif.
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply