09-11-2007 11:05 AM
Hi Experts,
I need to check the Open order and closed order item in ME53N t-Code(PR) through Quantity and quantity order filed. Now the problem is Order Quantity value is exceeds than quantity.if Quantity value is equal to Order Quanity the order should be closed. If Quantity value is lesser than order quantity the order should be in open state.
Thanks
Rajesh
09-11-2007 1:11 PM
Not quite sure what you actually want to do here.
Do you want to "modify" an existing BADI or create a new one.
AFAIK there aren't any existing BADI's for ME53 so you'll have to create a new one --not too difficult so long as you follow the rules.
You will need some place also to call it from (a User / Screen exit / a user mod or whatever.)
Use code something like this.
&----
*& Report Z_BADI_TEST
*&
&----
*&
*&
&----
REPORT Z_BADI_TEST.
test call Badi from standard abap. (Only from rel 6.40 and above)
do the following
1) define the Badi (SE18). For Abap call test uncheck multiple use
and filter boxes
2) Implement the badi (SE19). Add any methods here in the implemntation
3) activate
*
4) define the standard class exithandler to the abap. This class is the "Badi caller
"
5) define an exit variable referring to your Badi Implementation interface
this interface will normally be something like ZIF_EX***************
You will see this in SE18/SE19.
*
6) Instantiate your instance of the badi (method call get_instance)
7) Now call any method(s) in the Badi.
*
class cl_exithandler definition load. "Declaration
data exit type ref to zif_ex__jimbotest. "Interface reference
data yes type c.
data: v_knvv type knvv. "Used in Fmod call in Badi methods
start-of-selection.
yes = ' '.
selection-screen begin of block b1.
parameters: r1 radiobutton group rad1,
r2 radiobutton group rad1,
r3 radiobutton group rad1.
selection-screen end of block b1.
parameters: p_kunnr type knvv-kunnr.
select single * into v_knvv
from knvv
where kunnr eq p_kunnr.
export v_knvv to memory id 'CUST6A'. "Save customer data for the function module
break-point 1.
call method cl_exithandler=>get_instance "Factory method call
exporting "Method
exit_name = 'Z_JIMBOTEST' "Name of your BADI
changing instance = exit.
if not exit is initial.
if r1 = 'X'.
call method exit->dispord "Add-In call
exporting kunnr = p_kunnr.
endif.
if r2 = 'X'.
call method exit->dispfakt.
endif.
if r3 = 'X'.
call method exit->dispmat.
endif.
endif.
Your badi will have different methods -- just check your quantities and if necessary close the order.
Ensure that when you call your Badi you have access to all the releveant data to close the order if required.
Cheers
Jimbo
09-11-2007 2:55 PM
ME53N is the new ECC6 transaction for purchase Requisition - and there is a BADI - ME_PROCESS_REQ_CUST
This gives access to most PR fields. However not sure if you can change anything in ME53N - this is a display transaction. ME51N create or ME52N change can use the BADI.
A lot of the parameters for methods of the BADI are themselves object references with their own associated methods for get / set / check data etc. so you may need to drill down to find what you want.
The sample code below for the PROCESS_ITEM method shows an example of this. The parameter IM_ITEM is an object reference with methods for manipulating it's data, even though it appears as an IMPORTING parameter on the method - data can still be changed by it.
DATA: l_preq TYPE mereq_item.
CALL METHOD IM_ITEM->get_data
RECEIVING
re_data = l_preq.
* Convert Requisitioner name to upper case
TRANSLATE l_preq-afnam TO UPPER CASE.
CALL METHOD IM_ITEM->set_data
EXPORTING
im_data = l_preq.
Andrew
09-11-2007 3:19 PM
Thanks Andrew -- It's always good to find the answers to this stuff.
Badi's are certainly the way SAP intend in the future for customers to add their own modifications.
However for the cases where no Badi currently exists you CAN still use the method I outlined above (from rel 6.40 onwards) provided you can find some convenient place to call it from.
If a Badi actually exists then it's far better to use it as you'll have the correct parameters for the relevant transaction and data can be displayed / updated via the standard transaction.
Cheers
Jimbo