Material BOM Explosion in SAP

October 10, 2025

In SAP we can use BOM Explosion using below function module, we need to pass some important parameter. 

CAPID - BOM Application ID (BEST).
EMENG - Required Quantity.
MTNRV - Material.
STLAL - Alternative BOM.
STLAN - BOM Usage.
WERKS - Plant.

we can find the multilevel BOM in STB table.

Code Snippet:

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
    EXPORTING
        alekz = 'X'
        capid = p_capid
        datuv = sy-datum
        emeng = p_emeng
        mktls = 'X'
        mehrs = 'X'
        mtnrv = lv_matnr
        stlal = lv_stlal
        stlan = lv_stlan
        stpst = 0
        svwvo = 'X'
        werks = lv_werks
        vrsvo = 'X'
    TABLES
        stb = it_stb
        matcat = it_matcat
    EXCEPTIONS
        alt_not_found = 1
        call_invalid = 2
        material_not_found = 3
        missing_authorization = 4
        no_bom_found = 5
        no_plant_data = 6
        no_suitable_bom_found = 7
        conversion_error = 8
        OTHERS = 9.
    IF sy-subrc <> 0.
    ENDIF.

IDE Used To Test This Code : SAP GUI.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to change MRP Area data using MD_MRP_LEVEL_CHANGE_DATA in SAP?

October 08, 2025

Requirement : Minimum Lot Size of a material in MRP area should update using MD_MRP_LEVEL_CHANGE_DATA function module.

Minimum Lot Size we can find in MM03->MRP1->ARP Areas

i_matnr = Material
i_werk = Storage Location
i_mrp_area = MRP Area
i_berty = Type of MRP Area
i_selfields = Pass the selfields structure
i_mdma = Pass the mdma structure
i_dpop = Pass the dpop structure

Code Snippet :
DATA: wa_selfields TYPE sdibe_massfields,
wa_mdma TYPE mdma,
wa_dpop TYPE dpop,
wa_berty TYPE mdlv-berty,
wa_return TYPE bapireturn1.

wa_mdma-matnr = wa_final-matnr. "Material
wa_mdma-werks = wa_final-plant. "Plant
wa_mdma-dismm = wa_final-mrptype. "MRP Type
wa_mdma-dispo = wa_final-mrpcntrl. "MRP Controller
wa_mdma-berid = wa_final-mrparea. "MRP Area
wa_mdma-bstmi = wa_final-moq. "Minimum order quantity

wa_selfields-xbstmi = 'X'. "Minimum order quantity

CALL FUNCTION 'MD_MRP_LEVEL_CHANGE_DATA'
EXPORTING
i_matnr = wa_final-matnr
i_werk = wa_final-strgloc
i_mrp_area = wa_final-mrparea
i_berty = lv_berty
i_selfields = wa_selfields
i_mdma = wa_mdma
i_dpop = wa_dpop
IMPORTING
e_error_return = wa_return.

IDE Used To Test This Code : SAP GUI.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Where to find Material Group detail in SAP

July 15, 2025

You will find Material Group in MVKE table which contain material group number. 

MVKE - MVGR1
MVKE - MVGR2
MVKE - MVGR3
MVKE - MVGR4
MVKE - MVGR5

Material group number text will stored in different table.
MVKE - MVGR1 value text will stored in TVM1T.
MVKE - MVGR2 value text will stored in TVM2T.
MVKE - MVGR3 value text will stored in TVM3T.
MVKE - MVGR4 value text will stored in TVM4T.
MVKE - MVGR5 value text will stored in TVM5T

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to get header text in SAP ABAP

April 01, 2025

How to get header text in SAP ABAP.
By using READ_TEXT we can able to read the header text of any standard transaction.

DATA: text_name TYPE tdobname,
lvlang TYPE tdspras,
textid TYPE tdid,
textobj TYPE tdobject,
ittline TYPE STANDARD TABLE OF tline.

lvlang = 'EN'.
textobj = 'VBBK'.
textid = 'Z022'.
textname = document number.

CALL FUNCTION 'READ_TEXT'
    EXPORTING
        client = sy-mandt
        id = textid
        language = lvlang
        name = textname
        object = textobj
    TABLES
        lines = ittline
    EXCEPTIONS
        id = 1
        language = 2
        name = 3
        not_found = 4
        object = 5
        reference_check = 6
        wrong_access_to_archive = 7
        OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.

sy-mandt = Client name.
pass the document number in textname.
Header text will appear in ittline table.
Text object and Text id we can able to find from Detail option.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to count decimal places using function module in SAP ABAP

March 30, 2025

Using a SAP inbuilt function module SWA_DETERMINE_DECIMALS, we can count the number of digits in decimal places.

In import, section we need to pass the number with decimal places and data type should be SWAEXPDEF-EXPR type.
 

In export section, we can get the count of decimal place number and export data type is DFIES-DECIMALS type.

Example: 


Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Simple Try Catch program in SAP ABAP

July 17, 2024

Code:

DATA: res TYPE char10.
PARAMETERS: p1 TYPE char10,
            p2 TYPE char10.

TRY.
    res = p1 / p2.
    WRITE:/ res.
  CATCH cx_sy_zerodivide.
    WRITE: 'cannot divide by zero'.
ENDTRY.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to pass internal table data to range table in SAP ABAP

July 16, 2024

Code: 
TYPES: BEGIN OF ty_str,
         id   TYPE int4,
         name TYPE name1,
         site TYPE werks_d,
       END OF ty_str.

DATA: it TYPE STANDARD TABLE OF ty_str,
      wa TYPE ty_str.

DATA: r_site TYPE RANGE OF werks_d.

it = VALUE #( ( id = '1' name = 'AAA' site = 'H021' )
              ( id = '2' name = 'BBB' site = 'H067' )
              ( id = '3' name = 'CCC' site = 'H022' )
              ( id = '4' name = 'DDD' site = 'H055' )
              ( id = '5' name = 'EEE' site = 'H033' )
              ( id = '6' name = 'FFF' site = 'H064' ) ).

r_site = VALUE #( FOR <fs_it> IN it
                    ( sign = 'I'
                      option = 'EQ'
                      low = <fs_it>-site ) ).

cl_demo_output=>display( r_site ).

You can also use below code section -

r_site = VALUE #( FOR <fs_it> IN it
                    ( sign = if_fsbp_const_range=>sign_include
                      option = if_fsbp_const_range=>option_equal
                      low = <fs_it>-site ) ).

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

GET_CURRENT_YEAR in SAP ABAP

July 10, 2024

GET_CURRENT_YEAR is a SAP's standard function module used in ABAP program to get current year.

Code:
DATA: lv_year TYPE bkpf-gjahr.

CALL FUNCTION 'GET_CURRENT_YEAR'
 EXPORTING
   bukrs         = '1000' "company code
   date          = sy-datum
 IMPORTING
*   CURRM         =
   curry         = lv_year
*   PREVM         =
*   PREVY         = .
WRITE: lv_year.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

SQL Server (MSSQLSERVER) not running in services

July 03, 2024

Today I have faced some serious issues with SQL Server running status. When I tried to connect my SQL database through SQL Server Management studio, the database was not connecting at all, so I checked SQL Server Configuration Manager there and I saw that SQL Server wasn't running at all. After spending a lot of time in the system and blogs on the internet I have checked Windows Logs in Event Viewer and track down the actual error I was getting.

Error code I have found in the Event Viewer
SQL error 9003

After that I got a solution that works perfectly.

Solution:
Go to C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Binn\Templates

Copy and paste model.mdf and modellog.ldf file to below path

C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA

After that I have tried to start the SQL Server service and it's started and the database has connected perfectly.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to put the Routine Number in condition value in sap?

June 29, 2024

Step1 - First we need to go to VOFM tcode.
Step2 - Then go to Formulas then click on Condition Value.
Step3 - Put the following

Routine number (Require Access Key)
Description
Application Type.

To get access key
1. Login to SAP Marketplace https://me.sap.com/app/sscr
2. Then go to objects -> Register

Then put following -
Basis Release
Program ID
Type
Object Name
Select Installation(s) No (copy installation number from SAP Access key message box)

3. After putting all the details, SAP Marketplace will give you an Access Key. Put the Access Key and you will be able to put your Routine Number and logic into it.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Check table and value table in SAP

June 26, 2024

Value table
It is maintained at the Domain level and value table used to provide f4 help. Value table provides only suggested values. we can put the suggested value and other values also.

Check Table
It is maintained at the Table level. Check table provides a list of possible entries. we can not provide any value other than value other than possible entries.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Append Structure and Include Structure in SAP

June 26, 2024

Append structure
Append structure is used to append to another structure or database table.
Append structure assigned to only one structure or table.
Append structure only appended to transparent tables.

Include structure
Include structure is used to include the structure to the SAP's custom table.
It can include multiple structures or database tables.
CI_ for customers and SI_ for partner namespace used in SAP.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

ME Keyword in OOABAP

June 26, 2024

It refers to the current object in execution. It is just an alias name for the current object.

Demo Program
CLASS cl_main DEFINITION.
  PUBLIC SECTION.
    DATA: num  TYPE i.
    METHODS: setdata,
             display.
ENDCLASS.

CLASS cl_main IMPLEMENTATION.

  METHOD setdata.
    me->num = 20.
  ENDMETHOD.

  METHOD display.
    WRITE:/ num.
  ENDMETHOD.

ENDCLASS.

DATA: ob TYPE REF TO cl_main.

START-OF-SELECTION.
  CREATE OBJECT ob.
  CALL METHOD ob->setdata.
  CALL METHOD ob->display.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.