Code in badi me_process_po_cust

Hi,
       I Implemented a BADI for PO for me_prcess_po_cust. I would lik to capture Item and header details from the method 'POST'. In this method 2 parameters are there. 1. IM_HEADER type ref of IF_PURCHASE_ORDER_MM. In this  interface several methods are there. I needed to capture all header and item details. But when I am calling these methods its giving a run time error plz help me in this regard.
              I wrirte the code as follows.
method IF_EX_ME_PROCESS_PO_CUST~POST.
data: if_get_data TYPE REF TO IF_PURCHASE_ORDER_MM,
         if_get_item TYPE REF TO IF_PURCHASE_ORDER_MM,
         ge_data  type MEPOHEADER,
         ge_items type PURCHASE_ORDER_ITEMS.
          CALL METHOD IF_GET_ITEM->GET_ITEMS
                   RECEIVING
                   RE_ITEMS = ge_items
endmethod.

You have to update the account assignment(s)
lt_accountings = im_item->get_accountings( ).
LOOP AT lt_accountings INTO ls_accounting.
   ls_accounting_data = ls_accounting-accounting->get_data( ).
   " ... update cost center
   ls_accounting-accounting->set_data( ls_accounting_data ).
ENDLOOP.
Also to prevent infinite loop, only use set_data if you actually change cost center value.
Regards,
Raymond

Similar Messages

  • Custom tab data not saving in ME22N w/ BAdI ME_PROCESS_PO_CUST

    Hello all,
    I have implemented BAdis ME_PROCESS_PO_CUST & ME_GUI_PO_CUST and created a custom tab at the header level in ME21N/ME22N. I have fields such as Delivery Date and Ex Factory Date in my tab.
    We are able to put data in these fields and have that data populate their respective fields in the Purchase Order.
    Our users would like to be able to run ME22N and select certain line items and have only those items changed with the data from the custom fields. 
    So, my question is how do I handle line selection in the context of these BAdIs?  Is there a way to know which lines have been selected and then only change the data in those items?
    I have looked in Class CL_PO_ITEM_HANDLE_MM for an attribute or method that might help but I haven't found anything as of yet. 
    I have found that the field MEPO1211-TCSELFLAG is set when a line is selected in ME22N.  However, I haven't found a way to work with it.  It doesn't get passed to any of the methods in the BAdIs, as far as I know. 
    January 27, 2012  **************
    We were able to capture the lines selected by using code from method mass_change in Include LMEGUICJK, Function Group MEGUI.  The lines are in the lt_models table. 
    So, now my issue is getting data to save in ME22N.  When I put data in my custom tabs and select a line, the data gets changed on the screen but does not save.  It does work when I make a change in another field, like changing the description for instance.  I'm using the set_changed method in Process_Header from ME_PROCESS_PO_CUST but it doesn't work. 
    I'm getting the idea that I'm the first ABAP developer to try this...
    Thanks for any help.
    Kind Regards,
    Chris
    Edited by: Chris  Mowl on Jan 11, 2012 10:33 AM
    Edited by: Chris  Mowl on Jan 11, 2012 4:24 PM
    Edited by: Chris  Mowl on Jan 27, 2012 10:57 AM
    Edited by: Chris  Mowl on Jan 27, 2012 2:00 PM

    Hi,
    Checkout the below link :
    <link to blacklisted site removed by moderator>
    Shailaja Ainala.
    Edited by: Thomas Zloch on Jan 28, 2012 9:06 PM

  • BADI - ME_PROCESS_PO_CUST - To update Condition Types at time of creation

    Hi All
    I'm relatively new to Implementing BADIs. I'm using the BADI ME_PROCESS_PO_CUST.
    I have to update certain condition types with values determined from a custom table maintained for related Vendors.
    I have created a 'Z' implementation for ME_PROCESS_PO_CUST and activated the implementation. But when I try to create a PO, the code doesn't seem to be execute!
    Following is the code bundle -
    METHOD if_ex_me_process_po_cust~process_header .
      DATA : l_items TYPE purchase_order_items.
      DATA : l_single TYPE purchase_order_item.
      DATA : l_item_cond TYPE mmpur_tkomv.
      CALL METHOD im_header->get_items
        RECEIVING
          re_items = l_items.
      LOOP AT l_items INTO l_single.
        CALL METHOD l_single-item->get_conditions
          IMPORTING
            ex_conditions = l_item_cond.
      ENDLOOP.
    ENDMETHOD.       "IF_EX_ME_PROCESS_PO_CUST~PROCESS_HEADER
    Could you please give me your inputs on this?
    Regards
    Kripal
    [email protected]

    Kripal,
           The method PROCESS_HEADER gets trigerred only when you make an entry in any of the header fields and then press ENTER or do some action.
    For a simple case of analysis put a break-point at
    CALL METHOD im_header->get_items
    RECEIVING
    re_items = l_items.
    in your code.
    Now if you execute ME21N you will see that the code will not get triggered.But make an entry for one of the fields say fpr purchasing organisation.Now if you press ENTER or click on any other tab your code will get triggered.
    Hope this helps.
    <i>Reward helpful answers</i>
    Cheers
    Nishanth

  • Urgent Help Needed in BAdI ME_PROCESS_PO_CUST

    Hello friends,
    I m workin on BAdI ME_PROCESS_PO_CUST , my requirement is to store header level text in po if it is left blank by user , for this i have creadted standard text for every po header text , and implemeted method POST of the badi. so when user is saving the po , i m checking whether all header text is filled by user or not , for this i have called method GET_TEXT , if the text is blank i m reading data from standard text using READ_TEXT function module and setting in perticular text by using method SET_TEXT , every thing is working fine , the respective text ifrom standard text  getting filled to the perticular text of the po , if left blank by the user .  But the actual problem is that when i m going to display the same po again , the text that i was supplied by standard text is not showing in po.
    is there is anything that i missed out , i also done coomit work , but its not working ,
    so please suggest.......
    dont worry abt points

    Dear Mr Mahesh
    I also face similar problem . But my limitation is that I am new to BADI . Sir it will be great help if you can please mail me the steps / procedure and code to be written for implementing the above BADI .
    Sir , I look forward for your kind help please .
    Regards
    B V Mittal
    [email protected]

  • Rollback BAPI in BADI ME_PROCESS_PO_CUST

    hi guys,
    I used BADI ME_PROCESS_PO_CUST to implement a code before saving the purchase order (Method POST).
    This code contains a BAPI to create a delivery BAPI_OUTB_DELIVERY_CREATENOREF. If this BAPI fails (this is when Return parameter contains 'E' message), I execute function BAPI_TRANSACTION_ROLLBACK.
    Guess what is happening?
    There is no purchase order created even when screen shows message "Standard PO created under the number 45#######".
    What do I want to do?
    - Rollback the bapi executed and let the system continue saving the purchase order.
    - If possible show a message to the user that there is an error, but command MESSAGE doesn't seem to work in this BADI
    Could you share your insights with this wannabe-abapper?
    PD: it says in documentation that it is required ABAP OO to implement this BADI and I think I used it correctly for gathering all data I needed. But I just don't understand why MESSAGE statement and FM POPUP_TO_CONFIRM don't work.

    Hello
    You may try an approach like this:
      IF ( 1 = 1 ).
        MESSAGE 'Creation of outbound delivery failed'  type 'I'.
        data: ld_dummy  type string,
              ls_msg    type SMESG,
              lt_msg    type tsmesg.
          message id '00' type 'E' number '398' with 'Creation of outbound delivery failed'
                                                      space space space into gl_dummy.
        move-CORRESPONDING syst to ls_msg.
        APPEND ls_msg to lt_msg.
        CALL FUNCTION 'FB_MESSAGES_DISPLAY_POPUP'
          EXPORTING
            IT_SMESG              = lt_msg
    *       ID_SMESG_ZEILE        =
    *       IT_RETURN             =
    *       ID_SEND_IF_ONE        =
          EXCEPTIONS
            NO_MESSAGES           = 1
            POPUP_CANCELLED       = 2
            OTHERS                = 3.
        IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      endif.
    Regards
      Uwe

  • BADI ME_PROCESS_PO_CUST - DOES NOT CLEAR OUT ERROR

    In ME21N I want to validate the field Commodity Code - STAWN. I have used the BADI ME_PROCESS_PO_CUST*
    . Have used get_foreign_trade() in the PROCESS_ITEM method . I am able to throw an error . It is doing it but*
    after throwing error then when we give a valid Commoditycode too it is still showing the error and not clearing the error  .*
    As suggested by Dean Q I used   INCLUDE mm_messages_mac,
    tried im_item->set_foreign_trade( ls_mepo_eipo)  still when a valid Commodity code is entered after an invalid one  it does not clear out the error. In fact on checking using break-point I found that the second time it does not enter into the method  PROCESS_ITEM.    Any help is welcome
    Nivedita

    Hi,
    In SE18 give ME_PROCESS_PO_CUST as the enhancement spot and display. At the left side of the screen you can see the badi definition ME_PROCESS_PO_CUST. Expand the tree and double click on implementations. You can see the enhance implementations created. Double click on the enhancement implementation and in that screen there is a check box 'Implementation is active' and field 'Effect in current client'.
    If you know the enhancement implementation name(not the badi implementation name), you can check it directly from se19.
    Regards,
    Poornima

  • METHOD PROCESS_ACCOUNT OF BADI ME_PROCESS_PO_CUST.

    HI,
    I need to implement the method PROCESS_ACCOUNT of badi ME_PROCESS_PO_CUST.
    can anyone suugest me the samolw code for the same.
    i know i can get the account assignment data in the mathod IM_ACCOUNT->get_data.
    But how to declare the variable to store the data of im_account->getdata.
    so that i can use it in the progra?
    i mean for ex for header we will declare
    ls_header type mepoheader
    and then
    ls_header  = im_header->get-data.
    similarly can you plese tell me the declaration for storing the account assinment data.
    which table that variable will refer to.
    Smriti

    hai smriti
    u can call the method
    data: it_data type MEPOACCOUNTING
    im_accoutn->get_data  importing re_data  = it_data.
    just click the method type of parameter IM_ACCOUNT which is IF_PURCHASE_ORDER_ACCOUNT_MM  an interface
    u will get all the methods fro the same  u have ur mehtod get_data just click on it and click parameters and u get the paramter type  which is MEPOACCOUNTING
    regards
    m.a
    Edited by: mohammad afzal on Jul 9, 2009 7:11 AM

  • How to issue warning message in BADI ME_PROCESS_PO_CUST

    Hi Guys,
    I have already checked the forum regarding this. There are lots of threads. Unfortunately none of them helped me. I must be missing some thing in my code.
    I tried issuing warning message in BADI ME_PROCESS_PO_CUST and method PROCESS_ITEM.
    First i tried with normal message statement
    MESSAGE w001(00) WITH text-001 text-002.
    Didn't worked.
    Next tried calling standard macros
      DATA:mmmfd_cust_01 TYPE mmpur_metafield VALUE 90000000.
      call method cl_contextfield_mm=>set_current_field
                                      exporting im_field = mmmfd_cust_01.
      mmpur_metafield mmmfd_cust_01.
    mmpur_message_config 'W' 'X' ' '.      "Tried all permutations here
    mmpur_message_forced 'W' '00' '001' text-001 text-002 '' ''.
    Still no solution
    Tried with macro mmpur_message also
    Can some one helpme out to solve this issue.
    Thanks,
    Vinod.

    Hi all,
    Thanks for the responce.
    Not sure whether you have looked into BADI documentation or not. Please check below.
    "Further notes
    The above-mentioned macros are defined in the program MM_MESSAGES_MAC. Please include this program in your own application.
    Never issue messages in BAdI ME_GUI_PO_CUST! This is the task of the business logic and must therefore be done via the BAdI ME_PROCESS_PO_CUST.
    "Never use the ABAP statement MESSAGE in the BAdI ME_PROCESS_PO_CUST. Please use the macro mmpur_message_forced only. This macro only writes a message in the message collector.
    If you wish to mark the business object as invalid in order to prevent posting, you must additionally use the INVALIDATE ( ) method of the relevant interface. In this connection, see also the code example in the PROCESS_ITEM method of the BAdI ME_PROCESS_PO_CUST.
    I have tried almost all macros including mmpur_message_forced 'E' 'ME' '083' l_text ' '  ' '  ' '.
    Not sure where i am missing:(
    If i give error using MESSAGE statement it is working perfectly i.e. give error and save the PO. Only wanted to know if there are any implications.
    Thanks,
    Vinod

  • BADI ME_PROCESS_PO_CUST Implementation is not called

    Hello,
    I have created a test implementation(local object) for BADI ME_PROCESS_PO_CUST and implemented the Process_Item method to compare item price with material master commercial price. I have also activated the implementation.
    When I create a PO using ME21N, this implemenation is not getting called. I have put a breakpoint in the implementation but processing doesn't stops here. Also I am not able to find 'Where used' of the BADI name or the interface 'IF_EX_ME_PROCESS_PO_CUST'.
    What are the reason for above behaviour? Do we maintain this BADI name in some Customizing Table?
    Please help.
    Regards,
    Shubham

    i did the same as you did and the code is clearly getting triggerred.
    Samle Code:
      DATA : l_header TYPE REF TO if_purchase_order_mm.
      DATA : l_conditions TYPE mmpur_tkomv.
      DATA : l_item LIKE LINE OF l_conditions.
      DATA : l_data TYPE mepoheader.
      CALL METHOD im_item->get_header
        RECEIVING
          re_header = l_header.
      CALL METHOD l_header->get_data
        RECEIVING
          re_data = l_data.
      CALL METHOD im_item->get_conditions
        IMPORTING
          ex_conditions = l_conditions.
      CALL METHOD im_item->set_conditions
        EXPORTING
          im_conditions = l_conditions.
    if i put break-point on any of these methods the implementation is getting trigerred.

  • BADI: ME_PROCESS_PO_CUST~PROCESS_HEADER? it is urgent

    Hi,
    I implemented BADI ME_PROCESS_PO_CUST and write some lines in the method of process_header.
    but i discover the field reswk is still no value. why.
    Thanks.
    Best regards.
      DATA: re_data TYPE mepoheader.
    get the header data
      CALL METHOD im_header->get_data
        RECEIVING
          re_data = re_data.
      re_data-reswk = 'L000'.
      CALL METHOD im_header->set_data
                EXPORTING
                  im_data = re_data.

    Hi
    First check whether this field is there or not in the table data of EKKO
    If it is there then it should come into the code of your BADi header data re_data.
    Also check after calling method whether other fields data is coming into re_data or not ? if other fields data is coming and only this particular field data is not coming then the problem with code(after it is there in EKKO)
    if in EKKO itself it is not there it is not your mistake/code mistake.
    Reward points for useful Answers
    Regards
    Anji

  • BADI : ME_PROCESS_PO_CUST Probelm

    I am using BADI
    ME_PROCESS_PO_CUST
    and want to throw error if any Z condition is not maintained , it is throwing error but also it is then existing from the transaction , showing error message , System Error ( Error in Method PO_POST )
    Can we send error message thru method POST of this BADI
    How to rectify this problem
    Ankesh Jindal
    Edited by: Ankesh Jindal on Dec 11, 2008 8:00 AM

    Display the samples provided by SAP for this BADI and manage the error messages as prescribed by SAP. (SE18 / GOTO / Sample Code / Display)
    (There are already some threads at sdn on [message management in BADI : ME_PROCESS_PO_CUS|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=me_process_po_cust+message&adv=true&sdn_author_name=&sortby=cm_rnd_rankvalue])
    Regards

  • Badi ME_PROCESS_PO_CUST IN ME21N

    HI,
    I USING BADI ME_PROCESS_PO_CUST IN ME21N IN THIS im_item->GET_SCHEDULES( ).
    HOW TO GET DATA FROM THIS METHOD.... IF IT POSSABLE PLEASE SEND THE CODE
    Edited by: Rob Burbank on Mar 12, 2009 9:21 AM

    Please use an informative subject and do not use all caps.

  • BADI ME_PROCESS_PO_CUST AND BADI ME_DEFINE_CALCTYPE

    Hi,
    How do I change the pricing type when creating aPurchase Order using BADI ME_PROCESS_PO_CUST and ME_DEFINE_CALCTYPE.
    I need to set the value  IM_DATA-Calctype = 'B'  (Calctype) on the first badi.
    Please help!

    hi this is the code:
    method IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM.
      DATA:   RE_DATA TYPE MEPOITEM,
              IM_DATA TYPE MEPOITEM.
         CALL METHOD IM_ITEM->get_data
         RECEIVING
            RE_DATA = RE_DATA.
    MOVE 'B' TO RE_DATA-calctype.
    CALL METHOD IM_ITEM->set_data
             EXPORTING
                IM_DATA  = RE_DATA.
    endmethod.
    Upon creation of PO error message prompt
    'Data from Business Add-In ME_PROCESS_PO_CUST not adopted'

  • Issue with BADI 'ME_PROCESS_PO_CUST'

    Hi People,
           I have a requirement wherein we need to make the Delivery Date in Schedule line of PO as Uneditable. This needs to be done for specific User-Group. Hence I have decided to use the BADI 'ME_PROCESS_PO_CUST' to attain the solution.
    I am facing a problem in using the BADI. I have created 2 different Field Selection(one with editable and other without) through SPRO and  am trying to swap the field selection based on user in the Method 'FIELDSELECTION_ITEM_REFKEYS' of the BADI interface. This swapping doesn't seems to be working. Can anyone give me some idea on why is this not working, Eventhough the Method is getting trigerred.
    Also i have tried the other method 'FIELDSELECTION_ITEM' to make them uneditable by changing the Field Selection Properties. but still no luck as this method not getting trigerred at all.
    Regards,
    Simin Raveendran.

    Hi Simin,
    Did you check the sample code which is delivered with the BADI. This code can be accessed by following:
    GOTO->Sample Code->Display.
    Check the method FIELDSELECTION_ITEM to see an code example. It appears to me that you should do something like that by changing the properties for field mmmfd_deliv_date.
    Below is the documentation for the method FIELDSELECTION_ITEM:
    Special Field Selection Item
    Functionality
    The FIELDSELECTION_ITEM method enables you to influence the field selection properties for a field.
    Parameters
    The following parameters are available:
    IM_HEADER - Document header
    The interface reference is of the type IF_PURCHASE_ORDER_MM.
    IM_ITEM - Document item
    The interface reference is of the type IF_PURCHASE_ORDER_ITEM_MM.
    CH_FIELDSELECTION - Fiele selection table
    By making changes to this table, you can influence the display properties of a field.
    This table consists of value pairs <METAFIELD|FIELDSTATUS>.
    The Metafield represents a business content (e.g. the PO quantity). Thus, for example, the database field EKPO-MENGE is linked to a certain metafield value just like the field MEPO1211-MENGE on the item overview screen in the purchase order.
    Through this abstraction, reference can be made to business contents on a uniform basis.
    Standard metafields are defined in the type group MMMFD.
    The field selection status has four possible instances:
    '-' Field is suppressed
    '*' Field is purely a display field
    '.' Input field
    '+' Mandatory field
    Notes
    Under no circumstances make any changes to the database within this method. On no account use Commits.
    Kind regards,
    Robert

  • How to fetch newly updated item data in BADI  ME_PROCESS_PO_CUST?

    Hi Everyone,
    While changing a PO, I have a requirement where I need to only modify fields of newly added items of a purchase order and keep the values of existing items as it is. I have implemented the BADI ME_PROCESS_PO_CUST for this. but not able to know how to achieve this requirement. please suggest a solution.
    Thanks and Regards,
         Indudhar P.G

    Hi,
    interfaces for PO header and item have method is_persistent. This method returns true if the item/header is persistent which is equal to that it has been written to DB. So new items are not be persistent and old items are persistent.
    Cheers

Maybe you are looking for

  • Chart Multiple Series - Line/Column Alignment

    In one of the pages from the charting section of the Adobe's online Flex help, http://livedocs.adobe.com/labs/flex3/html/help.html?content=charts_types_12.html#227567 there's a picture near the top showing a line chart overlaid on a column chart, and

  • Blurred Text in Exported SWF

    I have created a project using C3 and when I export all of the text appears blurred or bold. You can see one slide from my project and published swf from the following link untitled.zip Any help to get this looking better would be greatly appreciated

  • Migrating iWeb site from '06 version to '09 version

    I recently found that I could not publish a blog page using my old '06 version of iWeb and was instructed to upgrade. I just upgraded to the '09 version. It was also recommended to me that I first save my iWeb site onto a USB, which I did. I now have

  • IPS Auto Update 5525X

    Hello, I have two IPS ASA5525-IPS "module" of 5525-X Firewall. I set the proxy connection in DNS/Proxy Settings for update the signatures, but, i receive an error above: Auto Update Statistics    lastDirectoryReadAttempt = 11:03:09 GMT-03:00 Wed Jan

  • Receipt Please?

    I need a receipt for my yearly subscription showing the tax paid.