SAP/ABAP

Set initial Screen Variant for Report

Denise 2014. 12. 3. 08:52
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.

'SAP > ABAP' 카테고리의 다른 글

Long Text 처리  (0) 2015.08.11
Check if Function call is RFC or Not.  (0) 2015.07.09
how to call BAPI_ALM_ORDER_MAINTAIN  (0) 2014.11.27
Save Smartform Output in PDF format without code  (0) 2014.11.19
Remove special char using hex or char.  (0) 2014.11.19