Sie sind auf Seite 1von 11

MB_CREATE_GOODS_MOVEMENT

Documentation: Version 1.0, 14.03.2000

General........................................................................................................................................... 2 How to use MB_CREATE_GOODS_MOVEMENT.........................................................................3 Import......................................................................................................................................... 3 Export......................................................................................................................................... 6 Example...................................................................................................................................... 8 Customer message..................................................................................................................... 9 Program........................................................................................................................................ 11

General
MM-IM provides a few transactions to post a goods movement (MB01, MB1C, MB1A, MBST, ). These transactions use forms and functions in the main MM-IM programs SAPMM07M, SAPFM07M and SAPLMBGB to create a material and accounting document. Furthermore these forms are responsible for all the other updates: consumption value, reservation, PO, PO history, production order, QM, serial numbers, Not all logistic processes are supported in MM-IM transactions. A lot of transactions post goods movements in the background, during their logistic process. These transactions dont use the MM-IM forms/functions directly. This would be too complicated and would cause a lot of customer messages. All applications have to use a standard interface. Right now (13.03.2000) 60 SAP-StandardPrograms are able to post a goods movement in the background. They all have to use the same interface: Function MB_CREATE_GOODS_MOVEMENT The function uses almost the same forms/functions, we use in the MM-IM-Transactions. The advantage for the calling application is, they dont have to know all our programs/forms/functions. They only have to know this one function. Transactions, which use MB_CREATE_GOODS_MOVEMENT: - VL02: Change outbound delivery - VL07: Goods receipt for delivery - VL09: Reverse goods movement for delivery - VL32: Change inbound delivery - COGI: Automatic goods receipt: Error handling - CO11: Create production order confirmation - CO13: Cancel production order confirmation - CO27: Picking List - MF41: Document-Specific Backflush Reversal - MF50: Planning table - QA02: Change inspection lot - QA07: Deadline monitoring of batches - MSC2: Change Batch (unresctricted <-> restricted) - MIGO: Goods receipt and goods issue Even some IDOCs and BAPIs use this function: - IDOC: WMMBXY MBGMCR - Bapi: CreateFromData (function BAPI_GOODSMVT_CREATE)

How to use MB_CREATE_GOODS_MOVEMENT


MB_CREATE_GOODS_MOVEMENT is a function (use SE37 to display function) with Importand Export-Parameters.

Import
To post a goods movement with function MB_CREATE_GOODS_MOVEMENT the calling report has provide this data: Structures: IMKPF Input data for material document header Tables: IMSEG Input data of material document items Fields: XALLP Only post if all items are o.k. XALLB Refresh data in MM-PUR XALLR Reset all data (same as initial call) CTCOD Externally provided transaction code XQMCL Call up from QM OLD_SUBRC SUBRC of preceding call IPKCOM Communication structure Kanban X_AUTHORITY No authorization check in SAPMM07M XLISU Call up order statistics XQMSR set serialnumbers in QM (in bold letters: obligatory data) Description of important fields: - XALLP: The parameter XALLP controls that the material document can only be generated after all items have been posted. - XALLB: Parameter XALLB controls wether the purchase order data should be initialized or not. - XALLR: 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. Example: (Release 3.1I) a) XALLR = X:
call function MB_CREATE_GOODS_MOVEMENT call function MB_CREATE_GOODS_MOVEMENT importing xallr = 'X' commit work. (with 2 lines in table IMSEG) (with 3 lines in table IMSEG)

Result: Material document with 3 items b) XALLR = :


call function MB_CREATE_GOODS_MOVEMENT call function MB_CREATE_GOODS_MOVEMENT importing xallr = (with 2 lines in table IMSEG) (with 3 lines in table IMSEG)

commit work.

Result: Material document with 5 items - CTCOD: 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. You will find the important information about the goods movement in IMKPF (header) and IMSEG (items). Here is an examples how to fill IMKPF and IMSEG to post a goods receipt for purchase order The following fields have to be filled: IMKPF-BLDAT Document date in document IMKPF-BUDAT Posting date in the document IMSEG-EBELN Purchase order IMSEG-EBELP Purchase order item IMSEG-BWART Movement type IMSEG-KZBEW = B Movement indicator IMSEG-ERFMG Quantity in unit of entry IMSEG-ERFME Unit of entry The following fields may have to be filled in some cases (incomplete listing): IMSEG-MHDAT Shelf life expiration date (if it has been configured like this in the system) IMSEG-GRUND Reason for movement (if it has been configured like this in the system) IMSEG-CHARG Batch (if the material is handled in batches and batch numbers are not assigned automatically) IMSEG-LGORT Storage location (if a storage location has not been specified in the purchase order item) The following fields can be filled (incomplete listing): IMSEG-INSMK Stock type IMSEG-SGTXT Item text IMSEG-ABLAD Unloading point IMSEG-ELIKZ delivery completed indicator You cannot fill the following fields (incomplete listing): Account assignment fields (account assignment is adopted from the purchase order) IMSEG-RESNUM Reservation IMSEG-RSPOS Receiving/issuing material IMSEG-UMWRK Receiving/issuing plant IMSEG-UMLGO Receiving/issuing storage location In the case of a purchase order item with the "subcontracting" item category, only the GR item in the interface is to be transferred. The system automatically determines GI items. All in all its not complicated to post a goods movement in the background, if MB_CREATE_ GOODS_MOVEMENT gets all data it needs. You can find more examples when you use transaction BAPI (release >4.5): transaction BAPI Materials Management Inventory Management

Goods Movement CreateFromData Choose Tabstrip Documentation You will find examples for - Goods receipt for purchase order - Goods receipt for production order - Goods issue - Transfer - Other goods receipts - Reversal of goods movements Its the documentation for the BAPI CreateFromData, but you can use this documentation, because the only thing the BAPI does is: 1 Use english fieldnames and translate them to our german fieldnames 2 Call MB_CREATE_GOODS_MOVEMENT 3 Translate the german result into english. The functionality is almost the same (instead of serial number handling)

Export
The function will return with this information: Structures: EMKPF Output data for material document header Fields: E_LVS_TAFKZ WM: transport order update Tables: EMSEG Output data of material document items (in bold letters: obligatory data) In EMKPF (header) and EMSEG (items) you will find these fields: MSGID Message identification MSGNO System message number MSGTY Message type MSGV1 Message variable 01 MSGV2 Message variable 02 MSGV3 Message variable 03 MSGV4 Message variable 04 If there is an error message depending the whole document, you will find the message in EMKPF. If there is an error message for an item, you will find the message in EMSEG. Attention: - MB_CREATE_GOODS_MOVEMENT ignores warning messages. - Only one error message per item (the first E-message) - The field EMKPF-SUBRC indicates where the program found the error: EMKPF-SUBRC Error 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 4 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. Dont forget: If there is an error message in a function, the program stops at this statement and goes back to the calling application. Only one error message is possible (without application log active).

MB_POST_GOOD_MOVEMENT
From release 4.0 you have to use MB_CREATE_GOODS_MOVEMENT and MB_POST_ GOODS_MOVEMENT. If there are no error message during MB_CREATE_GOODS_ MOVEMENT, you only have to call function MB_POST_GOODS_MOVEMENT to make the database update. Why we use 2 functions? After MB_CREATE_GOODS_MOVEMENT its necessary to do a COMMIT WORK. This coding would cause data inconsistencies:
call function MB_CREATE_GOODS_MOVEMENT call function MB_CREATE_GOODS_MOVEMENT commit work. (-> first mat.doc. in update task) (-> second mat.doc in update task)

A few applications in SAP designed their programs in such a way. They were able to post more than one material document in one LUW (logical unit of work). Its almost impossible to clear all internal tables/fields/structures we use during a goods movement, so the second goods movement sometimes took wrong data durning the update (-> data inconstencies). From release 4.0 the coding has to be like this:
call function MB_CREATE_GOODS_MOVEMENT call function MB_POST_GOODS_MOVEMENT commit work. (-> prepare goods movement) (->database updates)

Not possible:
call function MB_CREATE_GOODS_MOVEMENT call function MB_POST_GOODS_MOVEMENT call function MB_CREATE_GOODS_MOVEMENT call function MB_POST_GOODS_MOVEMENT commit work. (-> prepare goods movement) (->database updates) (-> prepare goods movement) (->database updates)

This coding would cause an error message: M7 266 or M7 299. After the use of MB_POST_GOODS_MOVEMENT the next statement must be COMMIT WORK.

Example
CO11 (Create production order confirmation)
call function 'MB_CREATE_GOODS_MOVEMENT' exporting imkpf = imkpf xallp = ' ' xallr = 'X' ctcod = tcode_prod importing emkpf = emkpf tables emseg = emseg imseg = imseg. if emkpf-subrc = 1. call function 'MB_POST_GOODS_MOVEMENT' importing emkpf = emkpf exceptions others = 0. if emkpf-subrc ne 0. clear goods_movement_ok. endif. endif.

prepare goods movement

database update

Customer message
There are a lot of customer messages, where you need to know MB_CREATE_GOODS_ MOVEMENT. Most of them are complicated, because the customers use transactions from another application (not MM-IM) like PP, SD, QM, etc. An error can happen, because of: - wrong customizing - wrong import data for MB_CREATE_GOODS_MOVEMENT - program error in calling application - program error in MM-IM If you still dont know what caused the error, after checking the customizing (this should be done by the calling application) and the standard note-search, you should proceed in this way: a) The customer gets an error message during the posting of the goods movement: 1. Set a breakpoint in LMBWLU14 (main program in MB_CREATE_GOODS_MOVEMENT): At the first line. 2. Call the transaction used by the customer and post the goods movement 3. If the breakpoint works, the system should stop at the breakpoint set in 1. *** 4. Menue path: Breakpoint Breakpoint at Statement: message 5. F8 (Continue): The system stops at the error message (sometimes the system stops at CO-,FI- or warning messages, which are not important (use F8 to proceed)). Try to find out what causes the error message. Attention: Not every M7 message is a MM-IM problem! Example: We call a MM-PUR-function to get the PO data, but we dont get a result from MM-PUR. This causes a M7 error message, but it could be a problem in MM-PUR. b) The customer wrote, the database update for a special field is not correct during the goods movement: (use a test system, if the error is reproducible) 1. Set a breakpoint in LMBWLU14 (main program in MB_CREATE_GOODS_MOVEMENT): At the first line. 2. Call the transaction used by the customer and post the goods movement. 3. If the breakpoint works, the system should stop at the breakpoint set in 1. *** 4. Check IMSEG: What is the content of the field (if its in IMSEG or IMKP): Not correct Customer message belongs to calling application. Correct Proceed with 5. 5. Set watchpoint on field (in most of the customer messages its a field in table MSEG, DM07M, VM07M) 6. F8 (Continue): Try to find out where and why the content of the field changes. Furthermore try to find out who is responsible for this change. If its not MM-IM, youll have to change the component of the customer message. *** You can set another breakpoint to secure the goods movement will not be posted: (you can use the test data a second time) - you are in debugging mode in program LMBWLU14 - push button: CALLS / C to see the calling programs

doubleclick on the previous program (the one which called MB_CREATE_GOODS_ MOVEMENT) - set a breapoint at the first line after the call of MB_CREATE_GOODS_ MOVEMENT After processing MB_CREATE_GOODS_ MOVEMENT, the system should stop at this line. You can analyse the internal table / structure the calling application uses for EMSEG and EMKPF. ( take a look at the fields SUBRC, MSGID, MSGNO, MSGTY, MSGV1, MSGV2, MSGV3, MSGV4. Described in chapter EXPORT). -

10

Program
The main include in MB_CREATE_GOODS_ MOVEMENT is LMBWLU14. Structure of this include:
FUNCTION mb_create_goods_movement. CALL FUNCTION 'MB_MOVEMENTS_REFRESH' CALL FUNCTION 'MB_CREATE_GOODS_ISSUE_HEADER' LOOP AT imseg. CALL FUNCTION 'MB_READ_RESERVATION_MBWL' CALL FUNCTION 'ME_CONFIRMATION_SEARCH_GR' MOVE-CORRESPONDING imseg TO dm07m. MOVE-CORRESPONDING imseg TO vm07m. MOVE-CORRESPONDING imseg TO mseg. CALL FUNCTION 'MB_CHECK_SUBCONTRACT_ORDER' MOVE-CORRESPONDING dm07m TO fuss. MOVE-CORRESPONDING vm07m TO fuss. MOVE-CORRESPONDING mseg TO fuss. APPEND FUSS. ENDLOOP WHILE sy-subrc IS INITIAL. READ TABLE fuss INDEX 1. IF sy-subrc IS INITIAL. DELETE fuss INDEX 1. CALL FUNCTION 'MB_CREATE_GOODS_ISSUE_ITEM' ENDWHILE. CALL FUNCTION 'MB_CREATE_MATERIAL_DOCUMENT' if XALLR=X all tables/fields/structure will be refreshed check of header data

if necessary: read reservation get PO for delivery

get subcontractor items

get material document number, serial number handling

In this function we do all important checks for each item (line in IMSEG):
FUNCTION 'MB_CREATE_GOODS_ISSUE_ITEM' CASE mseg-kzbew. WHEN b. (b = goods receipt for purchase order) WHEN f. (f = goods receipt for production order) WHEN OTHERS. (every goods movement, except the ones for kzbew = b or f) ENDCASE.

11

Das könnte Ihnen auch gefallen