cancel
Showing results for 
Search instead for 
Did you mean: 

EXIT MB_CF001 for WMMBXY

Former Member
0 Kudos

Hello everybody,

I am a SAP developper and I have to find a way to supply a WMS with infos on goods movements made in SAP for transfer movements posted with MB1B.

I would like to use SAP standard objects as much as possible and I was told that there is a way to issue standard idocs like WMMBXY from the user exit MB_CF001.

An example of coding is supposed to be given in the documentation of the img activity, but i cannot find it.

Does anybody know about how to do this?

Thank you for helping...

Julien Boffet

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If you go to transaction SMOD and supply the exit name MB_CF001 you can then click on the documenation button and receive the following:

The user exit MB_CF001 includes a function module that is called up

immediately before the COMMIT WORK when a goods movement is posted.

All the material document data is passed on to this function module from

the following tables:

o MKPF (Material document header)

o MSEG (Material document items)

o VM07M (Update data)

This data can be passed on to other programs.

Note

The user exit does not write any data to the material document, that is,

it is not possible to change material document data before the update

posting takes place.

If the enhancement MB_CF001 (component: Function module

EXIT_SAPLMBMB_001 with Include ZXMBCU01) is implemented incorrectly an

inconsistency may occur between documents and stocks as well as between

material documents and accounting documents. Such inconsistencies can be

caused by the following elements in the user exit, for example:

o COMMIT WORK

o Remote function call (CALL FUNCTION .. DESTINATION)

o Separate updates on the document or stock tables (for example, an

update on table MBEW, MARD, MSEG)

o Unlocking data (for example, through DEQUEUE_ALL)

The enhancement MB_CF001 is called in the update function module

MB_POST_DOCUMENT. If a COMMIT WORK or a Remote Function Call are set in

the enhancement, a complete ROLL BACK is not possible in the case of an

update termination since data is already written until the COMMIT or the

remote function call in the database. Consequently an asynchronous

status (for example, a material document without accounting document),

which can only be repaired with considerable effort, can result.

The enhancement MB_CF001 is not suited for customer-specific updates on

the stock tables since such updates can destroy the standard inventory

update if they are not programmed incrementally (see Note 6899) or do

not take the material blocks into account.

An unlocking of data (for example using DEQUEUE_ALL) is also a very high

priority since the data to be updated is no longer protected against

external updates and inconsistencies can result from parallel updates.

Before you activate an enhancement, carefully check that the user exit

does not contain a high priority source code positions.

If data inconsistencies already occurred in your system, which can be

traced back to the user exits, remove the high priority source code

positions immediately before they cause further inconsistencies.

Examples

The following example illustrates how you can use this user exit if you

have a link to an external system. All the goods movements of a

particular movement type are passed on to an external system via IDOC

using the ALE link. An existing IDOC structure is used. In addition to

the following coding, you must also specify a destination and a partner

link for the output in the ALE Customizing section.

  • INCLUDE ZXMBCU01/ (Create the Include by activating the

  • user-exit with transaction /nCMOD)

*----


""Local interface:

*" TABLES

*" XMKPF STRUCTURE MKPF

*" XMSEG STRUCTURE MSEG

*" XVM07M STRUCTURE VM07M

*----


data: p_varia like t327a-varia. "helper, of no use here

data: flg_continue_work type c value 0.

loop at xmseg.

if xmseg-bwart = 501.

flg_continue_work = 1.

else.

delete xmseg.

endif.

endloop.

check flg_continue_work = 1.

tables: edidd, edidc, e1mbxyh, e1mbxyi.

data: begin of comm_idoc_control occurs 10.

include structure edidc.

data: end of comm_idoc_control.

*----


  • Data send to ALE

*----


*........Giving data to ALE-interface..............................

call function 'L_IDOC_HEADER_CREATE'

exporting

i_mestyp = 'WMMBXY'

i_mescod = p_varia

i_idoctp = 'WMMBID01'

i_rcvprn = 'P30CLNT003'.

*........Prepare 1.Segment............................................

clear edidd.

loop at xmkpf.

move-corresponding xmkpf to e1mbxyh.

move sy-tcode to e1mbxyh-tcode.

move e1mbxyh to edidd-sdata.

endloop.

call function 'L_IDOC_SEGMENT_CREATE'

exporting

i_segnam = 'E1MBXYH'

i_sdata = edidd-sdata.

*........Prepare Itemdata .............................................

loop at xmseg.

clear edidd.

move-corresponding xmseg to e1mbxyi.

move e1mbxyi to edidd-sdata.

call function 'L_IDOC_SEGMENT_CREATE'

exporting

i_segnam = 'E1MBXYI'

i_sdata = edidd-sdata.

endloop.

*.......Send IDOC ............................................

call function 'L_IDOC_SEND'

tables

t_comm_idoc = comm_idoc_control

exceptions

error_distribute_idoc = 01.

if sy-subrc ne 0.

message id sy-msgid type 'A' number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

Former Member
0 Kudos

Hello Thomas,

Thank you so much for this!!!

Indeed it is exactly the bit of documentation I was looking for. It is stange though because I tried again on my system, and I do not have the example of ALE implementation for this userexit using SMOD nor using SPRO. I tried in French English and German and I only get the documentation until "positions immediately before they cause further inconsistencies".

Well anyway many thanks again, it solves my problem greatly !!!

julien