1

I am trying to modify the values of WEORA, BSTAE in ME21n tcode upon saving. I've written the code in ME_PROCESS_PO_CUST BADI, method CHECK:

DATA: lt_data TYPE PURCHASE_ORDER_ITEMS,
      lo_header TYPE REF TO CL_PO_HEADER_HANDLE_MM,
      lt_item TYPE REF TO IF_PURCHASE_ORDER_ITEM_MM,
      ls_get_item TYPE MEPOITEM,
      ls_set_item TYPE MEPOITEM,
      lv_firewall TYPE abap_bool.

  FIELD-SYMBOLS: <fs_data> TYPE PURCHASE_ORDER_ITEM.

  lt_data = im_header->get_items( ).

  READ TABLE lt_data ASSIGNING <fs_data> INDEX 1.
  IF <fs_data> IS ASSIGNED.
    lt_item = <fs_data>-item.
  ENDIF.

  ls_get_item = lt_item->get_data( ).

  ls_get_item-bstae = '0004'.
  ls_get_item-weora = abap_true.


  CALL METHOD lt_item->set_data
    EXPORTING
      im_data = ls_get_item.

I tried debugging, but inside the method set_data there is a condition:

CHECK l_parent->my_ibs_firewall_on  EQ mmpur_yes OR
      l_parent->my_cust_firewall_on EQ mmpur_yes.

The value of both is initial so it interrupts and doesn't go to the rest of the code. Forced setting them to true makes all the code execute but update of the fields doesn't work anyway.

It seems that this BADI doesn't work but I made my research and most people use this BADI to update EKPO fields in ME21n.

Is there any problem with my code?

Is there other exit I can use to update fields WEORA and BSTAE in transaction code ME21N upon saving?

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Yuri
  • 11
  • 2
  • 5
  • 1
    I don't think a `CHECK` method is used to change data. Try using the method `PROCESS_ITEM`, if you check the documentation it specifically says here that `The PROCESS_ITEM method enables you to change the item data and check it for correctness.` – andrecito Oct 19 '18 at 09:49
  • Hello @andrecito , I also tried transferring my code in the PROCESS_ITEM method but I got the endless loop error. I also tried the solutions I have searched regarding the error but none of them works properly. This solution was a close one http://saptechnical.com/Tutorials/ExitsBADIs/ME21N/Error.htm But after I input material, quantity, delivery date, plant and then press enter, The fields to be changed is updated but the values in material, quantity, delivery date and plant disappears. – Yuri Oct 19 '18 at 10:16
  • Use `PROCESS_ITEM` method instead – Suncatcher Oct 19 '18 at 11:06
  • @Suncatcher I already tried using PROCESS_ITEM method but it is also not working. I'm getting the error endless loop. – Yuri Oct 21 '18 at 04:52

2 Answers2

0

You have to call method SET_DATAX and then SET_DATA. SET_DATAX , you will mark X to field you want to update values.

Regards, Umar Abdullah

Umar Abdullah
  • 1,282
  • 1
  • 19
  • 37
  • there is no set_datax method in class IF_PURCHASE_ORDER_ITEM_MM. The field is being updated in the screen. But if I click the save button, the value is not reflecting in the table. – Yuri Nov 21 '18 at 01:49
0

You should use PROCESS_ITEM method from this BAdi, your code from this question perfectly works for me and updates these fields:

DATA: ls_mepoitem_set TYPE mepoitem.
FIELD-SYMBOLS: <fs_item> TYPE mepoitem.

DATA(ls_mepoitem) = im_item->get_data( ).

ls_mepoitem_set = ls_mepoitem.
ls_mepoitem_set-bstae = '0004'.
ls_mepoitem_set-weora = abap_true.
ASSIGN ls_mepoitem_set TO <fs_item>.
CALL METHOD im_item->set_data( EXPORTING im_data = <fs_item> ).
Suncatcher
  • 10,355
  • 10
  • 52
  • 90