2006 Dec 26 6:01 PM
Hi
Does somebody how can i update a report Variant inside a program ?
I have a report, wich has a Variant created with desired screen values, but i need to update the variant for set it a field value to 'A', and execute the report with the variant; then update the variant for set it a field value to 'B' and execute the report; etc.
Is there a FM to update a Variant ?
Thanks
Frank
2006 Dec 26 9:54 PM
HI Frank,
Please use RS_VARIANT_CONTENTS to read the variant values into VALUETAB.
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
REPORT = Program_name
VARIANT = Variant Name
MOVE_OR_WRITE = 'W'
NO_IMPORT = ' '
EXECUTE_DIRECT = ' '
IMPORTING
SP =
TABLES
L_PARAMS =
L_PARAMS_NONV =
L_SELOP =
L_SELOP_NONV =
VALUTAB = ValueTab.
OBJECTS =
FREE_SELECTIONS_DESC =
FREE_SELECTIONS_VALUE =
EXCEPTIONS
VARIANT_NON_EXISTENT = 1
VARIANT_OBSOLETE = 2
REPORT_NOT_EXISTENT = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Make the required changes and call FM RS_CHANGE_CREATED_VARIANT
CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
EXPORTING
CURR_REPORT = LS_REPORT_NAME
CURR_VARIANT = LS_VARIANT
VARI_DESC = LS_VARIANTDESC
ONLY_CONTENTS =
TABLES
VARI_CONTENTS = IT_SELPARAM.
VARI_TEXT =
VARI_SEL_DESC =
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 SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Venkat.
2006 Dec 26 6:28 PM
Hi,
There is a function group called SVAR. This has many FMs to handle variants with in a program.
The following FM can be used to change the values of an existing variant: RS_CHANGE_CREATED_VARIANT.
Hope this helps.
Sumant.
2006 Dec 26 6:30 PM
Use this FM "RS_VARIANT_SCREEN" in your program to create, change and delete the variant.
Thanks,
Santosh
2006 Dec 26 9:54 PM
HI Frank,
Please use RS_VARIANT_CONTENTS to read the variant values into VALUETAB.
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
REPORT = Program_name
VARIANT = Variant Name
MOVE_OR_WRITE = 'W'
NO_IMPORT = ' '
EXECUTE_DIRECT = ' '
IMPORTING
SP =
TABLES
L_PARAMS =
L_PARAMS_NONV =
L_SELOP =
L_SELOP_NONV =
VALUTAB = ValueTab.
OBJECTS =
FREE_SELECTIONS_DESC =
FREE_SELECTIONS_VALUE =
EXCEPTIONS
VARIANT_NON_EXISTENT = 1
VARIANT_OBSOLETE = 2
REPORT_NOT_EXISTENT = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Make the required changes and call FM RS_CHANGE_CREATED_VARIANT
CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
EXPORTING
CURR_REPORT = LS_REPORT_NAME
CURR_VARIANT = LS_VARIANT
VARI_DESC = LS_VARIANTDESC
ONLY_CONTENTS =
TABLES
VARI_CONTENTS = IT_SELPARAM.
VARI_TEXT =
VARI_SEL_DESC =
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 SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Venkat.
2006 Dec 27 12:45 AM
Thanks Venkat
I tried with the FM for update, but it just saw it clears all the others values, but with your tip for read first the original variant values and then update only the desired value; it works soo good.
Regards
Frank
2007 Apr 11 2:12 PM
Hello Venkat
Am using the same logic in one of my programs, i.e calling FM RS_VARIANT_CONTENTS -> changing the values in RSPARAMS -> then calling the FM RS_CHANGE_CREATED_VARIANT. The call to FM RS_CHANGE_CREATED_VARIANT result in a short dump.
The variant am trying to modify is a copy of the standard variant cockpit in transaction code /dsd/sl_radb . The short dump is due to the fact that in RSPARAMS the default value of the of the variant is of type char (in the LOW field) and the FM RS_CHANGE_CREATED_VARIANT is trying to move the char to a variable of type decimal such causing a conversion error. Do you have any idea how to fix that.