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

Material creation using bapi issue ..

ramkumar007
Participant
0 Likes
648

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
Read only

RaymondGiuseppi
Active Contributor
0 Likes
591

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

Regards,

Raymond

Read only

Former Member
0 Likes
591

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.