In this case , just before submitting the program , we can change the variant data . After gathering data we change back the variant. By the help of functions below , we kept the variant unchanged .
DATA : program TYPE rsvar-report ,
variant TYPE rsvar-variant.
DATA : lv_rc TYPE i.
DATA : variant_backup TYPE TABLE OF rsparams .
DATA : lt_values TYPE TABLE OF rsparams ,
ls_values LIKE LINE OF lt_values,
lt_objects TYPE TABLE OF vanz .
DATA : ls_varid TYPE varid.
DATA : lt_backup TYPE TABLE OF rsparams .
program = ‘ZZZ_PROG’.
variant = ‘ZZZ_VARI’.
CALL FUNCTION ‘RS_VARIANT_CONTENTS’
EXPORTING
report = program
variant = variant
TABLES
valutab = lt_values[]
OBJECTS = lt_objects[]
EXCEPTIONS
variant_non_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR : lt_backup[] , variant_backup[].
LOOP AT lt_values INTO ls_values
WHERE selname = ‘YOUR_SELECTION_FIELD’.
*** HERE YOU CAN ADD/MODIFY/DELETE SELECTION DATA
ls_values-low = ‘1234′.
APPEND ls_values TO lt_backup.
ENDLOOP.
*** BACKUP
variant_backup[] = lt_backup[].
CALL FUNCTION ‘RS_CHANGE_CREATED_VARIANT’
EXPORTING
curr_report = program
curr_variant = variant
vari_desc = ls_varid
only_contents = ‘X’
TABLES
vari_contents = lt_values[]
* VARI_TEXT =
* VARI_SEL_DESC =
OBJECTS = lt_objects[]
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_doesnt_exist = 7
variant_locked = 8
selections_no_match = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR : exists.
CALL FUNCTION ‘RS_VARIANT_EXISTS’
EXPORTING
report = program
variant = variant
IMPORTING
r_c = lv_rc
EXCEPTIONS
not_authorized = 1
no_report = 2
report_not_existent = 3
report_not_supplied = 4
OTHERS = 5.
IF sy-subrc EQ 0 AND lv_rc EQ 0.
SUBMIT zzz_prog
USING SELECTION-SET variant
WITH p_submit = ‘X’ AND RETURN.
CLEAR : gt_tab.
IMPORT gt_tab TO gt_tab FROM MEMORY ID ‘ZZZ_ID’.
ENDIF.
CALL FUNCTION ‘RS_CHANGE_CREATED_VARIANT’
EXPORTING
curr_report = program
curr_variant = variant
vari_desc = ls_varid
only_contents = ‘X’
TABLES
vari_contents = variant_backup[]
* VARI_TEXT =
* VARI_SEL_DESC =
OBJECTS = lt_objects[]
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_doesnt_exist = 7
variant_locked = 8
selections_no_match = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
No comments:
Post a Comment