SAP MGW1_SELECT_BOM Function Module for NOTRANSL: Lesen der Stücklisten zu einem strukt. Artikel
MGW1_SELECT_BOM is a standard mgw1 select bom SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for NOTRANSL: Lesen der Stücklisten zu einem strukt. Artikel 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 mgw1 select bom FM, simply by entering the name MGW1_SELECT_BOM into the relevant SAP transaction such as SE37 or SE38.
Function Group: MGW1
Program Name: SAPLMGW1
Main Program: SAPLMGW1
Appliation area: W
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function MGW1_SELECT_BOM 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 'MGW1_SELECT_BOM'"NOTRANSL: Lesen der Stücklisten zu einem strukt. Artikel.
EXPORTING
* CHANGE_MODE = ' ' "Maintenance mode
* WITH_BOM = ' ' "DE-EN-LANG-SWITCH-NO-TRANSLATION
* CHANGE_NO = ' ' "Change Number
* VALID_FROM = SY-DATUM "Valid From
* VALID_TO = SY-DATUM "Valid To
STRUC_MATERIAL = "structured matl
* STRUC_UNIT = ' ' "Unit of Measure
STRUC_TYPE = "DE-EN-LANG-SWITCH-NO-TRANSLATION
STRUC_USAGE = "BOM Usage
STRUC_POSTYP = "BOM item category
IMPORTING
RETURNCODE = "Return Code
TABLES
* COMPONENT = "Components
* HEAD = "Header
T_MAST = "DE-EN-LANG-SWITCH-NO-TRANSLATION
EXCEPTIONS
BOM_INVALID = 1 BOM_NOT_EXIST = 2
IMPORTING Parameters details for MGW1_SELECT_BOM
CHANGE_MODE - Maintenance mode
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
WITH_BOM - DE-EN-LANG-SWITCH-NO-TRANSLATION
Data type: XFELDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
CHANGE_NO - Change Number
Data type: CSAP_MBOM-AENNRDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
VALID_FROM - Valid From
Data type: CSAP_MBOM-DATUVDefault: SY-DATUM
Optional: Yes
Call by Reference: No ( called with pass by value option)
VALID_TO - Valid To
Data type: CSAP_MBOM-DATUBDefault: SY-DATUM
Optional: Yes
Call by Reference: No ( called with pass by value option)
STRUC_MATERIAL - structured matl
Data type: CSAP_MBOM-MATNROptional: No
Call by Reference: No ( called with pass by value option)
STRUC_UNIT - Unit of Measure
Data type: RMGW2-MEINHDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
STRUC_TYPE - DE-EN-LANG-SWITCH-NO-TRANSLATION
Data type: TMGW2-STRTPOptional: No
Call by Reference: No ( called with pass by value option)
STRUC_USAGE - BOM Usage
Data type: TMGW2-STLANOptional: No
Call by Reference: No ( called with pass by value option)
STRUC_POSTYP - BOM item category
Data type: TMGW2-POSTPOptional: No
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for MGW1_SELECT_BOM
RETURNCODE - Return Code
Data type: SY-SUBRCOptional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for MGW1_SELECT_BOM
COMPONENT - Components
Data type: STPOBOptional: Yes
Call by Reference: No ( called with pass by value option)
HEAD - Header
Data type: STKOBOptional: Yes
Call by Reference: No ( called with pass by value option)
T_MAST - DE-EN-LANG-SWITCH-NO-TRANSLATION
Data type: MASTBOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
BOM_INVALID - DE-EN-LANG-SWITCH-NO-TRANSLATION
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
BOM_NOT_EXIST - Bill of material does not exist
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for MGW1_SELECT_BOM 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: | ||||
| lt_component | TYPE STANDARD TABLE OF STPOB, " | |||
| lv_returncode | TYPE SY-SUBRC, " | |||
| lv_bom_invalid | TYPE SY, " | |||
| lv_change_mode | TYPE SY, " SPACE | |||
| lv_with_bom | TYPE XFELD, " SPACE | |||
| lt_head | TYPE STANDARD TABLE OF STKOB, " | |||
| lv_change_no | TYPE CSAP_MBOM-AENNR, " SPACE | |||
| lv_bom_not_exist | TYPE CSAP_MBOM, " | |||
| lt_t_mast | TYPE STANDARD TABLE OF MASTB, " | |||
| lv_valid_from | TYPE CSAP_MBOM-DATUV, " SY-DATUM | |||
| lv_valid_to | TYPE CSAP_MBOM-DATUB, " SY-DATUM | |||
| lv_struc_material | TYPE CSAP_MBOM-MATNR, " | |||
| lv_struc_unit | TYPE RMGW2-MEINH, " SPACE | |||
| lv_struc_type | TYPE TMGW2-STRTP, " | |||
| lv_struc_usage | TYPE TMGW2-STLAN, " | |||
| lv_struc_postyp | TYPE TMGW2-POSTP. " |
|   CALL FUNCTION 'MGW1_SELECT_BOM' "NOTRANSL: Lesen der Stücklisten zu einem strukt. Artikel |
| EXPORTING | ||
| CHANGE_MODE | = lv_change_mode | |
| WITH_BOM | = lv_with_bom | |
| CHANGE_NO | = lv_change_no | |
| VALID_FROM | = lv_valid_from | |
| VALID_TO | = lv_valid_to | |
| STRUC_MATERIAL | = lv_struc_material | |
| STRUC_UNIT | = lv_struc_unit | |
| STRUC_TYPE | = lv_struc_type | |
| STRUC_USAGE | = lv_struc_usage | |
| STRUC_POSTYP | = lv_struc_postyp | |
| IMPORTING | ||
| RETURNCODE | = lv_returncode | |
| TABLES | ||
| COMPONENT | = lt_component | |
| HEAD | = lt_head | |
| T_MAST | = lt_t_mast | |
| EXCEPTIONS | ||
| BOM_INVALID = 1 | ||
| BOM_NOT_EXIST = 2 | ||
| . " MGW1_SELECT_BOM | ||
ABAP code using 7.40 inline data declarations to call FM MGW1_SELECT_BOM
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 SUBRC FROM SY INTO @DATA(ld_returncode). | ||||
| DATA(ld_change_mode) | = ' '. | |||
| DATA(ld_with_bom) | = ' '. | |||
| "SELECT single AENNR FROM CSAP_MBOM INTO @DATA(ld_change_no). | ||||
| DATA(ld_change_no) | = ' '. | |||
| "SELECT single DATUV FROM CSAP_MBOM INTO @DATA(ld_valid_from). | ||||
| DATA(ld_valid_from) | = SY-DATUM. | |||
| "SELECT single DATUB FROM CSAP_MBOM INTO @DATA(ld_valid_to). | ||||
| DATA(ld_valid_to) | = SY-DATUM. | |||
| "SELECT single MATNR FROM CSAP_MBOM INTO @DATA(ld_struc_material). | ||||
| "SELECT single MEINH FROM RMGW2 INTO @DATA(ld_struc_unit). | ||||
| DATA(ld_struc_unit) | = ' '. | |||
| "SELECT single STRTP FROM TMGW2 INTO @DATA(ld_struc_type). | ||||
| "SELECT single STLAN FROM TMGW2 INTO @DATA(ld_struc_usage). | ||||
| "SELECT single POSTP FROM TMGW2 INTO @DATA(ld_struc_postyp). | ||||
Search for further information about these or an SAP related objects