‎2006 Jul 27 10:55 PM
Hello all,
I am trying to modify 'ROUTE' field in VBAP in the exit 'userexit_document_save'. It is modifying the xvbap table but when the sales order is created that value is overwritten somewhere. Please suggest.
Here is the code
DATA: ls_xvbpa LIKE xvbpa,
lf_aland LIKE tvst-aland,
lf_azone LIKE tvst-azone,
lf_lland LIKE trolz-lland,
lf_lzone LIKE trolz-lzone,
ls_vbadr LIKE vbadr,
ls_xvbap LIKE xvbap,
ls_tvst LIKE tvst,
lv_route LIKE trolz-route.
LOOP AT xvbap INTO ls_xvbap.
IF NOT ls_xvbap-vstel IS INITIAL.
SELECT SINGLE * FROM tvst
INTO ls_tvst
WHERE vstel EQ ls_xvbap-vstel.
IF sy-subrc = 0.
lf_aland = ls_tvst-aland.
lf_azone = ls_tvst-azone.
ENDIF.
ENDIF.
READ TABLE xvbpa INTO ls_xvbpa WITH KEY vbeln = ls_xvbap-vbeln
posnr = ls_xvbap-posnr
parvw = 'Q1'.
IF sy-subrc = 0.
CALL FUNCTION 'SD_ADDRESS_GET'
EXPORTING
fif_address_number = ls_xvbpa-adrnr
IMPORTING
fes_address = ls_vbadr
EXCEPTIONS
address_not_found = 1
address_type_not_exists = 2
no_person_number = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
lf_lland = ls_vbadr-land1.
lf_lzone = ls_vbadr-lzone.
ENDIF.
ENDIF.
CALL FUNCTION 'SD_ROUTE_DETERMINATION'
EXPORTING
i_aland = lf_aland
i_azone = lf_azone
i_lland = lf_lland
i_lzone = lf_lzone
IMPORTING
e_route = lv_route
EXCEPTIONS
no_route_found = 1
departure_error = 2
destination_error = 3
invalid_generic_key = 4
customer_exit_error = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
ls_xvbap-route = lv_route.
MODIFY xvbap FROM ls_xvbap TRANSPORTING route.
ENDIF.
ENDLOOP.
Thanks,
‎2006 Jul 27 11:03 PM
xvbap is the input to your routine. So try to change VBAP or check any different structure in scope.
Becos after you modity again the data will be resetted in the main program.
Regds
Manohar
‎2006 Jul 27 11:03 PM
xvbap is the input to your routine. So try to change VBAP or check any different structure in scope.
Becos after you modity again the data will be resetted in the main program.
Regds
Manohar
‎2006 Jul 27 11:13 PM
When you update the XVBAP internal table, you should set the update indicator. The field is XVBAP-UPDKZ. I think it's 'U' for update, 'D' for delete.
However, I think there is another userexit specifically used for route determination change. I'll check.
‎2006 Jul 27 11:22 PM
If you look in txn CMOD or SMOD, check enhancement 0VRF0001. It uses function module EXIT_SAPL0VRF_001. It is used to manipulate route determination for SD.
The function module if fully documented.
‎2006 Jul 27 11:48 PM
Manohar and Norman,
Thanks for all your replies.
Norman...I cant use the exit EXIT_SAPL0VRF_001 because my req. is to re-determine the route based on a partner addition. So after you add a partner to the item, this code will not execute.
And I tried with UPDKZ indicator with I and U. It didnt work. Any more ideas.
Manohar,
Can I modify vbap directly in that user exit. Direct update is not a good idea though.
Thanks,
‎2006 Jul 27 11:49 PM
‎2006 Jul 28 12:48 AM
Hello all,
I tried updating vbap directly...but it didnt work.
‎2006 Jul 28 12:50 AM
‎2006 Jul 28 1:11 AM
Is there a reason why you are using USEREXIT_SAVE_DOCUMENT instead of USEREXIT_SAVE_DOCUMENT_PREPARE?
Does the route get redetermined after USEREXIT_SAVE_DOCUMENT_PREPARE?
I ask because the original intent for USEREXIT_SAVE_DOCUMENT was to save data in OTHER tables. Usually the internal tables are manipulated in USEREXIT_SAVE_DOCUMENT_PREPARE.
‎2006 Jul 28 2:33 AM
‎2006 Jul 28 2:20 PM
Norman and Niranjan,
You are correct. I did the same and worked.
Thanks,