Application Development and Automation 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: 
Read only

Internal number assignment with BAPI_MATERIAL_SAVEDATA

Former Member
0 Likes
2,848

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 !

1 ACCEPTED SOLUTION
Read only

former_member585060
Active Contributor
0 Likes
1,425

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

3 REPLIES 3
Read only

Former Member
0 Likes
1,425

Just leave the material number blank in structure HEADDATA of bapi BAPI_MATERIAL_SAVEDATA

Read only

0 Likes
1,425

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.

....

Read only

former_member585060
Active Contributor
0 Likes
1,426

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