Skip to Content
0
Dec 28, 2022 at 07:38 PM

Copy sales order ship to address to PR delivery address

135 Views

Hi,

My requirement is to copy the Sales order ship to address to the delivery address of the PR created automatically.

Steps involved:

1. Sales order is created in VA01 with a material with item category TAN and saved.

2. The created Sales order is again opened using VA02 and the status is set to committed along with the committed date and quantity. The sales order is saved. At this point the PR is automatically created (I check in MD04 for the material plant).

Problem:

The PR always gets created with the plant address as delivery address. I have tried updating the ADRNR, ADRN2 and KUNNR fields in the below user exit and BADI. Still there is no effect. it is always the plant address in the PR. I have also tried updating EBAN in exit USEREXIT_SAVE_DOCUMENT in MV45AFZZ but no effect.

USEREXIT_MOVE_FIELD_TO_ME_REQ in MV45AFZB

EBAN-ADRNR = <value>.

EBAN-ADRN2 = <value>.

EBAN-KUNNR = <value>.

Implemented BADI ME_PROCESS_REQ_CUST and put the below code in PROCESS_ITEM.

DATA: lt_item TYPE mereq_item.

DATA: ls_datax TYPE mereq_itemx.

CHECK im_count = 1 .

lt_item = im_item->get_data( ).

lt_item-adrnr = <value>.

lt_item-adrn2 = <value>.

lt_item-kunnr = <value>.

im_item->set_data( lt_item ) .

MOVE: 'X' TO ls_datax-adrnr.

MOVE: 'X' TO ls_datax-adrn2.

MOVE: 'X' TO ls_datax-kunnr.

im_item->set_datax( ls_datax ) .

Could someone please provide some pointers on what could be the reason for the PR delivery address to always be the plant address even though it is changed in the user exit/BADI? Is there anything missing in the code or should I use some other user exit?Thanks in advance.Rincy