<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Bapi for material creation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510284#M1259999</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  Ztests. 

*---tables used
tables:bapimathead,
       bapi_makt,
       bapi_mara,
       bapi_marax. 

*--declaration for internal table 

data:begin of itab occurs 0,
      MATERIAL type BAPIMATHEAD-MATERIAL,
      IND_SECTOR(20),
      MATL_TYPE type bapimathead-MATL_TYPE,
      MATL_GROUP type bapi_mara-MATL_GROUP,
      LANGU TYPE BAPI_MAKT-LANGU,
      MATL_DESC TYPE BAPI_MAKT-MATL_DESC,
     end of itab, 

    it_return like BAPIRET2, 

    IT_BAPI LIKE BAPI_MAKT OCCURS 0 WITH HEADER LINE. 

*---selection screen
parameters:p_file TYPE IBIPPARMS-PATH obligatory. 

*---f4 help for the file from PC
at selection-screen on value-request for p_file. 

perform get_f4help. 

*--start-of-selection .
start-of-selection. 

perform upload_file_itab. 

perform call_bapi. 

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_f4help
*&amp;amp;---------------------------------------------------------------------*
form get_f4help . 

CALL FUNCTION 'F4_FILENAME'
 EXPORTING
   PROGRAM_NAME        = SYST-CPROG
   DYNPRO_NUMBER       = SYST-DYNNR
 IMPORTING
   FILE_NAME           = P_FILE  . 

endform.                    " get_f4help
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  upload_file_itab
*&amp;amp;---------------------------------------------------------------------* 

form upload_file_itab . 

DATA:V_FILE TYPE STRING.
MOVE P_FILE TO V_FILE. 

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
   filename                      = V_FILE
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
  TABLES
    data_tab                      = ITAB . 

endform.                    " upload_file_itab
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  call_bapi
*&amp;amp;---------------------------------------------------------------------* 

form call_bapi . 

loop at itab. 

BAPIMATHEAD-material = itab-MATERIAL.
bapimathead-IND_SECTOR = itab-IND_SECTOR.
BAPIMATHEAD-MATL_TYPE = itab-MATL_TYPE.
BAPIMATHEAD-BASIC_VIEW = 'X'. 

bapi_mara-MATL_GROUP = itab-MATL_GROUP.
bapi_mara-base_uom = 'KGS'.
bapi_marax-MATL_GROUP = 'X'.
bapi_marax-BASE_UOM = 'X'. 

IT_BAPI-LANGU = ITAB-LANGU.
IT_BAPI-LANGU_ISO = 'EN'.
IT_BAPI-MATL_DESC = ITAB-MATL_DESC.
APPEND IT_BAPI.
clear it_bapi. 

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata                  = BAPIMATHEAD
   CLIENTDATA                 = bapi_mara
   CLIENTDATAX                = bapi_marax
   IMPORTING
   RETURN                     = it_RETURN
 TABLES
   MATERIALDESCRIPTION        = IT_BAPI . 

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  . 

*---this is the message type which indicates whether it is failed or succeded
write:/ it_return-TYPE. 

endloop. 

endform.                    " call_bapi

Here is the test file used for creating the materials in the above program: 

000000000011111111     T          RFRM   001       EN        this is test material

000000000011111112     T          RFRM   001       EN        this is test material

000000000011111113     T          RFRM   001       EN        this is test material

000000000011111114     T          RFRM   001       EN        this is test material

000000000011111115     T          RFRM   001       EN        this is test material

000000000011111116     T          RFRM   001       EN        this is test material

000000000011111117     T          RFRM   001       EN        this is test material&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Apr 2009 14:02:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-28T14:02:17Z</dc:date>
    <item>
      <title>Bapi for material creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510282#M1259997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create  material in MM01. i am Using Bapi   BAPI_MATERIAL_SAVEDATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in my case i will populate all details required to create material ( basic data) except material number.&lt;/P&gt;&lt;P&gt;material number is internally generated in my case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wen i try to create through bapi using test mode its asking material number to fill.is there any option for this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 13:49:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510282#M1259997</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T13:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for material creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510283#M1259998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the BAPI documentation for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt;removed_by_moderator&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;Note: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't copy paste  Function module documentation here, Just ask the user to refer the Documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Vijay Babu Dudla on Apr 28, 2009 10:04 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 13:59:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510283#M1259998</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T13:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for material creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510284#M1259999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  Ztests. 

*---tables used
tables:bapimathead,
       bapi_makt,
       bapi_mara,
       bapi_marax. 

*--declaration for internal table 

data:begin of itab occurs 0,
      MATERIAL type BAPIMATHEAD-MATERIAL,
      IND_SECTOR(20),
      MATL_TYPE type bapimathead-MATL_TYPE,
      MATL_GROUP type bapi_mara-MATL_GROUP,
      LANGU TYPE BAPI_MAKT-LANGU,
      MATL_DESC TYPE BAPI_MAKT-MATL_DESC,
     end of itab, 

    it_return like BAPIRET2, 

    IT_BAPI LIKE BAPI_MAKT OCCURS 0 WITH HEADER LINE. 

*---selection screen
parameters:p_file TYPE IBIPPARMS-PATH obligatory. 

*---f4 help for the file from PC
at selection-screen on value-request for p_file. 

perform get_f4help. 

*--start-of-selection .
start-of-selection. 

perform upload_file_itab. 

perform call_bapi. 

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_f4help
*&amp;amp;---------------------------------------------------------------------*
form get_f4help . 

CALL FUNCTION 'F4_FILENAME'
 EXPORTING
   PROGRAM_NAME        = SYST-CPROG
   DYNPRO_NUMBER       = SYST-DYNNR
 IMPORTING
   FILE_NAME           = P_FILE  . 

endform.                    " get_f4help
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  upload_file_itab
*&amp;amp;---------------------------------------------------------------------* 

form upload_file_itab . 

DATA:V_FILE TYPE STRING.
MOVE P_FILE TO V_FILE. 

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
   filename                      = V_FILE
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
  TABLES
    data_tab                      = ITAB . 

endform.                    " upload_file_itab
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  call_bapi
*&amp;amp;---------------------------------------------------------------------* 

form call_bapi . 

loop at itab. 

BAPIMATHEAD-material = itab-MATERIAL.
bapimathead-IND_SECTOR = itab-IND_SECTOR.
BAPIMATHEAD-MATL_TYPE = itab-MATL_TYPE.
BAPIMATHEAD-BASIC_VIEW = 'X'. 

bapi_mara-MATL_GROUP = itab-MATL_GROUP.
bapi_mara-base_uom = 'KGS'.
bapi_marax-MATL_GROUP = 'X'.
bapi_marax-BASE_UOM = 'X'. 

IT_BAPI-LANGU = ITAB-LANGU.
IT_BAPI-LANGU_ISO = 'EN'.
IT_BAPI-MATL_DESC = ITAB-MATL_DESC.
APPEND IT_BAPI.
clear it_bapi. 

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata                  = BAPIMATHEAD
   CLIENTDATA                 = bapi_mara
   CLIENTDATAX                = bapi_marax
   IMPORTING
   RETURN                     = it_RETURN
 TABLES
   MATERIALDESCRIPTION        = IT_BAPI . 

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  . 

*---this is the message type which indicates whether it is failed or succeded
write:/ it_return-TYPE. 

endloop. 

endform.                    " call_bapi

Here is the test file used for creating the materials in the above program: 

000000000011111111     T          RFRM   001       EN        this is test material

000000000011111112     T          RFRM   001       EN        this is test material

000000000011111113     T          RFRM   001       EN        this is test material

000000000011111114     T          RFRM   001       EN        this is test material

000000000011111115     T          RFRM   001       EN        this is test material

000000000011111116     T          RFRM   001       EN        this is test material

000000000011111117     T          RFRM   001       EN        this is test material&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 14:02:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510284#M1259999</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T14:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for material creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510285#M1260000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey this is a functional problem&lt;/P&gt;&lt;P&gt;ask your functional guy to check for that&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;s.janagar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 14:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510285#M1260000</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T14:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for material creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510286#M1260001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this bapi, it completly replicates the MM01 functionality and new material number was given as output parameter by the end of the execution.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;BAPI_STANDARDMATERIAL_CREATE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope , this will matches your reuirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;by&lt;/P&gt;&lt;P&gt;Prasad gvk.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 14:08:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510286#M1260001</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T14:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi for material creation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510287#M1260002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You have choosen the correct BAPI, BAPI_MATERIAL_SAVEDATA &lt;/P&gt;&lt;P&gt;just check out for documentation&lt;/P&gt;&lt;P&gt;Tks,&lt;/P&gt;&lt;P&gt;Krishna..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 14:11:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-material-creation/m-p/5510287#M1260002</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-28T14:11:16Z</dc:date>
    </item>
  </channel>
</rss>

