Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Business Add-In

Former Member
0 Kudos
228

I need to change the Document Type of a Purchase Order before it

is generated via transaction ME59N.

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.

But I am not sure which method to call.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
88

Hi

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.

Reward points if useful

Regards

Anji

4 REPLIES 4

Former Member
0 Kudos
88

Hi Gregory,

You can read the documentation of the Badi or put a break-point inside the methods that you could think might work for you, and execute the transaction in order to verify which one is the one that you need.

Regards,

Eric

Former Member
0 Kudos
89

Hi

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.

Reward points if useful

Regards

Anji

Former Member
0 Kudos
88

Thanks for your reply. I understand your code, but I want to

change the Document Type from within the the Badi.

Is that possible?

Former Member
0 Kudos
88

I did this and it seems to be working:

DATA mepoheader TYPE mepoheader.

CALL METHOD im_header->get_data

RECEIVING

re_data = mepoheader.

mepoheader-bsart = 'NB'.

CALL METHOD im_header->set_data

EXPORTING

im_data = mepoheader.

Thanks for your help.