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: 
Read only

MB1A User Exit at document save

former_member360630
Discoverer
0 Likes
1,182

Hi everyone,

I have a requirement related to MB1A for materials distribution to personnel defined in HR. This can happen at line <Enter> press or at 'Document Save' time (either one is good, but could not get any to work). The requirements are:

- get all material quantities in all the lines of the document

- match the materials against a custom price table and get the total amount of the document

- compair the total amount with some value related to the person HR that receives the materials

- send a message to the user if the total amount is greater than the value

For this I tried MBCF0002 but here only get access to the current line item, not to all of them so I cannot get the total amount, only the line amount. I am aware about some other user exits but in none of them I could get a hold of all line items in the document before the document would be saved.

Do you know if there is a user exit where as parameters there are available all line items, or where can I find them, if I use MBCF0002?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
884

Check the methods "MB_DOCUMENT_BEFORE_UPDATE" & "MB_DOCUMENT_UPDATE" in badi implementation of "MB_DOCUMENT_BADI".

Regards

Vinod

Hi everyone,

I have a requirement related to MB1A for materials distribution to personnel defined in HR. This can happen at line <Enter> press or at 'Document Save' time (either one is good, but could not get any to work). The requirements are:

- get all material quantities in all the lines of the document

- match the materials against a custom price table and get the total amount of the document

- compair the total amount with some value related to the person HR that receives the materials

- send a message to the user if the total amount is greater than the value

For this I tried MBCF0002 but here only get access to the current line item, not to all of them so I cannot get the total amount, only the line amount. I am aware about some other user exits but in none of them I could get a hold of all line items in the document before the document would be saved.

Do you know if there is a user exit where as parameters there are available all line items, or where can I find them, if I use MBCF0002?

4 REPLIES 4
Read only

Former Member
0 Likes
885

Check the methods "MB_DOCUMENT_BEFORE_UPDATE" & "MB_DOCUMENT_UPDATE" in badi implementation of "MB_DOCUMENT_BADI".

Regards

Vinod

Read only

former_member360630
Discoverer
0 Likes
884

Used MB_DOCUMENT_BADI but get an error using the described business logic.

The implementation text for MB_DOCUMENT_BEFORE_UPDATE method is:

______________

(... some select from ztable and call for HR infotype, no insert or update...)

MESSAGE 'display text here' TYPE 'W'.

______________

The problem is that user will see the message then try to modify the document lines. When trying this, he gets an ABAP error, message class M7, message number 372.

Checked the code in include MM07B9_BUCHEN_AUFBEREITEN in SAPMM07M program and found that this 'before_update' method is not supposed to be called more than once for some reason. In this case my business flow is broken (the request is to show the warning and then allow some modifications to the document, then check again).

Do you know of another user exit/badi that can help? For the workflow to function as requested, such a function should allow access to all document lines (not just a current line of the document line).

Read only

0 Likes
884

Check these notes: 446057 and 1315985. MB_DOCUMENT_BEFORE_UPDATE can issue only messages which type is X or A.

--

Reddy

Read only

0 Likes
884

Thank you kindly for your post, unfortunately I could see that only A and X messages are allowed in that BADI, the request is specific to display only a warning message (so MB_DOCUMENT_BEFORE_UPDATE is not useful - this is why I reopened this thread).

The question is what to use instead, so I get access to all document lines and be able to show the warning message (like in the business flow described at the top of this thread).