cancel
Showing results for 
Search instead for 
Did you mean: 

BADI for ME59N

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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??