Skip to Content
author's profile photo Former Member
Former Member


Hello Friends.

As soon as a new data record is commited to table MSEG and MKPF, i.e. a goods receipt for purchase order is posted in the table. I need to send an automatic mail having the data of the newly added rows of MSEG.

Please tell me where I can write the code for this.

Is there any automatic event triggered after the MSEG is updated.

Currently I have written my code in the user exit.(CALL CUSTOMER-FUNCTION '001'). But if the user presses exit, without saving the document than the goods receipt mail will be already sent for that PO, where as that data is not updated in the MSEG.

Please help

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 05:36 AM


    you can use the function module <b>MB_CREATE_GOODS_MOVEMENT</b>.below is the documentation for that function module.



    The function module provides a general interface for posting goods movements.

    Movements performed in the framework of subcontracting (e.g. goods receipt for vendor with reference to subcontract order item or subsequent adjustment of "material to be provided" items) are currently not supported.

    In addition, it is assumed that in a goods movement with reference to a reservation, the reservation has already been read. The data of the reservation is to be made available through IMSEG. As of Release 3.0D, it is also possible to only submit the reservation number and item. In this case, the field XRERE of structure IMSEG must be filled with 'X'. If a reversal with reference to a reservation is to be posted - and the XRERE indicator set -, the XSTOB field in the IMSEG structure must be filled with X. In this case, no value is submitted in the IMSEG-BWART field.

    As of Release 3.0D, it is possible to have the system suggest the quantity to be posted. This has been implemented for movements with reference to reservations, production orders, and purchase orders. Enter an 'X' in the field IMSEG-XMEVO. The field IMSEG-ERFMG must remain blank.

    The system uses either the SY-TCODE or the transaction code that has explicitly been provided in the import parameter CTCOD. You have to make sure that an entry for the transaction is contained in table T158. In addition, you have to maintain the transaction/valid movement type combination in table T158B.

    There is no dialog. That is, error handling has to be ensured by the caller. The function module has been designed so that new items can only be added at the end. They cannot be inserted at any other point, because then the correct allocation between IMSEG and EMSEG will be lost (via SY-TABIX). The error messages are returned to the caller via the structure EMKPF or EMSEG. The COMMIT occurs at the caller.

    The parameter XALLP controls that the material document can only be generated after all items have been posted. Parameter XALLR controls whether in the case of repeated calls all tables are to be initialized or only the new/corrected items are to be processed. If in the calling program, new items are inserted between existing items, this parameter must be set.

    There is also the following option: Items that caused an error in the first call can be omitted when repeating the call. For this purpose, the field XNIBU in table IMSEG must be set.

    The structure EMKPF and tables IMSEG and EMSEG are returned. The field IMSEG-BEAKZ indicates when processing of an item was successful. In the field EMSEG-YZEIL, the preliminary line number is contained in the material document. If the document is posted, the line number is contained in field EMSEG-MBLPO of the material document. The field EMKPF-SUBRC indicates where the program found the error.

    EMKPF-SUBRC Ereror


    16 Initialization incorrect

    15 Header data incorrect

    11 Error when reading material master records per PREFETCH

    10 Error when reading material short texts per PREFETCH

    08 Allocation of IMSEG to EMSEG incorrect

    07 Error when correcting an item

    06 Error when creating an item

    05 No item generated

    04 It is only permitted to post all items; however, there

    is at least one incorrect item

    03 Error when posting the document

    02 Allocation of IMSEG to EMSEG incorrect

    01 Allocation of YMBUZ to XMSEG incorrect

    Please note that in EMKPF, the message ID, message number, etc. need not necessarily be set. It can also be the case that the system only indicates that an error has occurred. However, the relevant error message can be found in table EMSEG (with reference to the relevant line). For the following EMKPF-SUBRC's, the error messages are contained in table EMSEG: 07, 06, 05, 04.


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2007 at 10:43 AM

    No User EXIT, No BADI, No EVENT.

    Finally scheduled a batch job at a fixed interval of time to send email on goods receipt.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.