Skip to Content
author's profile photo Former Member
Former Member

BADI for ME59N

Hi

I want to do some validations in ME59N transaction during creation of POs automatically from PR.

Suppose if a PR has 10 line items . If only 8 of them are valid when we do the validations then PO should be created only with 8 line items?.

Is there any BADI for ME59N apart from ME_PROCESS_PO_CUST.

If we enhance the BADI ME_PROCESS_PO_CUST, then if the first line item is invalid , i want to remove the line item from PO line item and throw a warning message.

Is there any option of deleting PO line item at item method or check method .

If so can anyone please send me the way to do.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 01:14 PM

    Hi,

    I assume I can call a method on the IF_EX_ME_PROCESS_PO_CUST

    interface of the ME_PROCESS_PO_CUST add-in to do this.

    1. check out the enhancment

    MEREQ001

    2. In this, check out the FM Exits :

    EXIT_SAPLMEREQ_008

    EXIT_SAPLMEREQ_010

    if you are working on BADI Then this is the code

    First implement the BADI in SE19 and use the code

    this is the same BADI I used for the same type of requirement

    see the sample code

    BAdI Name: ZCHECK_PO_LINE_ITEM (Implementation name) PO Account assignment

    Definition Name: ME_PROCESS_PO_CUST

    Interface Name : IF_EX_ME_PROCESS_PO_CUST

    Implementing Class: ZCL_IM_BADIN_ACCOUNT_ASSGN

    Method : PROCESS_HEADER

    ************************************************************************

    METHOD if_ex_me_process_po_cust~process_header .

    DATA : re_data TYPE mepoheader.

    *get the item data

    CALL METHOD im_header->get_data

    RECEIVING

    re_data = re_data.

    re_header = re_data.

    IF ( re_data-bsart NE 'ZOC' AND re_data-bsart NE 'ZPC' ).

    IF ( re_data-bsart <> 'ZIC' AND re_data-bsart <> 'UB' ).

    IF re_data-bukrs NE '1001'.

    MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'Use only Sipchem Company'

    'Code for External Procurement'.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDMETHOD.

    ************************************************************************

    Method : PROCESS_ITEM

    ************************************************************************

    METHOD if_ex_me_process_po_cust~process_item .

    DATA: v_menge TYPE bamng, " PR Quantity

    v_statu. " PR Status

    DATA : re_data TYPE mepoitem,

    re_data1 TYPE mepoaccounting,

    re_accountings TYPE purchase_order_accountings ,

    header TYPE purchase_order_accounting.

    *get the item data

    CALL METHOD im_item->get_data

    RECEIVING

    re_data = re_data.

    IF ( re_header-bsart NE 'ZOC' AND re_header-bsart NE 'ZPC' ).

    IF re_header-bsart EQ 'ZRL'.

    IF re_data-konnr EQ space.

    MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You cant create a Release order'

    'without a reference to Outline Agreeement'.

    ENDIF.

    ENDIF.

    • IF ( re_header-bsart NE 'ZOC' AND re_header-bsart NE 'ZPC' ).

    IF ( re_data-banfn EQ space AND re_data-anfnr EQ space ).

    MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You can create a Purchase order'

    'only with reference to a PR or RFQ'.

    ENDIF.

    • ENDIF.

    • call method IM_ITEM->GET_ACCOUNTINGS

    • RECEIVING

    • RE_ACCOUNTINGS = RE_ACCOUNTINGS.

    **get the accounting reference variable,this reference is needed to get

    **the GL account *number and Asset number

    *loop at RE_ACCOUNTINGS into header.

    **get the accounting info.

    • call method header-ACCOUNTING->GET_DATA

    • RECEIVING

    • re_data = re_data1.

    **if the account assignment is K then check for GL account

    **if its A then check for Asset number

    • if re_data-KNTTP eq 'K'.

    • if re_data1-SAKTO IS INITIAL.

    • MESSAGE ID 'ZM_MSG'

    • TYPE 'E' NUMBER '000' WITH 'Enter G/L account'.

    • ENDIF.

    • ELSEIF re_data-KNTTP eq 'A'.

    • if re_data1-ANLN1 IS INITIAL.

    *

    • MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'Enter Asset Number'.

    • ENDIF.

    • ENDIF.

    *endloop.

    IF re_data-knttp NE 'K' AND re_data-pstyp NE '9' .

    IF syst-cprog EQ 'RM_MEPO_GUI'.

    IF re_data-uebto IS NOT INITIAL OR

    re_data-uebtk IS NOT INITIAL OR

    re_data-untto IS NOT INITIAL.

    MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You cant change delivery settings'.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDIF.

    • Checking PO quantity with PR Quantity

    • select single statu menge into (v_statu, v_menge) from eban

    • where banfn = re_data-banfn and

    • bnfpo = re_data-bnfpo.

    *

    • if v_statu <> 'B'.

    • if re_data-menge gt v_menge.

    • message e000(zm_msg) with 'You cant create PO exceeding' 'the PR Quantity'.

    • endif.

    • else.

    • MESSAGE e000(ZM_MSG) WITH 'You cant create a PO with reference' 'to Completed PR'.

    • endif.

    ENDMETHOD.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I dont see anywhere we are deleting the PO line item.

      My question was to delete a PO line item if it is invalid after validations, i need to create the PO with the rest of the PO line items.

      the user exits are at the PR level. I want a user exit which can be used between PR to PO creation from ME59N transaction.

      can we delete a PO line item at the item method if i suppose it is invalid. Or can we get all the line items in CHECK method and then delete the invalid items. Will the PO will create with the rest of the items??

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.