Application Development and Automation 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: 

USEREXIT_SAVE_DOCUMENT_PREPARE : For Validating Purchase Order

former_member321825
Active Participant
0 Kudos
1,908

In VA01,  If the purchase order and purchase order item is blank then error message will be displayed for the user to input these values .

I have writtwen below code in MV45AFZZ,   USEREXIT_SAVE_DOCUMENT_PREPARE. The problem is that when purchase order or purchase order item is not entered, the field is greyed out . Please suggest

   If VBAK-BSTNK is initial.
  message e000(ZMSG).        " Enter Purchase Order
ELSE.
   Read table xvbap with key POSEX = ' '.
* If VBAP-POSEX is initial.
   IF sy-subrc = 0 .

       SHIFT xvbap-POSNR  LEFT DELETING LEADING '0'.
  message e001(ZMSG) with  xvbap-POSNR .                                  " In Order data Tab, Enter Purchase order item
ENDIF.

ENDIF.

9 REPLIES 9

Former Member
0 Kudos
497

Hi

Try to add check condition in

MV45AFZB -  userexit_check_vbak /  userexit_check_vbap

Regards,

Pranav

0 Kudos
497


When I add my Code in userexit_check_vbap, the error message displays in initial screen .

Say , If i added line item with its details in intial screen , the error message for Purchase order Item displays in intial screen hence we cannot naviagate to item screen ---> order tab--Purchase order item field

Lakshmipathi
SAP Champion
SAP Champion
0 Kudos
497

Why User Exit ?  I am not sure, whether you have discussed with your Functional Consultant since this can be achieved with standard Incompletion Log itself.

Go to OVA2, select Sales Header > Procedures > Sale Order and maintain the following entries there.

VBKD:::::POSNR::::KBES:::01:::X

G. Lakshmipathi

0 Kudos
497

Thanks you for your reply .

I would like to know whether  warning message or error message will be displayed through OVA2.

Currently for Purchase Order below enteries are entered but it displays warning message & user is able to proceed with this message

VBKD:: BSTKD:: PO number::: KBES ::01::X

For Purchase Order Item

VBAP POSEX Purchase order item KBES 01

0 Kudos
497
I would like to know whether  warning message or error message will be displayed

It would be better if you set the incompletion log whatever I suggested, test it and update here whether users are able to proceed.  For information, system will not allow you to save the sale order. 

G. Lakshmipathi

Former Member
0 Kudos
497

Hi Rachel,

MV45AFZZ,   USEREXIT_SAVE_DOCUMENT_PREPARE will do the job for you.Try the following code snippet.



MESSAGE <Write your custom message> here. //Ensure you are using 'S' Message type rather than "E"

PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).

FCODE = 'ENT1'.

SET SCREEN SYST-DYNNR.

LEAVE SCREEN.

Hope it helps.

Regards,

Kannan

0 Kudos
497

Dear Kannan

May i know why are you recommending for development-when it can be done with standard??

Interested to know in what scenarios-we can differ the same process..

Phanikumar

former_member321825
Active Participant
0 Kudos
497


I have tried the incompletion log as suggested by G. Lakshmipathi & also tried Kanan's solution .


Since I wanted error message for specific customer I tried below code suggested by Kanan . It is working perfectly fine.

MESSAGE <Write your custom message> here. //Ensure you are using 'S' Message type rather than "E"

PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).

FCODE = 'ENT1'.

SET SCREEN SYST-DYNNR.

LEAVE SCREEN.

- Also, could you help me how can we position the cursor on "Purchase order item" field so that user will know that PO item has to be entered


-I am also curious to know how error message can be displayed through incompletion log  since I was getting warning message and was able to proceed further but while saving, the document shows in incomplete status.


0 Kudos
497

"""I am also curious to know how error message can be displayed through incompletion log  since I was getting warning message and was able to proceed further but while saving, the document shows in incomplete status""

You can check based on the Flag-Incomplete messages in VOV8

(If it is deactive-then you will get the option about incompletion).

Also to change the Message status from W to E--Try with OVAH (else at se91 at coding level)

Note:Incompletion procedure will not work based on customer--if business wants based on customer--then you need to go with exits.

Very Imp Note: Incompletion log will always check whether some value to be maintained in the respective field--but it does not validate(other than f4 options for some fields)

Phanikumar