Skip to Content

So, this is my code for searching for variant values.  I started this when I learned that others had been writing hard coded paths into variants.  When we copied Production to Development, the paths on Development pointed to Production directories and mayhem resulted.  I wrote this to find them.

*&---------------------------------------------------------------------*
*& Report  Z_FIND_VARI_CONTENT
*&
*&---------------------------------------------------------------------*
REPORT  z_find_vari_content
          NO STANDARD PAGE HEADING
          MESSAGE-ID zsd
          LINE-SIZE 200
          LINE-COUNT 65.
TABLES: varid,
        varit,
        tvarvc,
        rsparams.
SELECT-OPTIONS:
       s_rpt   FOR vari-report,
       s_varnt FOR vari-variant.
PARAMETERS:
       p_value LIKE rsparams-low.
DATA:
       t_report1 LIKE trdir-name.
TYPES: BEGIN OF ty_parms.
        INCLUDE STRUCTURE rsparams.
TYPES  END OF ty_parms.
TYPES: BEGIN OF ty_vari_drop,
         report LIKE vari-report,
         variant LIKE vari-variant,
       END OF ty_vari_drop.
TYPES: BEGIN OF ty_vari_data,
         report LIKE vari-report,
         variant LIKE vari-variant,
         value LIKE rsparams-low,
       END OF ty_vari_data.
TYPES: BEGIN OF ty_vari_sel,
         report LIKE varid-report,
         variant LIKE varid-variant,
         ename LIKE varid-ename,
         aedat LIKE varid-aedat,
       END OF ty_vari_sel.
TYPES:
        tt_vari_drop TYPE STANDARD TABLE OF ty_vari_drop,
        tt_vari_data TYPE STANDARD TABLE OF ty_vari_data,
        tt_vari_sel TYPE STANDARD TABLE OF ty_vari_sel,
        tt_parms TYPE STANDARD TABLE OF ty_parms.
DATA:
        i_vari_drop TYPE tt_vari_drop,
        i_vari_data TYPE tt_vari_data,
        i_vari_sel TYPE tt_vari_sel,
        i_valu_tab TYPE tt_parms.
DATA:
        wa_tvarvc TYPE tvarvc,
        wa_vari_drop TYPE ty_vari_drop,
        wa_vari_data TYPE ty_vari_data,
        wa_vari_sel TYPE ty_vari_sel,
        wa_valu_tab TYPE ty_parms.
************************************************************************
*                    START-OF-SELECTION                                *
************************************************************************
START-OF-SELECTION.
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF wa_tvarvc FROM tvarvc
         WHERE name = 'Z_FIND_VARI_CONTENT'
           AND type = 'P'
           AND numb = '0000'.
  SELECT report variant ename edat
         INTO CORRESPONDING FIELDS OF TABLE i_vari_sel
         FROM varid
         WHERE report IN s_rpt
           AND variant IN s_varnt.
  SORT i_vari_sel BY report variant.
  LOOP AT i_vari_sel INTO wa_vari_sel.
    MOVE wa_vari_sel-report TO wa_tvarvc-low.
    UPDATE tvarvc FROM wa_tvarvc.
    COMMIT WORK AND WAIT.
    if wa_tvarvc-low = 'NIL'.
*     break nwilhite.
    endif.
    SELECT SINGLE name INTO (t_report1) FROM trdir
           WHERE name = wa_vari_sel-report
             AND uccheck = 'X'.
    IF sy-subrc IS INITIAL.
      SELECT SINGLE * FROM vari
                           WHERE relid   = 'VB'
                           AND   report  = wa_vari_sel-report
                           AND   variant = wa_vari_sel-variant.
      IF sy-subrc <> 0.
        CONTINUE.
      ENDIF.
      CALL FUNCTION 'RS_VARIANT_CONTENTS'
        EXPORTING
          report                      = wa_vari_sel-report
          variant                     = wa_vari_sel-variant
*          MOVE_OR_WRITE               = 'W'
*          NO_IMPORT                   = ' '
*          EXECUTE_DIRECT              = ' '
*        IMPORTING
*          SP                          =
        TABLES
*          L_PARAMS                    =
*          L_PARAMS_NONV               =
*          L_SELOP                     =
*          L_SELOP_NONV                =
          valutab                     = i_valu_tab
*          OBJECTS                     =
*          FREE_SELECTIONS_DESC        =
*          FREE_SELECTIONS_VALUE       =
       EXCEPTIONS
         variant_non_existent        = 1
         variant_obsolete            = 2
         OTHERS                      = 3.
      IF sy-subrc <> 0.
        CASE sy-subrc.
          WHEN '1'.
            MESSAGE ID 'Z1' TYPE 'S' NUMBER '0000'
                    WITH 'non-exestient for:' wa_vari_sel-report wa_vari_sel-variant.
          WHEN '2'.
            MESSAGE ID 'Z1' TYPE 'S' NUMBER '0000'
                    WITH 'obsolete for:' wa_vari_sel-report wa_vari_sel-variant.
          WHEN OTHERS.
            MESSAGE ID 'Z1' TYPE 'S' NUMBER '0000'
                    WITH 'other error for:' wa_vari_sel-report wa_vari_sel-variant.
        ENDCASE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        LOOP AT i_valu_tab INTO wa_valu_tab.
          MOVE wa_vari_sel-report TO wa_vari_data-report.
          MOVE wa_vari_sel-variant TO wa_vari_data-variant.
          MOVE wa_valu_tab-low TO wa_vari_data-value.
          IF wa_vari_data-value IS INITIAL.
          ELSE.
            APPEND wa_vari_data TO i_vari_data.
          ENDIF.
          MOVE wa_valu_tab-high TO wa_vari_data-value.
          IF wa_vari_data-value IS INITIAL.
          ELSE.
            APPEND wa_vari_data TO i_vari_data.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDIF.
    CLEAR wa_valu_tab.
    REFRESH i_valu_tab.
  ENDLOOP.
  MOVE 'NIL' TO wa_tvarvc-low.
  UPDATE tvarvc FROM wa_tvarvc.
* break nwilhite.
  LOOP AT i_vari_data INTO wa_vari_data.
    IF wa_vari_data-value CS p_value.
      WRITE: /001 wa_vari_data-report, wa_vari_data-variant, wa_vari_data-value.
    ENDIF.
  ENDLOOP.

Now, with some tweaks, we should be also able to search for accesses to TVARVC for variant values.

More to follow:

Neal

To report this post you need to login first.

1 Comment

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

Leave a Reply