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: 

Material creation using bapi issue ..

ramkumar007
Participant
0 Kudos

Hi,

  Am using bapi    'BAPI_MATERIAL_SAVEDATA'.


   here without matnr given mean it's coming error..


   if any possibility is there without given matnr no will generate  matnr automatically  ..


2 REPLIES 2

raymond_giuseppi
Active Contributor
0 Kudos

Read the BAPI documentation of parameter HEADDATA, look for BAPI_MATERIAL_GETINTNUMBER.

Regards,

Raymond

former_member184569
Active Contributor
0 Kudos

You can get the material number to be generated internally as suggested by Raymond.

CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
         EXPORTING
           material_type    = 'FIM' "it_matmaster-mtart
           industry_sector  = 'M'
           required_numbers = 1
         IMPORTING
           return           = gv_bapireturn1
         TABLES
           material_number  = gt_bapimatnr.
       IF gv_bapireturn1-type EQ 'S'.
*        SORT gt_bapimatnr BY material DESCENDING.
         READ TABLE gt_bapimatnr INDEX 1.
         IF sy-subrc EQ 0.
           it_matmaster-matnr = gt_bapimatnr-material.
           bapimathead-material = gt_bapimatnr-material.
         ENDIF.
       ENDIF.
     ENDIF.