Automate

 View Only
  • 1.  BAPI_MATERIAL_SAVEDATA to update Profit Center

    Posted 23 days ago

    Hi Experts,
    Could you please help with a script? I'm trying to make a direct script to update a profit center and it was a success, but I'd like to make a loop that would make an update to all plant at once and then commit (to save time). I can't figure this out - it doesn't update. Does anyone know what am I doing wrong?

    Thank you for your help.

    BR,
    Tomasz



    ------------------------------
    Tomasz Tomaszewski
    Self-Registration Shared Account
    ------------------------------


  • 2.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Employee
    Posted 22 days ago

    Hi Tomasz

    Looks like you are close. Can you please share you script?  Template too, if it's ok - otherwise no worries.

    Best Regards,

    Sigrid



    ------------------------------
    Sigrid Kok
    *Precisely Software Inc.
    ------------------------------



  • 3.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Posted 21 days ago

    Hello,

    Sure, thank you for taking time to look into this.
    Script runs the loop, but updates only the last entry on the file.

    BR,
    Tomasz



    ------------------------------
    Tomasz Tomaszewski
    Self-Registration Shared Account
    ------------------------------



  • 4.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Employee
    Posted 21 days ago

    Hi Tomasz

    Thanks for sharing your script.

    I am running into the same behavior, and I think I know why.

    When you go into the tcode, you have to enter material number, then select the Sales Plant view, fill in the sales plant data and then update your profit center and click Save.  The Save ends the interaction and you have to start over when you do it manually, If recording in Transaction, that same Save ends the recording.  That means you cannot select another plant and change the profit center in the same interaction/recording.

    I believe the BAPI is behaving the same way. It won't let you loop through multiple plants in a single post, so you have to post separately. I now remember someone else asked something similar a few years ago for extensions, and it didn't work in a loop for similar reasons.

    Hope that makes sense. If there are any ABAP experts who can add to this, please share.

    Best Regards,

    Sigrid



    ------------------------------
    Sigrid Kok
    *Precisely Software Inc.
    ------------------------------



  • 5.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Posted 21 days ago
    Edited by Jeremy Maxfield 21 days ago
      |   view attached

    Hi Tomasz & Sigrid,

    I had tried a while back to accomplish a full plant/sorg extension in a very similar case and was unsuccessful as well with just a script that did it for me. I ended up having to take the steps below to accomplish what I wanted.

    For an excel based form, I ended up creating a matrix for both Plants and Sorgs I wanted to extend to on my main Request sheet. I identified my material, then I create a check for each I wish to deploy.



    Then on the respective sheet for each, I used formulas to take the horizontal Request 'X' and mapped via formula to vertically allow the script to run.

    The biggest win here is my script is able to run seamlessly for each combination requested, the biggest challenge is maintaining the formulas. I have attached a shareable version of my template that includes the formulas that might at least help Tomasz get something working in short order. If you can think of any improvements I could do to simplify doing a similar request (create/update/extend across various SAP structures), please let me know!

    My goal is to eventually put this in an Evolve web-form, as I think it would be easier to manage as we add/remove plants.



    ------------------------------
    Jeremy Maxfield
    Lead BSA
    Chamberlain Group, LLC
    Oak Brook IL
    ------------------------------



  • 6.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Employee
    Posted 21 days ago

    Thanks for sharing, @Jeremy Maxfield  I'll take a closer look when I have time.

    Are you able to do the updates/posts in a loop across plants and sales orgs, or is it one at a time?  That has been the issue here - and it would be for the Transaction and Direct - it can only do one at a time, not in a loop.

    Thanks again,

    Sigrid



    ------------------------------
    Sigrid Kok
    *Precisely Software Inc.
    ------------------------------



  • 7.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Posted 16 days ago

    Hi Sigrid,

    No, it is not through Loop, as I have never been able to achieve that or known anyone who has been able to get updates across plants/sorgs to script like that.

    My goal here was to create a user experience where the end user did not have to repeat the material number / plant combinations that they wanted to extend to. 2nd goal was to not have to create multiple iterations of the same script, each with a different hard coded plant to extend and new run log mapping.

    So the first sheet is effectively a control sheet with formulas mapping everything to the respective Plant Ext sheet, as well as the Sales Org Extension sheet. Then the Plant Ext script can run just like a regular Automate script, extending each material to each plant that had been selected on the previous sheet, repeating the same for Sales Org Extension.

    I believe something similar could work for Tomasz. with easier maintenance in a web-form.



    ------------------------------
    Jeremy Maxfield
    Lead BSA
    Chamberlain Group, LLC
    Oak Brook IL
    ------------------------------



  • 8.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Employee
    Posted 15 days ago

    Thanks for confirming @Jeremy Maxfield.

    @Tomasz was trying to posting multiple plants in the same transaction via a loop. I can only get one to post at a time in the tcode and the BAPI. I think that is simply the behavior of both.

    Best Regards,

    Sigrid



    ------------------------------
    Sigrid Kok
    *Precisely Software Inc.
    ------------------------------



  • 9.  RE: BAPI_MATERIAL_SAVEDATA to update Profit Center

    Posted 15 days ago

    Thank you all for your time. I'll just have to go with what I have :). 



    ------------------------------
    Tomasz Tomaszewski
    Self-Registration Shared Account
    ------------------------------