Friday, December 18, 2009
Variant Creation At Runtime
DATA : l_variant TYPE rsvar-variant ,
l_s_vari_desc TYPE varid,
l_t_vari_contents TYPE STANDARD TABLE OF rsparams,
l_s_vari_contents TYPE rsparams,
l_t_vari_text TYPE STANDARD TABLE OF varit,
l_s_vari_text TYPE varit.
l_variant = 'NAME_OF_VARIANT'.
*** Main data
l_s_vari_desc-mandt = sy-mandt.
l_s_vari_desc-report = 'REPORT_NAME'.
l_s_vari_desc-variant = l_variant.
l_s_vari_desc-flag1 = space.
l_s_vari_desc-flag2 = space.
l_s_vari_desc-transport = 'F'.
l_s_vari_desc-environmnt = 'B'. "Variant for background
l_s_vari_desc-protected = space.
l_s_vari_desc-secu = space.
l_s_vari_desc-version = '1'.
l_s_vari_desc-ename = sy-uname.
l_s_vari_desc-edat = sy-datum.
l_s_vari_desc-etime = sy-uzeit.
l_s_vari_desc-aename = space.
l_s_vari_desc-aedat = space.
l_s_vari_desc-aetime = space.
l_s_vari_desc-mlangu = sy-langu.
*** CONTENTS
l_s_vari_contents-selname = 'S_SELOPT'.
l_s_vari_contents-kind = 'S'.
l_s_vari_contents-sign = 'I'.
l_s_vari_contents-option = 'CP'.
l_s_vari_contents-low = 'A*'.
APPEND l_s_vari_contents TO l_t_vari_contents.
l_s_vari_contents-selname = 'P_BUKRS'.
l_s_vari_contents-kind = 'P'.
l_s_vari_contents-sign = 'I'.
l_s_vari_contents-option = 'EQ'.
l_s_vari_contents-low = 'AABB'.
APPEND l_s_vari_contents TO l_t_vari_contents.
*** Description
l_s_vari_text-mandt = sy-mandt.
l_s_vari_text-langu = sy-langu.
l_s_vari_text-report = 'REPORT_NAME'.
l_s_vari_text-variant = l_variant.
l_s_vari_text-vtext = l_variant.
APPEND l_s_vari_text TO l_t_vari_text.
*** Del variant if any exists with the same name (Optional)
CALL FUNCTION 'RSAQ_DELETE_ONE_VARIANT'
EXPORTING
report = 'REPORT_NAME'
variant = l_variant
* IMPORTING
* SUBC =
EXCEPTIONS
not_authorized = 1
not_executed = 2
no_report = 3
report_not_existent = 4
report_not_supplied = 5
variant_locked = 6
OTHERS = 7
.
CALL FUNCTION 'RS_CREATE_VARIANT'
EXPORTING
curr_report = 'REPORT_NAME'
curr_variant = l_variant
vari_desc = l_s_vari_desc
TABLES
vari_contents = l_t_vari_contents
vari_text = l_t_vari_text
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_exists = 7
variant_locked = 8
OTHERS = 9.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment