Automate

 View Only
  • 1.  Skript needed für ME22 or ME22N adding positions

    Posted 09-27-2023 06:09

    Hello Community :)

    Is there a way to add positions to an existing purchase order? I've tried to record a skript with ME22 but there's no command like "go to last row" or "new position".

    Our purchase department often has to edit existing orders and also to add several new lines / positions.

    Challenges are: 

    1. I can't use "GUI scripting"
    2. I never worked with BAPI's
    3. I don't wanna use ME22N, as it always does what it wants :D but if someone has a good script where it handles the header/position/position detail - section, I'd take it <3 
    4. If a command like "new position" can't be found, I guess, I'd need an additional script that downloads the existing positions, so I know what my new position number  wourd be.

    Hope I put my words so that you understand what I need :) Thank you all in advance, have a great day!

    Best regards
    Iris

    PS: We're using Studio 20.2.9 :)



    ------------------------------
    Iris Müller
    THOMAS SABO GmbH & Co. KG
    ------------------------------


  • 2.  RE: Skript needed für ME22 or ME22N adding positions

    Posted 09-27-2023 06:47

    Unless you have a very long PO you can use the filtering option and go to line 999. 

    The following document describes how to deal with header details for ME21N but it works the same for ME22N.

    https://winshuttle-help.s3.amazonaws.com/step-by-step/en/studio/me21n-step-by-step_11.htm



    ------------------------------
    Rick Compen
    Lumileds Netherlands B.V.
    Eindhoven
    ------------------------------



  • 3.  RE: Skript needed für ME22 or ME22N adding positions

    Posted 10-12-2023 10:38

    Hi Rick,

    its about time to reply to your helpful hint to use ME22N with the filtering option. That helped a lot. Thank you very much!!
    But like I have forseen ... My skript struggels with the section opening or closing issue. I've found another thread, where Jan van Asseldonk gave some great tips. (https://community.precisely.com/communities/community-home/digestviewer/viewthread?GroupId=865&MID=45245&CommunityKey=4418e63a-9f6f-4468-b3f1-0186605ed001) so I think I'm gonna try and play with this. Will see if I'll be able to run more than one transaction succsessfully :D



    ------------------------------
    Iris Müller
    Specialist Data Management
    THOMAS SABO GmbH & Co. KG
    ------------------------------



  • 4.  RE: Skript needed für ME22 or ME22N adding positions

    Posted 10-12-2023 11:54

    Dear Community,

    I'm very close to tell our purchase department that they better create new PO's insteat of adding positions to existing orders....
    Well irony mode off: My script doesn't work. The first transaction runs well but the following ta's not. When I then go and debug them all, everything works perfectly. So it seems to be worth a thought, if I put on Debug-Mode and put a heavy item on my enter key for make the script runnng?! ;)



    ------------------------------
    Iris Müller
    Specialist Data Management
    THOMAS SABO GmbH & Co. KG
    ------------------------------



  • 5.  RE: Skript needed für ME22 or ME22N adding positions

    Employee
    Posted 10-12-2023 12:01

    Hi Iris

    So great you're hanging in there and trying suggestions. :)

    Can you please post your script and perhaps template (you can cleanse it of anything confidential)?  Also please share where it's breaking, maybe a screen shot?

    Thanks,

    Sigrid



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



  • 6.  RE: Skript needed für ME22 or ME22N adding positions

    Posted 10-12-2023 12:26

    Dear Sigrid,

    my script and the template are in German... I hope you'll still be able to read and see things. 
    As for the "break points": I can't provide anything, because if I go on debug-mode everything works fine.

    Thank you so much. Your help is really appreciated!

    Its closing time now over here in Germany. Have yourself a great day. Best regards,
    Iris



    ------------------------------
    Iris Müller
    Specialist Data Management
    THOMAS SABO GmbH & Co. KG
    ------------------------------

    Attachment(s)

    Txr
    ME22N_20231012_155150.Txr   6.73 MB 1 version


  • 7.  RE: Skript needed für ME22 or ME22N adding positions

    Employee
    Posted 10-12-2023 13:03

    Hi Iris

    One thing at the start is that you only want to swap to edit mode for the first transaction - after that SAP remembers, so this needs an IF First Transaction

    I don't believe you need these in your loop, and in fact in the last section, you have two OK codes

    So I would get rid of the first two sections and get rid of METOGGON3 and have the first thing in the loop be the filter.

    Also in the detail lines, it will remember the tab you left off on, so I recommend you go back to the first tab in the loop at the bottom

    for me that's this 

    TABIDT3 took me back to the first tab.

    You may consider also disabling all cursor rows - they're not needed.

    That's all I have time for right now.  Hope this gets you started.

    HTH

    Sigrid



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



  • 8.  RE: Skript needed für ME22 or ME22N adding positions

    Posted 10-13-2023 06:12
      |   view attached

    Hi Sigrid,

    wow! Thank you very much for this indept analysis. Awesome <3 !!

    I did most of what you suggested. The "first transaktion" condition I already had in my scipt but I wasn't sure if WinShuttle needs a "then" order. But it appears to be not the case.

    Next I did was more of a "trial and error" thing. E.g. changing some "go to tab" directions. I'll enclose the new script because ..... tadaaa... IT WORKS NOW :) I'm very happy and wanna thank all who helped directly or in case of Jan van Asseldonk indirectly. Thank you so much!

    Have a great day, best regards,
    Iris



    ------------------------------
    Iris Müller
    Specialist Data Management
    THOMAS SABO GmbH & Co. KG
    ------------------------------

    Attachment(s)



  • 9.  RE: Skript needed für ME22 or ME22N adding positions

    Employee
    Posted 10-13-2023 12:15

    Super happy to hear that it's working, @Iris Müller!  It's one of the tougher tcodes to automate, so you are not alone in this.  That's why I prefer a BAPI, but that has it's own learning curve.

    Thanks for letting us know and for sharing your script with others! 

    Best Regards,

    Sigrid



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



  • 10.  RE: Skript needed für ME22 or ME22N adding positions

    Employee
    Posted 09-27-2023 20:10

    Hi Iris

    Rick pointing you to the step by step guide is great.

    You could also consider using a BAPI: BAPI_PO_CHANGE in the Direct part of Studio.  It takes the interface out of the picture, which for this "Enjoy" tcode is a good thing! :)

    Best Regards,

    Sigrid



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