11-28-2007 5:57 AM
hi Friends,
I am Using ME_PROCESS_PO_CUST badi for validation in Purchase order (ME21N),
For that I implemented PROCESS_ITEM method which fires during each row now i want to add another validation in same implementation for that i need previous row's value so how to get that value ?
following is my current validation code.
method IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM.
DATA:ls_poitem TYPE mepoitem.
DATA:ls_poheader TYPE MEPOHEADER.
DATA:lm_poheader TYPE ref to IF_PURCHASE_ORDER_MM.
DATA:w_mara TYPE mara.
DATA:IT_ZMMTBL039 TYPE STANDARD TABLE OF ZMMTBL039 ,
WA_ZMMTBL039 TYPE ZMMTBL039 .
DATA:ls_poitem1 TYPE mepoitem.
DATA:V_KUNNR1 TYPE KNA1-KUNNR.
DATA:V_KUNNR2 TYPE KNA1-KUNNR.
ls_poitem = im_item->get_data( ).
lm_poheader = im_item->GET_HEADER( ).
ls_poheader = lm_poheader->GET_DATA( ).
CLEAR: WA_ZMMTBL039,w_mara.
REFRESH:IT_ZMMTBL039[] .
SELECT *
INTO TABLE IT_ZMMTBL039
FROM ZMMTBL039
WHERE bsart EQ ls_poheader-bsart.
IF sy-subrc EQ 0.
CLEAR: WA_ZMMTBL039,w_mara.
SELECT SINGLE *
INTO w_mara
FROM mara
WHERE matnr EQ ls_poitem-MATNR.
IF SY-SUBRC EQ 0.
READ TABLE IT_ZMMTBL039 INTO WA_ZMMTBL039 WITH KEY bsart = ls_poheader-bsart
mtart = w_mara-mtart
spart = w_mara-spart.
IF SY-SUBRC NE 0.
MESSAGE E009(zparts) WITH ls_poitem-MATNR w_mara-spart ls_poheader-bsart .
ENDIF.
ENDIF.
ENDIF.
endmethod.
12-03-2007 5:49 AM
Hi Swarup,
One solution could be that you export the line item to ABAP memory.
Later you can read it and update it with the current line item.
Regards
Megha
11-28-2007 7:47 PM
One possibility would be to define a global attribute for the class implementing your BAdI. This would be an internal table of type TAB_MEPOITEM that contains your item data. As you process each item, you can add the current one to this internal table if it's not yet there so you'll have the previous item available.
Or as another alternative, you can try to use function module MEPO_DOC_ITEM_GET with the previous item's number... it should work.
12-02-2007 6:25 AM
If you are not doing any changes to the data during your validation you can use CHECK method from the same BADI. Here you will have all the line items listed.
12-03-2007 5:49 AM
Hi Swarup,
One solution could be that you export the line item to ABAP memory.
Later you can read it and update it with the current line item.
Regards
Megha
12-03-2007 6:03 AM
hi Megha,
Thats what i am looking for, Thanks
Can you please give me syntax . as i m doing it for ME21n .
i want to check plant.
12-03-2007 7:13 AM
import F1 F2 from memory id 'MEM01'.
if sy-subrc eq 0.
{
}
*at the end export current line-
export F1 F2 to memory id 'MEM01'
note-
f1,f2 are fields u want to store in memory
use <b>'free memory id 'MEM01'</b> to free memory space. at last
reward points if useful
Regards
Megha
12-05-2007 8:45 AM
12-05-2007 8:12 PM
otherwise u can define a field of type static in attribute tab.
it holds the value statically.