2014 Feb 03 8:08 PM
Hi
Did BAPI Checks the number ranges while creating the material by using BAPI BAPI_MATERIAL_SAVEDATA.
Regards
DIvakar
2014 Feb 04 5:14 AM
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:
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.
2014 Feb 04 5:42 AM
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