Skip to Content
0
Former Member
Mar 29, 2010 at 07:07 AM

how to ChangePlantfor each item of Sales order using User Exit SAVE_DOCUMEN

45 Views

Hi All,

I have to change plant for Each line item of sales order using (MV45AFZZ) (USEREXIT_SAVE_DOCUMENT) based on first Schedule line.

if Confirmed Quantity is Less than Ordered Quantity.

based on first Schedule line.

it has to select other Plant and need to populate it in line item of sales order.Please see the below code and let me knoe if any changes required... Thanks in Advance.

data : wa_vbep like xvbep,

Lv_matnr type mara-matnr,

lv_werks type marc-werks.

DATA: it_vbap TYPE STANDARD TABLE OF vbap,

wa_vbap TYPE vbap.

field-symbols: <wa_vbap> type VBAPVB.

clear wa_vbap.

*loop at xvbap into wa_vbap.

loop at xvbap assigning <wa_vbap>.

read table xvbep into wa_vbep with key posnr = <wa_vbap>-posnr.

if wa_vbep-ETENR = '0001'.

if sy-subrc = 0.

IF wa_VBEP-BMENG LT wa_VBEP-WMENG.

SELECT SINGLE DWERK

INTO lv_werks

FROM MVKE WHERE matnr = <wa_VBAP>-matnr

and DWERK ne <wa_VBAP>-werks.

if not Lv_werks is initial.

if lv_werks EQ 1033.

move '1002' to <wa_vbap>-werks.

if sy-subrc eq 0.

xvbap-werks = <wa_vbap>-werks.

modify xvbap from <wa_vbap> .

endif.

elseif lv_werks EQ 1003.

move '1003' to <wa_vbap>-werks.

elseif lv_werks EQ 1010.

move '1010' to <wa_vbap>-werks.

endif.

endif.

endif.

endif.

endif.

endloop.

endif.

Regards,

Sudhakar Reddy.A