Thursday, April 12, 2012

BADI for purchase requisition in sap ABAP

BADI for Purchase requisition : ME_PROCESS_REQ_CUST

Purpose: when ever user is changing price in PR it will display error message to maintain text .


method IF_EX_ME_PROCESS_REQ_CUST~PROCESS_ITEM.

**added by satya for valuation price change in PR'S related for projects

data: it_ci_eban type MEREQ_ITEM,

it_ci_eban1 type ref to IF_PURCHASE_REQUISITION,

it_ci_eban2 type MEREQ_HEADER.

data: V_EX_PS_PSP_PNR type EXKN-PS_PSP_PNR.

DATA:wrk_object TYPE thead-tdname.

DATA : t_remarks TYPE TABLE OF tline," OCCURS 0 WITH HEADER LINE,

V_PREIS TYPE mbew-VERPR.

clear:V_PREIS,V_EX_PS_PSP_PNR,it_ci_eban.

IF SY-TCODE EQ 'ME51N' or SY-TCODE EQ 'ME52N'.

call method IM_ITEM->IF_ACCT_CONTAINER_MM~GET_DATA

importing

EX_PS_PSP_PNR = V_EX_PS_PSP_PNR.

call method IM_ITEM->GET_DATA

receiving

re_data = it_ci_eban.

call method IM_ITEM->GET_REQUISITION

receiving

RE_REQUISITION = it_ci_eban1.

call method it_ci_eban1->GET_DATA

receiving

RE_DATA = it_ci_eban2.

if V_EX_PS_PSP_PNR NE SPACE.

select single VERPR from mbew into V_PREIS where matnr eq it_ci_eban-matnr and bwkey = it_ci_eban-werks.

CONCATENATE it_ci_eban2-BANFN it_ci_eban-BNFPO INTO wrk_object.

call function 'READ_TEXT'

exporting

client = sy-mandt

id = 'B01'

language = sy-langu

name = wrk_object

object = 'EBAN'

tables

lines = t_remarks

exceptions

not_found = 4.

delete t_remarks where TDLINE eq space.

IF V_PREIS NE it_ci_eban-PREIS.

.IF t_remarks[] IS INITIAL.

MESSAGE 'Please mention reason for change of price in Item->Texts->Item Note' TYPE 'E'.

ENDIF.

ENDIF

ENDIF.

ENDIF.

endmethod.

Reactions:

0 comments:

Post a Comment