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: 

How to change delivery date when save the PO?

Former Member

Hello,

I need help.

I want to change delivery date when I save PO. I`m using BADI

ME_PROCESS_PO_CUST method CHECK but here the value of delivery date = EEIND isnt change. I tried PROCESS_SCHEDULE method, here it is posible but system doesn´t stop when you are save the PO.

Please, anyoen knows where can I do that??

thanks in advance

10 REPLIES 10

raymond_giuseppi
Active Contributor

Did you actually loop at the items and schedules in your implementation of the CHECK method to update schedule?

items = im_header->get_items( ).
LOOP AT items ASSIGNING <item>.
  schedules = <item>-item->get_schedules( ).
  LOOP AT schedules ASSIGNING <schedule>.
    <schedule>-schedule->get_data( ).
    " only use set_data if you actually change a value (no infinite loop)
    <schedule>-schedule->set_data( ).
  ENDLOOP.
ENDLOOP.

0 Kudos

Hi

Sorry to re-activate old thread, but I have exactly same question.

I have first tried ME_PROCESS_PO_CUST method PROCESS_SCHEDULE and this works in many scenarios, but not if a PO is changed with BAPI_PO_CHANGE (called from idoc). All the methods of ME_PROCESS_PO_CUST are called when a PO is changed with BAPI_PO_CHANGE - except the method PROCESS_SCHEDULE 😞

So I tried to move the code to the CHECK method. The method is called, but the change of delivery date is ignored because of 2 flags in the <schedule>-schedule->set_data( ) method - it is something about a state flag and a parent->my_cust_firewall_on. It seems it is not possible to update data in the check method.

Best regards

Thomas

0 Kudos

When changing with the BAPI, did you try to use the POSCHEDULE[X] parameters.
(Eventually, use an enhhancement of the IDoc inbound process to provide those fields)

0 Kudos

Hi Raymond

Thanks for your reply.

The Bapi call is working fine. POs are created with BAPI_PO_CREATE1 and changed with BAPI_PO_CHANGE. The BAPI's are called from IDOC and this is more or less a SAP standard setup.

The delivery date from idoc is updated in the PO, but I have a requirement to make a more complex calculation of the delivery date based on the input delivery date and some data in info records.

I made this more complex calculation in BAdI ME_PROCESS_PO_CUST method PROCESS_SCHEDULE and this solution works when the order is created with ME21N and BAPI_PO_CREATE1 (idoc). I also works if a PO is changes with ME22N, but the BAdI method PROCESS_SCHEDULE is not called when the order is changed with BAPI_PO_CHANGE (idoc).

I think this is an error in SAP standard setup and of course the best solution would be to find out why this method is not called in the BAPI_PO_CHANGE scenario. I debugged several times, but it is very complicated and I did not find an explanation.

So I tried a workaround to move my coding to the CHECK method. This works without errors, the method is called, but the changed delivery date is ignored.

Next I will try to move the coding to the PROCESS_ITEM method.

I can now confirm that it is possible to update the schedule line delivery date in method PROCESS_ITEM with code like this:

....

  schedules = <item>-item->get_schedules( ). 
LOOP AT schedules ASSIGNING <schedule>.
<schedule>-schedule->get_data( ).
.... some code to change the delivery date here ....
<schedule>-schedule->set_data( ).
ENDLOOP.

0 Kudos

so it's good news

0 Kudos

Hi Raymond,

I am getting below error . Can you please help. PO item delivery date should update based on some business logic during creation or change a PO.

I have used the same code in the PROCESS_ITEM method.

items = im_header->get_items( ).
LOOP AT items ASSIGNING <item>.
  schedules = <item>-item->get_schedules( ).
  LOOP AT schedules ASSIGNING <schedule>.
    <schedule>-schedule->get_data( ).
    " Updating both EINDT and EEIND field for schedule line
    <schedule>-schedule->set_data( ).
  ENDLOOP.
ENDLOOP.

Error: Data from Business Add-In ME_PROCESS_PO_CUST not adopted

0 Kudos

Inhsure that you don't use unnecessary SET_DATA (as already written) and that the current status of the PO allows the change of this data (check with ME252N)

Check also this KBA: 2157373 - Hints for error MEPO151 in BADI ME_PROCESS_PO_CUST

(Basically fields of structures MEPOITEM_TECH and/or MEPOSCHEDULE_TECH shouldn't be changed, also multiple identical changes will raise the same error)

0 Kudos

Updating the delivery date(field - EINDT) based on some custom logic.

In order to reflect the change, we have to call set_data(). But according to you, it is unnecessary. Then how one can change the value without calling this method. Both the structure does not have field EINDT.

we have to update delivery date in PO item for the below scenario:

  • During creation of a PO
  • During final release of a PO

It would be good if I can get sample code for this.

0 Kudos

I didn't write 'we have to call set_data(). But according to you, it is unnecessary' but 'only call the method once' (when required), prevent multiple call, then perform testing again.