Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ME_PROCESS_PO_CUST

Former Member
0 Likes
2,289

Hi friends

first time i am using BADIs

i want pass po item material number as ' 100-100' thorugh BADI, tcode ME21n and i tried as given below but getting infinite loop.

METHOD if_ex_me_process_po_cust~process_item.

DATA:ls_poheader TYPE mepoheader,

lm_poheader TYPE REF TO if_purchase_order_mm,

wa_item TYPE mepoitem,

lm_poheader = im_item->get_header( ).

ls_poheader = lm_poheader->get_data( ).

CALL METHOD im_item->get_data

RECEIVING

re_data = wa_item.

IF ls_poheader-bsart = 'UB' .

wa_item.matnr = '100-100'.

CALL METHOD im_item->set_data

EXPORTING

im_data = WA_ITEM.

endif.

please help me why my code is going to infinite loop.

Thanks

Ramesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,476

Hi,

I am not able to figure out why its getting into infinite loop.

Try changing your code

 wa_item.matnr = '100-100' 

to

 wa_item-matnr = '100-100' 

.

Try the below code.



DATA:ls_poheader TYPE mepoheader,
lm_poheader TYPE REF TO if_purchase_order_mm,
wa_item TYPE mepoitem.

lm_poheader = im_item->get_header( ).
ls_poheader = lm_poheader->get_data( ).

wa_item = im_item->get_data( ).

IF ls_poheader-bsart = 'UB' .
  wa_item-matnr = '100-100'.

  CALL METHOD im_item->set_data
    EXPORTING
      im_data = WA_ITEM.
endif.

Hope this works. Reward points if helpful.

Thanks,

Balaji

Hi friends

first time i am using BADIs

i want pass po item material number as ' 100-100' thorugh BADI, tcode ME21n and i tried as given below but getting infinite loop.

METHOD if_ex_me_process_po_cust~process_item.

DATA:ls_poheader TYPE mepoheader,

lm_poheader TYPE REF TO if_purchase_order_mm,

wa_item TYPE mepoitem,

lm_poheader = im_item->get_header( ).

ls_poheader = lm_poheader->get_data( ).

CALL METHOD im_item->get_data

RECEIVING

re_data = wa_item.

IF ls_poheader-bsart = 'UB' .

wa_item.matnr = '100-100'.

CALL METHOD im_item->set_data

EXPORTING

im_data = WA_ITEM.

endif.

please help me why my code is going to infinite loop.

Thanks

Ramesh

5 REPLIES 5
Read only

Former Member
0 Likes
1,476

Hi,

I dont see any reason from the code why it should loop.

It is possibly caused by format of MATNR field - internal versus external - as material number uses conversion exit (MATN1 I think).

instead of

wa_item.matnr = '100-100'.

try a call to function 'CONVERSION_EXIT_MATN1_INPUT' (check this is correct one by looking at the data element / domain for MATNR).

Andrew

Read only

0 Likes
1,476

Hi Andrew,

thanks for your reply, i tried to use Conversion exit, still the code is going to infinite loop.

please help.

Thanks

Ramesh

Read only

0 Likes
1,476

Hi

write like this and try

wa_item-matnr = '100-100'.

regards

Shiva

Read only

Former Member
0 Likes
1,477

Hi,

I am not able to figure out why its getting into infinite loop.

Try changing your code

 wa_item.matnr = '100-100' 

to

 wa_item-matnr = '100-100' 

.

Try the below code.



DATA:ls_poheader TYPE mepoheader,
lm_poheader TYPE REF TO if_purchase_order_mm,
wa_item TYPE mepoitem.

lm_poheader = im_item->get_header( ).
ls_poheader = lm_poheader->get_data( ).

wa_item = im_item->get_data( ).

IF ls_poheader-bsart = 'UB' .
  wa_item-matnr = '100-100'.

  CALL METHOD im_item->set_data
    EXPORTING
      im_data = WA_ITEM.
endif.

Hope this works. Reward points if helpful.

Thanks,

Balaji

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,476

Hello Ramesh

Using the following implementation of BAdI ME_PROCESS_PO_CUST I have been able to change the material number in the item detail section of the purchase order. However, in the table control showing the item overview the material number is not exchanged.


METHOD if_ex_me_process_po_cust~process_item.
* define local data
  DATA:
    lo_item     TYPE REF TO cl_po_item_handle_mm,
    ls_item     TYPE mepoitem,
    ls_itemx    TYPE mepoitemx,
    ls_header   TYPE mepoheader.


  INCLUDE mm_messages_mac. "useful macros for message handling


  ls_header = me->mo_header->get_data( ).
  ls_item = im_item->get_data( ).

  CHECK ( ls_header-bsart = 'NB' ).
  CHECK ( ls_item-matnr NE '80-110C' ).

  ls_item-matnr = '80-110C'.  " another type of bulbs

  " Casting to implementing class CL_PO_ITEM_HANDLE_MM
  " Why? Method SET_DATAX is not accessible via interface.
  lo_item ?= im_item.

  CALL METHOD lo_item->set_data
    EXPORTING
      im_data = ls_item.


  clear: ls_itemx.  " update structure
  ls_itemx-ebelp_key = ls_item-ebelp.
  ls_itemx-matnr = 'X'.  " update material number

  CALL METHOD lo_item->set_datax
    EXPORTING
      im_data = ls_itemx.

ENDMETHOD.

Regards

Uwe