FUNCTION zca_set_sc_variant.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_REPID) TYPE REPID
*" REFERENCE(IV_UNAME) TYPE UNAME
*" REFERENCE(IV_USERSPECIFIC) TYPE BOOLEAN_FLG DEFAULT 'X'
*"----------------------------------------------------------------------
DATA : lt_varid TYPE TABLE OF varid WITH HEADER LINE.
DATA : lt_where TYPE TABLE OF string,
lv_text TYPE char100.
*--- Set User specific variant or lastest
IF iv_userspecific IS NOT INITIAL.
CONCATENATE `'U_` iv_uname `'` INTO lv_text.
CONCATENATE 'VARIANT = ' lv_text
INTO lv_text
SEPARATED BY space.
APPEND lv_text TO lt_where.
ENDIF.
SELECT *
FROM varid
INTO CORRESPONDING FIELDS OF TABLE lt_varid
WHERE report EQ iv_repid
AND ename EQ iv_uname
AND (lt_where).
SORT lt_varid DESCENDING BY edat etime.
CHECK lt_varid[] IS NOT INITIAL.
READ TABLE lt_varid INDEX 1.
CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
EXPORTING
report = iv_repid
variant = lt_varid-variant
EXCEPTIONS
variant_not_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFUNCTION.