11
MB_CREATE_GOODS_MOVEMENT Documentation: Version 1.0, 14.03.2000 General........................................................................................................................................... 2 How to use MB_CREAT E_GOODS_MOVEMENT......................................................................... 3 Import....... .................................................................................................................................. 3 Export....... .................................................................................................................................. 6 Example...... ................................................................................................................................ 8 Customer message........... .......................................................................................................... 9 Program........ ................................................................................................................................ 11 1

MM IM Technical Documentation

Embed Size (px)

Citation preview

Page 1: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 1/11

MB_CREATE_GOODS_MOVEMENTDocumentation: Version 1.0, 14.03.2000

General........................................................................................................................................... 2How to use MB_CREATE_GOODS_MOVEMENT.........................................................................3

Import......................................................................................................................................... 3Export....................................................................................................................................... .. 6Example...................................................................................................................................... 8Customer message.....................................................................................................................9

Program....................................................................................................................................... . 11

1

Page 2: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 2/11

GeneralMM-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 goodsmovements in the background, during their logistic process. These transactions don’t use theMM-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-Standard-Programs are able to post a goods movement in the background. They all have to use the sameinterface: Function MB_CREATE_GOODS_MOVEMENTThe function uses almost the same forms/functions, we use in the MM-IM-Transactions. Theadvantage for the calling application is, they don’t 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 IDOC’s and BAPI’s use this function:- IDOC: WMMBXY

MBGMCR- Bapi: CreateFromData (function ‘BAPI_GOODSMVT_CREATE’)

2

Page 3: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 3/11

How to use MB_CREATE_GOODS_MOVEMENTMB_CREATE_GOODS_MOVEMENT is a function (use SE37 to display function) with Import-and Export-Parameters.

ImportTo post a goods movement with function MB_CREATE_GOODS_MOVEMENT the calling reporthas provide this data:

Structures:IMKPF Input data for material document header  Tables:IMSEG Input data of material document itemsFields:

 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 itemshave 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 initializedor only the new/corrected items are to be processed.Example: (Release 3.1I)

a) XALLR = ‘X’:

call function ‘MB_CREATE_GOODS_MOVEMENT’ (with 2 lines in table IMSEG)call function ‘MB_CREATE_GOODS_MOVEMENT’ (with 3 lines in table IMSEG)

importing…

xallr = 'X'…

commit work.

Result: Material document with 3 items

b) XALLR = ‘ ‘:

call function ‘MB_CREATE_GOODS_MOVEMENT’ (with 2 lines in table IMSEG)

call function ‘MB_CREATE_GOODS_MOVEMENT’ (with 3 lines in table IMSEG)importing

…xallr = ‘ ‘

3

Page 4: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 4/11

commit work.

Result: Material document with 5 items

- CTCOD:The system uses either the SY-TCODE or the transaction code that has explicitly beenprovided in the import parameter CTCOD. You have to make sure that an entry for thetransaction is contained in table T158. In addition, you have to maintain the transaction/validmovement 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 purchaseorder 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 inthe interface is to be transferred. The system automatically determines GI items.

  All in all it’s 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 usetransaction BAPI (release >4.5):

transaction BAPI

Materials Management

Inventory Management

4

Page 5: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 5/11

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

It’s 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 fieldnames2 Call MB_CREATE_GOODS_MOVEMENT3 Translate the ‘german result’ into english.The functionality is almost the same (instead of serial number handling)

5

Page 6: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 6/11

ExportThe 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 identificationMSGNO System message number  MSGTY Message typeMSGV1 Message variable 01MSGV2 Message variable 02MSGV3 Message variable 03MSGV4 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 incorrect15 Header data incorrect11 Error when reading material master records per PREFETCH10 Error when reading material short texts per PREFETCH08 Allocation of IMSEG to EMSEG incorrect

07 Error when correcting an item06 Error when creating an item05 No item generated4 It is only permitted to post all items; however, there is at least

one incorrect item03 Error when posting the document02 Allocation of IMSEG to EMSEG incorrect01 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, therelevant error message can be found in table EMSEG (with reference to the relevant line). For thefollowing EMKPF-SUBRC's, the error messages are contained in table EMSEG: 07, 06, 05, 04.

Don’t forget:If there is an error message in a function, the program stops at this statement and goes back tothe calling application. Only one error message is possible (without application log active).

6

Page 7: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 7/11

MB_POST_GOOD_MOVEMENTFrom 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 thedatabase update.

Why we use 2 functions? After MB_CREATE_GOODS_MOVEMENT it’s necessary to do a COMMIT WORK. This codingwould cause data inconsistencies:

call function ‘MB_CREATE_GOODS_MOVEMENT’ (-> first mat.doc. in update task)call function ‘MB_CREATE_GOODS_MOVEMENT’ (-> second mat.doc in update task)

commit work.

 A few applications in SAP designed their programs in such a way. They were able to post morethan one material document in one LUW (logical unit of work). It’s almost impossible to clear allinternal tables/fields/structures we use during a goods movement, so the second goodsmovement sometimes took wrong data durning the update (-> data inconstencies). Fromrelease 4.0 the coding has to be like this:

call function ‘MB_CREATE_GOODS_MOVEMENT’ (-> prepare goods movement)call function ‘MB_POST_GOODS_MOVEMENT’ (->database updates)commit work. 

Not possible:

call function ‘MB_CREATE_GOODS_MOVEMENT’ (-> prepare goods movement)call function ‘MB_POST_GOODS_MOVEMENT’ (->database updates)

call function ‘MB_CREATE_GOODS_MOVEMENT’ (-> prepare goods movement)call function ‘MB_POST_GOODS_MOVEMENT’ (->database updates)commit work.

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.

7

Page 8: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 8/11

ExampleCO11 (Create production order confirmation)

…call function 'MB_CREATE_GOODS_MOVEMENT'

exporting

imkpf = imkpf xallp = ' 'xallr = 'X'

ctcod = tcode_prod prepare goods movement

importingemkpf = emkpf 

tablesemseg = emseg

imseg = imseg.if emkpf-subrc = 1.

call function 'MB_POST_GOODS_MOVEMENT'importing

emkpf = emkpf  database update

exceptionsothers = 0.

if emkpf-subrc ne 0.clear goods_movement_ok.

endif.endif.…

8

Page 9: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 9/11

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 fromanother 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 don’t know what caused the error, after checking the customizing (this should be doneby 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 movement3. If the breakpoint works, the system should stop at the breakpoint set in 1. ***

4. Menue path: Breakpoint

Breakpoint at

Statement: message5. 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 findout what causes the error message.

 Attention:Not every M7 message is a MM-IM problem! Example: We call a MM-PUR-function to getthe PO data, but we don’t 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 it’s 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 it’s 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 findout who is responsible for this change. If it’s not MM-IM, you’ll have to change thecomponent 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

9

Page 10: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 10/11

- 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

Page 11: MM IM Technical Documentation

7/28/2019 MM IM Technical Documentation

http://slidepdf.com/reader/full/mm-im-technical-documentation 11/11

ProgramThe main include in MB_CREATE_GOODS_ MOVEMENT is LMBWLU14.

Structure of this include:FUNCTION mb_create_goods_movement.

…CALL FUNCTION 'MB_MOVEMENTS_REFRESH' if XALLR=X all tables/fields/structure… will be refreshedCALL FUNCTION 'MB_CREATE_GOODS_ISSUE_HEADER' check of header data

…LOOP AT imseg.

…CALL FUNCTION 'MB_READ_RESERVATION_MBWL' if necessary: read reservation

…CALL FUNCTION 'ME_CONFIRMATION_SEARCH_GR' get PO for delivery

…MOVE-CORRESPONDING imseg TO dm07m.MOVE-CORRESPONDING imseg TO vm07m.MOVE-CORRESPONDING imseg TO mseg.

…CALL FUNCTION 'MB_CHECK_SUBCONTRACT_ORDER' get subcontractor items…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' 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