SAP BM_VARIANTS_FETCH Function Module for
BM_VARIANTS_FETCH is a standard bm variants fetch SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used to perform a specific ABAP function and below is the pattern details, 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 bm variants fetch FM, simply by entering the name BM_VARIANTS_FETCH into the relevant SAP transaction such as SE37 or SE38.
Function Group: SF03
Program Name: SAPLSF03
Main Program: SAPLSF03
Appliation area: S
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function BM_VARIANTS_FETCH 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 'BM_VARIANTS_FETCH'".
EXPORTING
I_VARIANTS = "Variants to be read (IDs) (import)
* LANGU = ' ' "Read name of variant in language LANGU
* VAR_OBJECTS = 'X' "Read objects
* ALSO_UNDEFINED_OBJECTS = ' ' "Also read undefined objects
* ONLY_OBJ_TYPE = 'H' "
IMPORTING
E_VARIANTS = "Variants (export)
EXCEPTIONS
NO_OBJECTS_IN_I_VARIANTS = 1 PART_IN_WORK = 2
IMPORTING Parameters details for BM_VARIANTS_FETCH
I_VARIANTS - Variants to be read (IDs) (import)
Data type: BMT_OBJ_DEFSOptional: No
Call by Reference: No ( called with pass by value option)
LANGU - Read name of variant in language LANGU
Data type: SY-LANGUDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
VAR_OBJECTS - Read objects
Data type: BMT_FLAGDefault: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
ALSO_UNDEFINED_OBJECTS - Also read undefined objects
Data type: BMT_FLAGDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
ONLY_OBJ_TYPE -
Data type: DF40D-PARENT_TYPDefault: 'H'
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for BM_VARIANTS_FETCH
E_VARIANTS - Variants (export)
Data type: BMT_VARIANTSOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
NO_OBJECTS_IN_I_VARIANTS - Variant missing in import part
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
PART_IN_WORK - In process
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for BM_VARIANTS_FETCH 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_e_variants | TYPE BMT_VARIANTS, " | |||
| lv_i_variants | TYPE BMT_OBJ_DEFS, " | |||
| lv_no_objects_in_i_variants | TYPE BMT_OBJ_DEFS, " | |||
| lv_langu | TYPE SY-LANGU, " SPACE | |||
| lv_part_in_work | TYPE SY, " | |||
| lv_var_objects | TYPE BMT_FLAG, " 'X' | |||
| lv_also_undefined_objects | TYPE BMT_FLAG, " SPACE | |||
| lv_only_obj_type | TYPE DF40D-PARENT_TYP. " 'H' |
|   CALL FUNCTION 'BM_VARIANTS_FETCH' " |
| EXPORTING | ||
| I_VARIANTS | = lv_i_variants | |
| LANGU | = lv_langu | |
| VAR_OBJECTS | = lv_var_objects | |
| ALSO_UNDEFINED_OBJECTS | = lv_also_undefined_objects | |
| ONLY_OBJ_TYPE | = lv_only_obj_type | |
| IMPORTING | ||
| E_VARIANTS | = lv_e_variants | |
| EXCEPTIONS | ||
| NO_OBJECTS_IN_I_VARIANTS = 1 | ||
| PART_IN_WORK = 2 | ||
| . " BM_VARIANTS_FETCH | ||
ABAP code using 7.40 inline data declarations to call FM BM_VARIANTS_FETCH
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 LANGU FROM SY INTO @DATA(ld_langu). | ||||
| DATA(ld_langu) | = ' '. | |||
| DATA(ld_var_objects) | = 'X'. | |||
| DATA(ld_also_undefined_objects) | = ' '. | |||
| "SELECT single PARENT_TYP FROM DF40D INTO @DATA(ld_only_obj_type). | ||||
| DATA(ld_only_obj_type) | = 'H'. | |||
Search for further information about these or an SAP related objects