Application Development 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: 

Implementing Badi ME_PROCESS_PO_CUST

Former Member
0 Kudos

Hi all,

I'm trying to implement the BADI ME_PROCESS_PO_CUST, the method PROCESS_ITEM, and I'm trying to change the field ls_positem-lebre, but it doesn't works. I've seen that this field is in the mepoitem_tech structure in the method set_data and it restores this value to his old value, anyone knows how to change this field?

..and another question...

In the same BADI, I'm trying to change the sale's area in the shipping data, but when I call the method set_shipping_data there is a firewall that only allows me to change the fields vstel, lprio, vsbed, route and ablad. Is there any way to change the other fields?

Thanks,

Xavi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use ls_mepoitem = im_item->get_data( ).

and chage your item date. Please read the documentation you can change only some set of data at item level.

Then use im_item->set_data( ).

I will send you the detailed code by tomorrow.

12 REPLIES 12

Former Member
0 Kudos

Hi,

The PROCESS_ITEM method has only IMPORTING parameter, meaning that you cannot change the values in the IM_ITEM parameter.

Hope this helps,

Bhanu

0 Kudos

But if u call the method im_item->set_data u can change the fields that are not in the mepo_tech structure (I've done this). My problem is that I'm trying to change a field that appears in this structure and I don't know how.

Regards,

Xavi

Former Member
0 Kudos

Use ls_mepoitem = im_item->get_data( ).

and chage your item date. Please read the documentation you can change only some set of data at item level.

Then use im_item->set_data( ).

I will send you the detailed code by tomorrow.

0 Kudos

Thanks, I'll waiting for it

Former Member
0 Kudos

hi ,

In ME_PROCESS_PO_CUST badi you can use another method FIELDSELECTION_ITEM_REFKEYS to change the value of an item level field( but this method will trigger many times). I think it will work.

another question of changing the sales area of shipping tab. i too got the same problem when changing delivery creation date. it is not possible to change the sales area through set_shipping_data.

0 Kudos

I've tried to modify the field in the FIELDSELECTION_ITEM_REFKEYS but the problem persists. The problem is that when I call the method im_item->set_data, there is a structure (l_mepotech type mepoitem_tech) that not allows to change any field compressed in this structure. In the structute definition says "Non-Directly-Changeable Fields" and I ask if there is another way (indirectly) to change a field of this structure

Former Member
0 Kudos

Hi,

By implementing the above badi you can change limited fields at item level.

I am using this to change the following and it is working fine for me.

a) Chaning field -- PLIFZ and RESWK and NETPR based on some header conditions

DATA : LS_MEPOITEM TYPE MEPOITEM.

DATA : ZZPLIFZ TYPE EKPO-PLIFZ.

*----


  • Get the Item data

*----


LS_MEPOITEM = IM_ITEM->GET_DATA( ).

LS_MEPOITEM-PLIFZ = ZZPLIFZ.

LS_MEPOITEM-NETPR = V_NETPR.

*----


  • Set the Item data

*----


CALL METHOD IM_ITEM->SET_DATA

EXPORTING

IM_DATA = LS_MEPOITEM.

Try this.

I hope this will help.

Message was edited by: Lanka Murthy

furlan
Participant
0 Kudos

Hi,

Try to change the field using field symbol assign

Field-symbols: <fs> type [type field].

ASSING('(prgname)tab-field') to <fs>.

where prgname, is the program name where you can find the fild (at screen) and tab-field is the field name.

<fs> = some value.

This is not the more elegant solution, but it can help you.

Regards!

Furlan

Former Member
0 Kudos

Hi Flávio,

first of all, thanks for your reply.

I've tried your solution with the following code in the PROCESS_ITEM method of the BADI:

FIELD-SYMBOLS: but it doesn't change.

Former Member

Hi Xavier,

SAP recommends that you should not attempt to change any field which is contained in MEPOITEM_TECH structure (see note 803749). So you should avoid that.

However if you have no choice and you want to change this field, may be the following code helps:

*declare an object of class cl_po_item_handle_mm

DATA: lr_item TYPE REF TO cl_po_item_handle_mm.

*assign the parameter IM_ITEM of BADI IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM to this *variable

lr_item ?= im_item.

lt_items = im_item->get_data( ).

-


*modify field lt_items-LEBRE

and then

lr_item->set_data( lt_items ).

This code should do the trick, because now we use method SET_DATA(which has no validation) of class CL_PO_ITEM_HANDLE_MM instead of method IF_PURCHASE_ORDER_ITEM_MM~SET_DATA.

However please check for any other data changes after implmenting this solution.

Kind Regards

Ravi

0 Kudos

Great, works perfectly!

0 Kudos

mz1919 this is a bad practice