Problem solve Get help with specific problems with your technologies, process and projects.

Simple report variant viewer

Sometimes it is nice to do a quick analysis of the defined variants for an arbitrary ABAP report.

Sometimes it is nice to do a quick analysis of the defined variants for an arbitrary ABAP report, but I do not...

know of any transactions that can do this. That is why I wrote a simple utility program that uses the SAP supplied functions in function group SVAR to select and display a list of variants. A simple "drill down"-functionality allow users to view the full definition of any particular Variant. The user can filter results by program name, variant name, and by the name of the parameter/select-option in code. This program works in R/3 versions 4.6B and 4.7. The functions used are not officially released to customers, so SAP may discontinue offering this functionality in future system revisions.

*&---------------------------------------------------------------------*
*&  Report  YZZ90103A                                                  *
*&---------------------------------------------------------------------*
*&  Report Variant viewer utility                                      *
*&---------------------------------------------------------------------*
REPORT YZZ90103A.


***************************
LOAD-OF-PROGRAM. "EVENT ***
***************************

DATA: report_name  TYPE VARI_REPRT,
      variant_name TYPE VARIANT,
      texts_name   TYPE RVART_VTXT,
      creates_name TYPE SYUNAME,
      changes_name TYPE SYUNAME,
      creates_date TYPE SYDATUM,
      changes_date TYPE SYDATUM,
      field_name   TYPE TVARV_VAL,
      list         TYPE RSVARIINFO OCCURS 0 WITH HEADER LINE,
      params       TYPE RSPARAMS   OCCURS 0 WITH HEADER LINE,
      thisReport   LIKE list-REPORT,
      thisVar      LIKE list-VARIANT,
      found.

SELECT-OPTIONS: reports  FOR report_name,
                variants FOR variant_name,
                texts    FOR texts_name         NO-DISPLAY,
                creates  FOR creates_name       NO-DISPLAY,
                changes  FOR changes_name       NO-DISPLAY,
                createDt FOR creates_date       NO-DISPLAY,
                changeDt FOR changes_date       NO-DISPLAY,
                fields   FOR field_name.


******************************
START-OF-SELECTION. "EVENT ***
******************************

CALL FUNCTION 'RS_VARIANT_INFO'
  TABLES
    PROG_RANGE             = reports
    VAR_RANGE              = variants
    TEXT_RANGE             = texts
    CREATED_BY             = creates
    CHANGED_BY             = changes
    CREADATE               = createDt
    CHANGEDATE             = changeDt
    VARIANT_INFO           = list.

LOOP AT fields.
  TRANSLATE fields TO UPPER CASE.
  MODIFY: fields.
ENDLOOP.


****************************
END-OF-SELECTION. "EVENT ***
****************************

LOOP AT list.
  thisReport = list-REPORT.
  thisVar = list-VARIANT.
  PERFORM FindField. CHECK: NOT found IS INITIAL.
  WRITE: /
  list-REPORT     COLOR 1,
  list-VARIANT    COLOR 2 HOTSPOT,
  list-VTEXT      COLOR 3,
  list-ENVIRONMNT COLOR 4,
  list-PROTECTED  COLOR 5,
  list-ENAME      COLOR 6,
  list-EDAT       COLOR 7,
  list-AENAME     COLOR 1,
  list-AEDAT      COLOR 2,
  list-MANDT      COLOR 3.
  HIDE: thisReport,thisVar.
ENDLOOP.


*****************************
AT LINE-SELECTION. "EVENT ***
*****************************

CALL FUNCTION 'RS_VARIANT_DISPLAY'
  EXPORTING
    REPORT                     = thisReport
    VARIANT                    = thisVar
  EXCEPTIONS
    NO_REPORT                  = 1
    REPORT_NOT_EXISTENT        = 2
    REPORT_NOT_SUPPLIED        = 3
    VARIANT_NOT_EXISTENT       = 4
    VARIANT_NOT_SUPPLIED       = 5
    VARIANT_PROTECTED          = 6
    OTHERS                     = 7.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


"--------------------[ End of EVENT code ]----------------------


*&---------------------------------------------------------------------*
*&      Form  FindField
*&---------------------------------------------------------------------*
*       Filter for Interface fields by name if requested by User.
*----------------------------------------------------------------------*
FORM FindField.

  CLEAR: found.

* Show all Variants if User did not define a field name range.
  IF fields IS INITIAL.
    found = 'X'.
    EXIT.
  ENDIF.

* Look for Variants with content in User defined range of field names.
  CALL FUNCTION 'RS_VARIANT_CONTENTS'
    EXPORTING
      REPORT                      = thisReport
      VARIANT                     = thisVar
    TABLES
      VALUTAB                     = params
    EXCEPTIONS
      VARIANT_NON_EXISTENT        = 1
      VARIANT_OBSOLETE            = 2
      OTHERS                      = 3.
  IF sy-subrc EQ 0.
    LOOP AT params.
      IF params-selname IN fields.
        IF NOT params-low  IS INITIAL. found = 'X'. ENDIF.
        IF NOT params-high IS INITIAL. found = 'X'. ENDIF.
      ENDIF.
    ENDLOOP.
  ELSE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM. "------------------[ FindField ]------------------------
This was last published in October 2003

Dig Deeper on SAP development and programming languages

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchContentManagement

SearchHRSoftware

Close