SAP RS_CREATE_VARIANT Function Module for Creating a variant (not using a selection screen)
RS_CREATE_VARIANT is a standard rs create variant SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Creating a variant (not using a selection screen) processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for rs create variant FM, simply by entering the name RS_CREATE_VARIANT into the relevant SAP transaction such as SE37 or SE38.
Function Group: SVAR
Program Name: SAPLSVAR
Main Program: SAPLSVAR
Appliation area:
Release date: 09-Nov-1998
Mode(Normal, Remote etc): Normal Function Module
Update:

Function RS_CREATE_VARIANT pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'RS_CREATE_VARIANT'"Creating a variant (not using a selection screen).
EXPORTING
CURR_REPORT = "Report Name
CURR_VARIANT = "Variant name
VARI_DESC = "Variant description (structure VARID)
TABLES
VARI_CONTENTS = "Contents (STRUCTURE RSPARAMS)
VARI_TEXT = "Variant text (structure VARIT)
* VSCREENS = "
* VARI_CONTENTS_L = "Gen. Structure for Parameters and Select-Options (132 char.)
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
IMPORTING Parameters details for RS_CREATE_VARIANT
CURR_REPORT - Report Name
Data type: RSVAR-REPORTOptional: No
Call by Reference: No ( called with pass by value option)
CURR_VARIANT - Variant name
Data type: RSVAR-VARIANTOptional: No
Call by Reference: No ( called with pass by value option)
VARI_DESC - Variant description (structure VARID)
Data type: VARIDOptional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for RS_CREATE_VARIANT
VARI_CONTENTS - Contents (STRUCTURE RSPARAMS)
Data type: RSPARAMSOptional: No
Call by Reference: No ( called with pass by value option)
VARI_TEXT - Variant text (structure VARIT)
Data type: VARITOptional: No
Call by Reference: No ( called with pass by value option)
VSCREENS -
Data type: RSDYNNROptional: Yes
Call by Reference: No ( called with pass by value option)
VARI_CONTENTS_L - Gen. Structure for Parameters and Select-Options (132 char.)
Data type: RSPARAMSLOptional: Yes
Call by Reference: Yes
EXCEPTIONS details
ILLEGAL_REPORT_OR_VARIANT - Incorrect report or variant name (VARI_DESC)
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ILLEGAL_VARIANTNAME - Variante name space or contains '&' or '%'
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NOT_AUTHORIZED - No authorization
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NOT_EXECUTED - Not executed
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
REPORT_NOT_EXISTENT - Report does not exist
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
REPORT_NOT_SUPPLIED - Report is not type '1'
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIANT_EXISTS - Layout Already Exists
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
VARIANT_LOCKED - Variant locked
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for RS_CREATE_VARIANT Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_curr_report | TYPE RSVAR-REPORT, " | |||
| lt_vari_contents | TYPE STANDARD TABLE OF RSPARAMS, " | |||
| lv_illegal_report_or_variant | TYPE RSPARAMS, " | |||
| lt_vari_text | TYPE STANDARD TABLE OF VARIT, " | |||
| lv_curr_variant | TYPE RSVAR-VARIANT, " | |||
| lv_illegal_variantname | TYPE RSVAR, " | |||
| lt_vscreens | TYPE STANDARD TABLE OF RSDYNNR, " | |||
| lv_vari_desc | TYPE VARID, " | |||
| lv_not_authorized | TYPE VARID, " | |||
| lv_not_executed | TYPE VARID, " | |||
| lt_vari_contents_l | TYPE STANDARD TABLE OF RSPARAMSL, " | |||
| lv_report_not_existent | TYPE RSPARAMSL, " | |||
| lv_report_not_supplied | TYPE RSPARAMSL, " | |||
| lv_variant_exists | TYPE RSPARAMSL, " | |||
| lv_variant_locked | TYPE RSPARAMSL. " |
|   CALL FUNCTION 'RS_CREATE_VARIANT' "Creating a variant (not using a selection screen) |
| EXPORTING | ||
| CURR_REPORT | = lv_curr_report | |
| CURR_VARIANT | = lv_curr_variant | |
| VARI_DESC | = lv_vari_desc | |
| TABLES | ||
| VARI_CONTENTS | = lt_vari_contents | |
| VARI_TEXT | = lt_vari_text | |
| VSCREENS | = lt_vscreens | |
| VARI_CONTENTS_L | = lt_vari_contents_l | |
| 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 | ||
| . " RS_CREATE_VARIANT | ||
ABAP code using 7.40 inline data declarations to call FM RS_CREATE_VARIANT
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single REPORT FROM RSVAR INTO @DATA(ld_curr_report). | ||||
| "SELECT single VARIANT FROM RSVAR INTO @DATA(ld_curr_variant). | ||||
Search for further information about these or an SAP related objects