11-07-2017 5:46 AM
I have a requirement in my project..For the tcode = VA01 or VA02, for sales org = 'mxco',distribution channel = 20, division = tv,order type = zsf2 and order reason = zar,
as I click on the save button, I have to check that order field (aufnr) in account assignment tab at item level is blank or not, if it is blank then I have to display the error. I am new to user exits and I am not able to find the correct userexit where I can write my code. Any help will be appreciated.
11-07-2017 6:57 AM
On top of what Raymond said, you really need to get back to your functional consultant for clarifications to understand what is the idea behind, because AUFNR is on header and on item level.
From the details that you provided I would say that the solution design is rather poor and it would not work well in real life situations.
Seriously, validation for AUFNR on order type+sales area+order reason is not very intuitive and once the users figure out that the easiest way to get rid of the the error is by changing the order reason you can imagine what will be the end result. Raising an error in the exit that Raymond suggested may be right from technical perspective, but it is not immensely helpful to business users, who would be more willing to comply with rules if they were presented with a screen where they can correct their mistake - like standard document incompletion is designed. #justmy2cents
11-07-2017 6:29 AM
During your search didn't you find the good old SD user-exit (USEREXIT_SAVE_DOCUMENT_PREPARE) there are already so many threads on this kind of question?
11-07-2017 8:00 AM
Hi Raymond,
I tried putting my code in the above mentioned userexit but my code didn't run successfully.
Below is my code which i have written inside an include and have called this inlcude in the userexit_save_document_prepare.
DATA: wa_vbap1 TYPE vbap.
if sy-tcode = 'VA01' or sy-tcode = 'VA02'.
IF vbak-vkorg = 'MXCO' AND vbak-vtweg = '20' AND vbak-spart = 'TV'
AND vbak-auart = 'ZSF2' AND vbak-augru = 'ZAR' .
READ TABLE xvbap INTO wa_vbap1 INDEX 1.
IF wa_vbap1-aufnr IS INITIAL.
MESSAGE s000(zsd) WITH 'ORDER field cannot be blank' DISPLAY LIKE 'E'.
ENDIF.
endif.
ENDIF.
Please let me know if i am writing anything wrong.
11-07-2017 8:19 AM
Use an actual error message type 'E', your current code wont stop the save. Put your customer form(s) in include MV45AFZZ to get acess to main program data. Don't hesitate to debug. Also provide more information to user in the error message like item number xvbap-posnr and a 'why' the field is mandatory.
11-07-2017 8:46 AM
11-07-2017 6:57 AM
On top of what Raymond said, you really need to get back to your functional consultant for clarifications to understand what is the idea behind, because AUFNR is on header and on item level.
From the details that you provided I would say that the solution design is rather poor and it would not work well in real life situations.
Seriously, validation for AUFNR on order type+sales area+order reason is not very intuitive and once the users figure out that the easiest way to get rid of the the error is by changing the order reason you can imagine what will be the end result. Raising an error in the exit that Raymond suggested may be right from technical perspective, but it is not immensely helpful to business users, who would be more willing to comply with rules if they were presented with a screen where they can correct their mistake - like standard document incompletion is designed. #justmy2cents