‎2008 Jan 17 2:53 PM
Hi everyone!
It is possible to create a material that has "Internal number assignment" with the bapi BAPI_MATERIAL_SAVEDATA ?
I try using the FM BAPI_STDMATERIAL_GETINTNUMBER or BAPI_MATERIAL_GETINTNUMBER, neither work.
Thank you in advance !
‎2009 Aug 17 10:26 AM
Hi,
Do in following way
1) Get all the Material details into the Internal table.
2) Use BAPI_MATERIAL_GETINTNUMBER, by passing the Material Type and Industry sector from Internal table, you will get the Internal Material number as output.
Get new material number
CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
EXPORTING
material_type = headdata-matl_type
industry_sector = headdata-ind_sector
required_numbers = 1
IMPORTING
return = gv_bapireturn1
TABLES
material_number = gt_bapimatnr.
IF gv_bapireturn1-type EQ 'S'.
READ TABLE gt_bapimatnr INTO gs_bapimatnr INDEX 1.
IF sy-subrc EQ 0.
headdata-material = gs_bapimatnr-material.
ENDIF.
ENDIF.3) Now fill up all the values of BAPI BAPI_MATERIAL_SAVEDATA, and create Material.
Regards
Bala Krishna
‎2008 Jan 18 9:01 AM
Just leave the material number blank in structure HEADDATA of bapi BAPI_MATERIAL_SAVEDATA
‎2009 Aug 17 10:12 AM
It's not possible to put a blank in field material because we obtain error message M3 262.
....
IF HEADDATA-MATERIAL = SPACE.
CLEAR TMERRDAT.
SY-MSGID = MESSAGE_ID_M3.
SY-MSGTY = MESSAGE_ERROR.
SY-MSGNO = '262'.
BAPI_ERROR = 'X'.
ENDIF.
....
‎2009 Aug 17 10:26 AM
Hi,
Do in following way
1) Get all the Material details into the Internal table.
2) Use BAPI_MATERIAL_GETINTNUMBER, by passing the Material Type and Industry sector from Internal table, you will get the Internal Material number as output.
Get new material number
CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
EXPORTING
material_type = headdata-matl_type
industry_sector = headdata-ind_sector
required_numbers = 1
IMPORTING
return = gv_bapireturn1
TABLES
material_number = gt_bapimatnr.
IF gv_bapireturn1-type EQ 'S'.
READ TABLE gt_bapimatnr INTO gs_bapimatnr INDEX 1.
IF sy-subrc EQ 0.
headdata-material = gs_bapimatnr-material.
ENDIF.
ENDIF.3) Now fill up all the values of BAPI BAPI_MATERIAL_SAVEDATA, and create Material.
Regards
Bala Krishna