Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Did BAPI Checks the number ranges while creating the material by using BAPI BAPI_MATERIAL_SAVEDATA

Former Member
0 Kudos

Hi

Did  BAPI  Checks the number ranges while creating the material by using BAPI BAPI_MATERIAL_SAVEDATA.

Regards

DIvakar

2 REPLIES 2

gouravkumar64
Active Contributor
0 Kudos

Hi Divakar,

This is very FAQ .

From parameter header data documentation, it is saying.

When you create material master data, the following fields must always contain a value in the structure:

  • MATERIAL

Only external number assignment is supported for the material number (MATERIAL). If you want the material number to be assigned internally, the method BAPI_MATERIAL_GETINTNUMBER must first be called. This method determines an internal number for the material to be created. You must enter this internal number in field HEADDATA-MATERIAL.

You can check this thread for more idea.

Thanks

Gourav.

Former Member
0 Kudos

Hi

If you looking Internal Number Range based on Material Type and Industry Sector then Use this "BAPI_STDMATERIAL_GETINTNUMBER"  , Or If you need External Number then assign Material Number to "BAPI_MATERIAL_SAVEDATA"  check below sample code .

DATA : MAT TYPE STANDARD TABLE OF BAPIMATINR WITH HEADER LINE INITIAL SIZE 0 ,

           MTYP TYPE MTART ,

           IND_SEC TYPE MBRSH,

           T_MHEADER LIKE BAPIMATHEAD.

* Check INTERNAL NUMBER OR EXTERNAL NUMBER FOR MATERIAL.

IF S_MATNR IS INITIAL.

                                  

* GET INTERNAL NUMBER FOR MATERIAL .

    MTYP      = S_MTART.                   " Material Type 

    IND_SEC = S_MBRSH .               " Industry Sector 

    PERFORM GET_INTERNAL_NUMBER  TABLES MAT

                                                               USING   MTYP

                                                                            IND_SEC.

    READ TABLE MAT INDEX 1.

    T_MHEADER-MATERIAL = MAT-MATERIAL .

     ELSE.

* GET EXTERNAL NUMBER FOR MATERIAL .

     T_MHEADER-MATERIAL  =  S_MATNR .  "  External Material Number

ENDIF.

FORM GET_INT_NUMBER  TABLES   P_MAT STRUCTURE MAT

                     USING    P_MTYP

                              P_IND_SEC.

  CALL FUNCTION 'BAPI_STDMATERIAL_GETINTNUMBER'

    EXPORTING

      MATERIAL_TYPE          = P_MTYP

      INDUSTRY_SECTOR     = P_IND_SEC

      REQUIRED_NUMBERS = 1

    IMPORTING

      RETURN                       = RT

    TABLES

      MATERIAL_NUMBER  = P_MAT.

ENDFORM.  

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

    EXPORTING

      HEADDATA             = T_MHEADER

          .............

          ...................    .

then finally if return is "Success" then Commit the Material Material Record .

Regard's

Smruti