Application Development and Automation 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: 
Read only

BADI and BAPI

Former Member
0 Likes
1,240

Hi friends ,

1) Could any one tell the process for this BADI

and

2) which BAPI well will use for populating using these transactions

Populated Purchase Order & Purchase Requisition Document number in a custom Z table each time created through ME21N & ME51N by using ME_PURCHDOC_POSTED & ME_REQ_POSTED

Cheers,

Naren.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,043

Hi,

BAPI for

<b>me21n --> BAPI_PO_CREATE.</b>

<b>me51n --> BAPI_REQUISITION_CREATE</b>

Check transaction BAPI and check under "Material management --> Purchasing" for more BAPIs related to purchasing.

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

For creating BADI as per your requirement, follow these steps.

--> Go to transaction SE19.

--> Enter Implementation name "Z_ME_PURCHDOC_POSTED" ( you can enter any other meaningful name too) and hit create.

--> When asked for "definition name" , enter "ME_PURCHDOC_POSTED".

--> On the screen which opens, enter meaningful description. and hit save.

--> When asked, enter your custom development class and create a transport request.

--> Now, select "interface" tab.

--> Here you can do two things. a). double-click on method and it will directly take you to the place where you write your code to update custom Z table. OR b). Double-click on the "implementation class" . This you will fine under interface name and it would be line "ZCL_IM__ME_PURCHDOC_POSTED".

--> If you double-click on "implementation class", it will take you to the screen ( this is same as SE24 screen where you implement can see classes and interfaces ) where you can see method, what parameters are available etc. From here also you can double-click on method and do to the place where you can implement you code.

For ME_REQ_POSTED just replace ME_PURCHDOC_POSTED by ME_REQ_POSTED in above steps.

For more information on BADI, please refer to this link.

http://help.sap.com/saphelp_46c/helpdata/EN/ee/a1d548892b11d295d60000e82de14a/frameset.htm

Let me know if you have any question.

Regards,

RS

Hi,

BAPI for

<b>me21n --> BAPI_PO_CREATE.</b>

<b>me51n --> BAPI_REQUISITION_CREATE</b>

Check transaction BAPI and check under "Material management --> Purchasing" for more BAPIs related to purchasing.

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

For creating BADI as per your requirement, follow these steps.

--> Go to transaction SE19.

--> Enter Implementation name "Z_ME_PURCHDOC_POSTED" ( you can enter any other meaningful name too) and hit create.

--> When asked for "definition name" , enter "ME_PURCHDOC_POSTED".

--> On the screen which opens, enter meaningful description. and hit save.

--> When asked, enter your custom development class and create a transport request.

--> Now, select "interface" tab.

--> Here you can do two things. a). double-click on method and it will directly take you to the place where you write your code to update custom Z table. OR b). Double-click on the "implementation class" . This you will fine under interface name and it would be line "ZCL_IM__ME_PURCHDOC_POSTED".

--> If you double-click on "implementation class", it will take you to the screen ( this is same as SE24 screen where you implement can see classes and interfaces ) where you can see method, what parameters are available etc. From here also you can double-click on method and do to the place where you can implement you code.

For ME_REQ_POSTED just replace ME_PURCHDOC_POSTED by ME_REQ_POSTED in above steps.

For more information on BADI, please refer to this link.

http://help.sap.com/saphelp_46c/helpdata/EN/ee/a1d548892b11d295d60000e82de14a/frameset.htm

Let me know if you have any question.

Regards,

RS

4 REPLIES 4
Read only

Former Member
0 Likes
1,043

Hi,

Go to Transaction SE19 and implement the BADI ME_PURCHDOC_POSTED or

ME_REQ_POSTED

by copying it to a ZBADI.

then go to the methods and write the code.

see the sample code of BADI.

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 if useful

regards,

ANji

Read only

Former Member
0 Likes
1,044

Hi,

BAPI for

<b>me21n --> BAPI_PO_CREATE.</b>

<b>me51n --> BAPI_REQUISITION_CREATE</b>

Check transaction BAPI and check under "Material management --> Purchasing" for more BAPIs related to purchasing.

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

For creating BADI as per your requirement, follow these steps.

--> Go to transaction SE19.

--> Enter Implementation name "Z_ME_PURCHDOC_POSTED" ( you can enter any other meaningful name too) and hit create.

--> When asked for "definition name" , enter "ME_PURCHDOC_POSTED".

--> On the screen which opens, enter meaningful description. and hit save.

--> When asked, enter your custom development class and create a transport request.

--> Now, select "interface" tab.

--> Here you can do two things. a). double-click on method and it will directly take you to the place where you write your code to update custom Z table. OR b). Double-click on the "implementation class" . This you will fine under interface name and it would be line "ZCL_IM__ME_PURCHDOC_POSTED".

--> If you double-click on "implementation class", it will take you to the screen ( this is same as SE24 screen where you implement can see classes and interfaces ) where you can see method, what parameters are available etc. From here also you can double-click on method and do to the place where you can implement you code.

For ME_REQ_POSTED just replace ME_PURCHDOC_POSTED by ME_REQ_POSTED in above steps.

For more information on BADI, please refer to this link.

http://help.sap.com/saphelp_46c/helpdata/EN/ee/a1d548892b11d295d60000e82de14a/frameset.htm

Let me know if you have any question.

Regards,

RS

Read only

0 Likes
1,043

Thanks for your reply.

But will be code we will write in the BADI method in implementation part.

With regards,

Naren.

Read only

0 Likes
1,043

Hi,

Yes, you write your code in BADI implementation.

Check the last step in my answer before. It talks about where you write your code.

Let me know if you have any question.

Regards,

RS