05-03-2007 11:43 AM
Hi,
I need to check the data when creating a Purchase Requisition with reference to an existing Purchase Requisition. Currently, I am using the user exit EXIT_SAPLMEREQ_005 to carry out these checks.
One of the checks that I need to do is to validate Cost Center. However, in this user exit, there is no cost center found in any of the imported parameters. Hence, I tried to use the function module 'COBL_RECEIVE'. However, the Cost Center retrieved is not refreshed and is incorrect. Are there any other ways where I can retrieve the correct Cost Center that is populated from the reference Purchase Requisition?
Will appreciate any help in resolving this issue.
Thanks lots.
Cheers,
Liyan
05-03-2007 11:55 AM
Hi
use the BADI in SE18 Tcode
ME_REQ_POSTED
implement this and use
the Method POSTED has the parameter IM_EBKN which has KOSTL field
this will work
see the sample code for this BADI
BAdI Name: ZPUR_RFQ (Implementation name) Purchase Requisitions
Definition Name: ME_REQ_POSTED
Interface Name : IF_EX_ME_REQ_POSTED
Implementing Class: ZCL_IM_PUR_REQ
Method : POSTED
************************************************************************
METHOD if_ex_me_req_posted~posted .
TYPE-POOLS: pgrt.
DATA: t_txpdat TYPE STANDARD TABLE OF txpdat.
DATA: s_txpdat TYPE txpdat.
DATA: t_ident TYPE pgrt_t_obj_ident.
DATA: s_ident TYPE pgrt_obj_ident.
DATA: ident_tmp TYPE eketkey.
DATA: nmrid_init TYPE txpdat-nmrid.
DATA t_obj_event TYPE pgrt_t_obj_event.
DATA s_obj_event TYPE pgrt_obj_event.
DATA t_event TYPE pgrt_t_event.
DATA s_event TYPE pgrt_event.
DATA change_yes TYPE c.
IF l_s_eban-estkz NE 'B'.
CLEAR v_mtart.
SELECT SINGLE mtart INTO v_mtart FROM mara WHERE matnr = l_s_eban-matnr.
IF v_mtart EQ 'ZERS' OR v_mtart EQ 'FHMI' OR v_mtart EQ 'UNBW'.
MESSAGE e000(zm_msg) WITH 'You are not allowed' 'to create PR for stock items'.
ENDIF.
ENDIF.
IF l_s_eban-knttp NE 'F' OR l_s_eban-pstyp NE '9'.
IF l_s_eban-knttp NE 'A'.
IF ( l_s_eban-pstyp NE '9' AND l_s_eban-pstyp NE 'D' ) AND l_s_eban-matnr EQ space.
MESSAGE e000(zm_msg) WITH 'You cannot create' 'a PR without material number'.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
reward points if useful
regards
Anji
05-03-2007 11:55 AM
Hi
use the BADI in SE18 Tcode
ME_REQ_POSTED
implement this and use
the Method POSTED has the parameter IM_EBKN which has KOSTL field
this will work
see the sample code for this BADI
BAdI Name: ZPUR_RFQ (Implementation name) Purchase Requisitions
Definition Name: ME_REQ_POSTED
Interface Name : IF_EX_ME_REQ_POSTED
Implementing Class: ZCL_IM_PUR_REQ
Method : POSTED
************************************************************************
METHOD if_ex_me_req_posted~posted .
TYPE-POOLS: pgrt.
DATA: t_txpdat TYPE STANDARD TABLE OF txpdat.
DATA: s_txpdat TYPE txpdat.
DATA: t_ident TYPE pgrt_t_obj_ident.
DATA: s_ident TYPE pgrt_obj_ident.
DATA: ident_tmp TYPE eketkey.
DATA: nmrid_init TYPE txpdat-nmrid.
DATA t_obj_event TYPE pgrt_t_obj_event.
DATA s_obj_event TYPE pgrt_obj_event.
DATA t_event TYPE pgrt_t_event.
DATA s_event TYPE pgrt_event.
DATA change_yes TYPE c.
IF l_s_eban-estkz NE 'B'.
CLEAR v_mtart.
SELECT SINGLE mtart INTO v_mtart FROM mara WHERE matnr = l_s_eban-matnr.
IF v_mtart EQ 'ZERS' OR v_mtart EQ 'FHMI' OR v_mtart EQ 'UNBW'.
MESSAGE e000(zm_msg) WITH 'You are not allowed' 'to create PR for stock items'.
ENDIF.
ENDIF.
IF l_s_eban-knttp NE 'F' OR l_s_eban-pstyp NE '9'.
IF l_s_eban-knttp NE 'A'.
IF ( l_s_eban-pstyp NE '9' AND l_s_eban-pstyp NE 'D' ) AND l_s_eban-matnr EQ space.
MESSAGE e000(zm_msg) WITH 'You cannot create' 'a PR without material number'.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
reward points if useful
regards
Anji
05-03-2007 12:40 PM
Hi Anji,
Thanks for your prompt reply.
The BADI ME_REQ_POSTED is only called when I am posting the Purchase Requisition. Are there other BADIs where I can check Cost Center even before posting?
Thanks lots for your help.
Cheers,
Liyan