Skip to Content
0
Jun 07, 2022 at 11:44 AM

Set LOEKZ in Purchase Request when released ME_PROCESS_REQ_CUST

72 Views

Hello guys,

I have the following problem. I want to set deletion flag in Purchase Request when it is released. Therefor I thought about ME_PROCESS_REQ_CUST badi in method 'POST'.


My code ist the following...

  CHECK sy-tcode EQ 'ME54N'.

CALL METHOD im_header->get_items
RECEIVING
re_items = lt_items.

LOOP AT lt_items INTO ls_items.
CALL METHOD ls_items-item->get_data
RECEIVING
re_data = ls_req_item.
CALL METHOD ls_items-item->get_datax
RECEIVING
re_datax = ls_req_itemx.
IF ls_req_item-frgrl IS INITIAL.
ls_req_item-loekz = abap_true.
ls_req_itemx-loekz = abap_true.
CALL METHOD ls_items-item->set_datax
EXPORTING
im_datax = ls_req_itemx.

CALL METHOD ls_items-item->set_data
EXPORTING
im_data = ls_req_item.
ENDIF.
ENDLOOP.

But with this code nothing happens. So I thought maybe 'POST' method does not allow any changes and tried the same in 'PROCESS_ITEM' method. But the same result, no changes. When I try to change another field, e.g. description of preq, it does not work in 'POST' but works in 'PROCESS_ITEM' method. Can anyone tell me where the problem is?

I also tried with

      CALL FUNCTION 'BAPI_REQUISITION_DELETE'
EXPORTING
number = ld_banfn
TABLES
requisition_items_to_delete = lt_del_item
return = lt_return.

which works in 'POST' method fine, but I'm not sure if its the right way because first its an older BAPI afaik and second is it right to use BAPI when user is in method of changing itself in GUI transaction? Sounds wrong for me.

Regards
Michael