Please provide me how change the Materil using BAPI...?

Hi Guru's,
could please provide me how change the Materil using BAPI...
please provide the BPAI name and step by step process...
if ou provide any program logic that would be helpfull to me...
thanks in advance
Srinivas....

Hi,
THis is code .
*& Report Zs_MATMAS_BAPI
*& This program demonstrates how easy it is to create Material master
*& data using BAPI_MATERIAL_SAVEDATA
*& The program also generates a report post-execution displaying errors
*& as well as successful uploads
REPORT Zs_MATMAS_BAPI.
TABLES
FLAGS *
DATA: F_STOP. " Flag used to stop processing
DATA DECLARATIONS *
DATA : V_EMPTY TYPE I, " No. of empty records
V_TOTAL TYPE I. " Total no. of records.
STRUCTURES & INTERNAL TABLES
*BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_RETURN LIKE BAPIRET2. " Return Parameter
*--- Internal table to hold excel file data
DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold Matetrial descriptions
DATA: BEGIN OF IT_MAKT OCCURS 100.
        INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.
*--- Internal to hold the records in the text file
DATA : BEGIN OF IT_DATA OCCURS 100,
            WERKS(4), " Plant
            MTART(4), " Material type
            MATNR(18), " Material number
            MATKL(9) , " Material group
            MBRSH(1), " Industry sector
            MEINS(3), " Base unit of measure
            GEWEI(3), " Weight Unit
            SPART(2), " Division
            EKGRP(3), " Purchasing group
            VPRSV(1), " Price control indicator
            STPRS(12), " Standard price
            PEINH(3), " Price unit
            SPRAS(2), " Language key
            MAKTX(40), " Material description
            END OF IT_DATA.
SELECTION SCREEN. *
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
'C:\Material_master.XLS'.
PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK SCR1.
AT SELECTION-SCREEN *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*--- Validating file
  PERFORM VALIDATE_FILE USING P_FILE.
START-OF-SELECTION
START-OF-SELECTION.
*--- Perform to convert the Excel data into an internal table
  PERFORM CONVERT_XLS_ITAB.
  IF NOT IT_DATA[] IS INITIAL.
*--- Perform to delete Header lines
    PERFORM DELETE_HEADER_EMPTY_RECS.
  ENDIF.
END OF SELECTION. *
END-OF-SELECTION.
*--- Perform to upload Material Master data
  PERFORM UPLOAD_MATMAS.
Form : validate_input_file
Description : To provide F4 help for file if read from PC
FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    CHANGING
      FILE_NAME     = F_FILE
    EXCEPTIONS
      MASK_TOO_LONG = 1
      OTHERS        = 2.
  IF SY-SUBRC  0.
    MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
  ENDIF.
ENDFORM. " validate_input_file
*& Form CONVER_XLS_ITAB
text
FORM CONVERT_XLS_ITAB.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME    = P_FILE
      I_BEGIN_COL = P_BEGCOL
      I_BEGIN_ROW = P_BEGROW
      I_END_COL   = P_ENDCOL
      I_END_ROW   = P_ENDROW
    TABLES
      INTERN      = IT_INTERN.
  IF SY-SUBRC  0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*--- Perform to move the data into an internal data
  PERFORM MOVE_DATA.
ENDFORM. " CONVERT_XLS_ITAB
*& Form MOVE_DATA
text
FORM MOVE_DATA.
  DATA : LV_INDEX TYPE I.
  FIELD-SYMBOLS <FS>.
*--- Sorting the internal table
  SORT IT_INTERN BY ROW COL.
  CLEAR IT_INTERN.
  LOOP AT IT_INTERN.
    MOVE IT_INTERN-COL TO LV_INDEX.
*--- Assigning the each record to an internal table row
    ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <FS>.
*--- Asigning the field value to a field symbol
    MOVE IT_INTERN-VALUE TO <FS>.
    AT END OF ROW.
      APPEND IT_DATA.
      CLEAR IT_DATA.
    ENDAT.
  ENDLOOP.
ENDFORM. " MOVE_DATA
*& Form DELETE_HEADER_EMPTY_RECS
To delete the Header and empty records
FORM DELETE_HEADER_EMPTY_RECS.
  DATA: LV_TABIX LIKE SY-TABIX.
  IF NOT P_HEADER IS INITIAL.
    LOOP AT IT_DATA.
      IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
        DELETE IT_DATA FROM 1 TO P_HEADER.
P_HEADER = 0.
        EXIT.
      ENDIF.
    ENDLOOP.
  ENDIF.
  CLEAR IT_DATA.
*--- To delete the empty lines from internal table
  LOOP AT IT_DATA.
    LV_TABIX = SY-TABIX.
    IF IT_DATA IS INITIAL.
      V_EMPTY = V_EMPTY + 1.
      DELETE IT_DATA INDEX LV_TABIX..
    ENDIF.
  ENDLOOP.
  CLEAR IT_DATA.
*--- Total no of recs in file
  DESCRIBE TABLE IT_DATA LINES V_TOTAL.
  IF V_TOTAL = 0.
    MESSAGE I013(ZLKPL_MSGCLASS). " No records in the file
    F_STOP = 'X'.
    STOP.
  ENDIF.
ENDFORM. " DELETE_HEADER_EMPTY_RECS
*& Form UPLOAD_MATMAS
to upload Material Master data
FORM UPLOAD_MATMAS .
  LOOP AT IT_DATA.
Header
    UNPACK IT_DATA-MATNR TO IT_DATA-MATNR.
    BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
    BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
    BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
    BAPI_HEAD-BASIC_VIEW = 'X'.
    BAPI_HEAD-PURCHASE_VIEW = 'X'.
    BAPI_HEAD-ACCOUNT_VIEW = 'X'.
Material Description
    REFRESH IT_MAKT.
    IT_MAKT-LANGU = IT_DATA-SPRAS.
    IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
    APPEND IT_MAKT.
Client Data - Basic
    BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
    BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
    BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
    BAPI_MARA1-DIVISION = IT_DATA-SPART.
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-BASE_UOM = 'X'.
    BAPI_MARAX-UNIT_OF_WT = 'X'.
    BAPI_MARAX-DIVISION = 'X'.
Plant - Purchasing
    BAPI_MARC1-PLANT = IT_DATA-WERKS.
    BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
    BAPI_MARCX-PLANT = IT_DATA-WERKS.
    BAPI_MARCX-PUR_GROUP = 'X'.
Accounting
    BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
    BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
    BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
    BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
    BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
    BAPI_MBEWX-PRICE_CTRL = 'X'.
    BAPI_MBEWX-STD_PRICE = 'X'.
    BAPI_MBEWX-PRICE_UNIT = 'X'.
*--- BAPI to create material
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
    HEADDATA = BAPI_HEAD
    CLIENTDATA = BAPI_MARA1
    CLIENTDATAX = BAPI_MARAX
    PLANTDATA = BAPI_MARC1
    PLANTDATAX = BAPI_MARCX
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA = BAPI_MBEW1
VALUATIONDATAX = BAPI_MBEWX
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA = BAPI_MVKE1
SALESDATAX = BAPI_MVKEX
STORAGETYPEDATA =
STORAGETYPEDATAX =
    IMPORTING
    RETURN = BAPI_RETURN
    TABLES
    MATERIALDESCRIPTION = IT_MAKT
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
    IF BAPI_RETURN-TYPE = 'E'.
      WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,IT_DATA-MATNR.
    ELSEIF BAPI_RETURN-TYPE = 'S'.
      WRITE: 'Successfully created material' ,IT_DATA-MATNR.
    ENDIF.
  ENDLOOP.
ENDFORM. " UPLOAD_MATMAS
Thanks
Sarada

Similar Messages

  • How can I change the value used in a Criteria Rule in a Subscription agent

    Dear mobile heroes.... How can I change the value used in a Criteria Rule in a Subscription agent in a quality environment? (CRM 70 SP04).
    I have built a subscription agent in dev, which uses a static where clause to filter activity_object on VKORG. I need to filter on a different VKORG value in the quality environment, but when I change the value of the sales org, the change is not saved. I have tried this even non 'activated'  subscription agents, but it still does not appear possible to change and save the changes.
    This poses a big problem because the VKORG value I want to use does not even exist in the dev environment, so I could not even rebuild in dev and transport the new agent to quality. Can anyone help me?

    Too old to care now.

  • How to change the browser used for Google search from context menu of selected text?

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

  • Volume control: I cannot change the volume using the keyboard of my Macbook. I have to go into preference. How to come back to the keyboard controler.

    I cannot change the volume using the keyboard of my Macbook. I have to go into preference. How to come back to the keyboard controler.

    1. Reset PRAM.  http://support.apple.com/kb/PH4405
    2. Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own".

  • How do I change the image used on an movie project icon? iMovie seems to select an image at random from the images I imported.

    How do I change the image used on an movie project icon?
    iMovie seems to select an image at random from the images I imported.

    Not sure I understand how to use what you have posted. Here's what my init() looks like:
    public void init()
    setLayout(new BorderLayout());
    p=new Panel();
    p.setLayout(new GridLayout(1,1));
    callnowButtonURL = getURL(callnowButtonFilename);
    if (callnowButtonURL != null)
    callIcon = new ImageIcon(callnowButtonURL,"call");
    endcallButtonURL = getURL(endcallButtonFilename);
    if (endcallButtonURL != null)
    endIcon = new ImageIcon(endcallButtonURL);
    b=new JButton(callIcon);
    b.setBorder(new EmptyBorder(0,0,0,0));
    b.setBorderPainted(false);
    b.addActionListener(this);
    p.add(b);
    add(p,"Center");
    Now the ActionListener is basically:
    public void actionPerformed(ActionEvent e)
    if (mybool == false)
    <Perform actions here set mybool to true>
    Change JButton b to use EndIcon
    else
    <Perform actions here set mybool to false>
    Change JButton b to use CallIcon
    Can you clarify how to perform the action I require? You can have a couple of Dukes if you can help me sort this out.

  • How change the graph dynamically based on pivot table.

    Hi,
    My Report having pivot table and bar chart. Organization Name column set as pivot table prompts in pivot table.So Organization Name is appear as dropdown list.If i choose the diffrent Organization Names the pivot table data is according to the Organization Name but no changes in chart.How change the Graph dynamically based on pivot table.
    Please help on this.

    ok.I created pivot table with 4 columns and created chart using pivot table chart options but all 4 columns are displaying chart.But I need only 2 column in chart ..unable to edit the only chart in pivot table.Please help on this.Thank you..

  • How change the report graph color in teststand

    how change the report graph color in teststand?

    Michael,
    You might also be able to customize the style sheet associated with the report. The TestStand Help provides some information about how to customize ATML or XML style sheets to change report colors based on the status of test steps.
    Please take a look at the following topics; are these helpful?
    ATML Report Style Sheets
    Modifying Cell Background Color Based on Step Status in ATML Test Results 5.0 Reports
    XML Report Style Sheets
    Modifying Cell Background Color Based on Step Status in XML Reports
    Tom
    TestStand Documentation

  • Can you change the units used for size and position in layout editor?

    Hello,
    In Aperture 3.4, does anyone know if you can change the units used for size and position in layout editor?  The page is set in inches, but the image size and position are given in centimetres and I would prefer to work all in inches to create custom layouts.  I can't see any way to change this.  If anyone knows how it would be much appreciated.  Thanks!

    Aperture uses the unit settings defined in the System Preferences.  Set the "Measurement Units" in the "Region" tab of the "Language & Text" preferences to "US"; the Aperture will display the Size & Position in inches, if it is the "Book" layout manager you are asking about.
    Merry Christmas!
    Léonie

  • Please help me to change the password policy in Sun Directory Server 6.0

    Hi,
    Please help me to change the password policy in Sun Directory Server 6.0

    What are you trying to accomplish? Have you at least read the manual?
    http://docs.oracle.com/cd/E19693-01/819-0995/fhkrj/index.html
    As reported in earlier threads on this forum, DSEE 6.0 IS NOT a release you should use in your production environment, specially if you're starting new projects; consider moving at least to the latest 6.x release which is 6.3.1.1.1
    thanks,
    Marco

  • Not able to change the password using FNDCPASS

    I am not able to change password using FNDCPASS. I am getting follwoing error while executing following command with APPLMGR user ( before that I have source the .env file ) (OS-Linux)
    [applmgr@ora11 /]$ FNDCPASS apps/apps 0 Y system/manager SYSTEM APPLSYS WELCOME
    Log filename : L2741743.log
    Report filename : O2741743.out
    APP-FND-01630: Cannot open file L2741743.log for appending
    Cause: FDPFOP encountered an error when attempting to open file L2741743.log for appending.
    Action: Verify that the filename is correct and that the environment variables controlling that filename are correct.
    Action: If the file is opened in read mode, check that the file exists. Check that you have privileges to read the file in the file directory. Contact your system administrator to obtain read privileges.
    Action: If the file is opened in write or append mode, check that you have privileges to create and write files in the file directory. Contact your system administrator to obtain create and write privileges.
    Can some one pls guide me on this

    Duplicate post-
    Not able to change the password using FNDCPASS
    Please post only once.
    Thanks,

  • How change the wallpaper/background with a command line ?

    Hi people,
    did someone know how change the wallpaper with a command line ?
    thx a lot

    Hi,
    I think this can be done with PowerShell. We could create a function to set wallpaper:
    Function Set-WallPaper($Value)
     Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
     rundll32.exe user32.dll, UpdatePerUserSystemParameters
    Open PowerShell; paste the function above in it to make this function work.
    Now, if you want to change some wallpaper, you could type the following text:
    Set-WallPaper -value "the path of you wallpaper"
    If you are interested, I would like to share the following article with you for your reference:
    Hey, Scripting Guy! How Can I Hide
    My Desktop Wallpaper?
    If you need some help on writing this script, you can also post your question to The Official Scripting Guys Forum:
    The
    Official Scripting Guys Forum
    Hope this helps. Thanks.
    Alex Zhao
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • How change the moving average prices?If run costing done In the MR21 system

    hI,
    How change the moving average prices?If run costing done In the MR21 system notallowing the changing the prices?
    Regards
    Channa

    Hi
    Showingerror
    A current or future standard price exists for material 300000007
    Message no. CKPRCH025
    Diagnosis
    A current or future cost estimate exists.
    Procedure
    You can set the price of a marked cost estimate through the radio button 'Default Planned Prices' and release it by saving.
    Please what is the process changing moving aveerage prices

  • Can I change the colors used in iOS7?

    Can I change the colors used in iOS7?
    The white background makes reading text and numbers very difficult.  Especially if the are in light gray.

    The answer to your question is "No"...and what you're experiencing is a major gripe with this "Upgrade".
    If Apple would allow the Invert Colors option to be activated without the effect that has on images it would resolve most of the concerns about iOS 7.  I would even consider downloading it... again.

  • I want to check the main diffrence in Pop up block enabled and disabled.But,i don't get any difference.Would u please help me to understand the difference using one practical example of website

    I want to check the main diffrence in Pop up block enabled and disabled.But,i don't get any difference.Would u please help me to understand the difference using one practical example of website

    Here's two popup test sites.
    http://www.kephyr.com/popupkillertest/test/index.html
    http://www.popuptest.com/

  • When I change the color using windows 7 color, I get a prompt to change back to firefox default or everything is very slow. Isn't there another way to fix the i

    When I change the color using windows 7, apparently firefox runs slower. The videos I watch are spotty and looking like it's in slow motion. Sometimes I get a prompt to use firefox colors and this fixes it. But why can't I use other colors, and are there settings to help me fix this problem? Thank you for any information you can give me. Joyce

    Try to disable hardware acceleration in Firefox.
    *Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    *https://hacks.mozilla.org/2010/09/hardware-acceleration/
    You can check for problems caused by recent Flash updates and try these:
    *disable a possible RealPlayer Browser Record Plugin extension for Firefox and update the RealPlayer if installed
    *disable protected mode in Flash 11.3 and later
    *disable hardware acceleration in the Flash plugin
    *http://kb.mozillazine.org/Flash#Troubleshooting

Maybe you are looking for