Cancel variant protection or Uncheck protection checkbox for variant.


Problem:
How do you take the Protect Variant off.
We have created transportable variants using variant prefix CUS& and it automatically selects the protect variant checkbox.  You cannot deselect it and so only the user can change this variant.
I have tried Program RSVARENT which is supposed to cancel variant protection but this did not work.
Protect variant:
If you select this option, the variant can only be changed by the
person who created it or the last person to change it. If you start
a program using a protected variant, none of the fields on the
selection screen accept user input.

 Solution:

*&———————————————————————*
*& Report  ZCV_RSVARENT
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT  zrsvarent_partha.

TABLES: varid,rsvar.

DATA: i_varid TYPE STANDARD TABLE OF varid WITH HEADER LINE.

SELECT-OPTIONS: s_report FOR rsvarreport,
                s_vari   FOR rsvarvariant.
PARAMETERS: p_mandt  LIKE symandt OBLIGATORY DEFAULT ‘000’.

START-OF-SELECTION.

  SELECT * INTO TABLE i_varid
  FROM varid CLIENT SPECIFIED
  WHERE mandt     =  p_mandt
    AND report    IN s_report
    AND variant   IN s_vari
    AND protected NE space .

  IF sysubrc = 0.
    LOOP AT i_varid.
      CLEAR i_varidprotected.
      IF NOT  i_varidvariant(4) EQ ‘SAP&’
         AND NOT i_varidvariant(4) EQ ‘CUS&’.
        MOVE ‘F’ TO i_varidtransport.
      ENDIF.
      MODIFY i_varid.
    ENDLOOP.
    MODIFY varid CLIENT SPECIFIED FROM TABLE i_varid .
    WRITE:/ ‘SY-SUBRC = ‘ , sysubrc.
    WRITE:/ ‘No. of records updated = ‘ , sydbcnt.
    COMMIT WORK.
  ELSE.
    WRITE:/ ‘No records found for the selection criteria.’.
  ENDIF.

Inputs:

S_REPORT – Report/Program name.
S_VARI – Variant name.
P_MANDT – NO CHANGE (Let it be as ‘000’).
Run the program.
Hurray .. !! The variant is now with protected check box unchecked.  🙂

Leave a Reply

Your email address will not be published. Required fields are marked *