Skip to Content
0
Former Member
Feb 25, 2008 at 07:51 AM

USER EXIT FOR MIGO_GR ISSUE:

41 Views

HI

I have case which user want to limit material received of quantity.

i addon one table which structure

WERKS --plant id

MATNR ---material

ALLOW_SIZE -


allow max limit

RECEIVE_SIZE --- have received quantity

ervery time when execute MIGO_GR program, i will add this time received quanitity to table and check RECEIVE_SIZE < ALLOW_SIZE .

otherwise will give a message to user what this action be reject.

so i find a user exit:MB_CF001

and ABAP CODE as follow:

tables:ZMRP_LOT_SIZE,ZMRP_PARAMETER.

data:wa_mseg type mseg.

data:l_subrc type c.

DATA:IT_PARA TYPE ZMRP_PARAMETER OCCURS 0 WITH HEADER LINE.

DATA:IT_ZMRP_LOT_SIZE TYPE ZMRP_LOT_SIZE OCCURS 0 WITH HEADER LINE.

data:wa_zmrp_lot_size type ZMRP_LOT_SIZE.

RANGES:R_WERKS FOR ZMRP_LOT_SIZE-WERKS,

R_MATNR FOR MARA-MATNR,

R_MATKL FOR MARA-MATKL.

data:wa_mara type mara.

data:l_msg(30) type c,

g_msg(100) type c.

break john.

break fms04873.

clear l_subrc .

read table XMSEG INTO wa_mseg with key bwart = '101'.

if sy-subrc <> 0.

read table XMSEG INTO wa_mseg with key bwart = '103'.

if sy-subrc = 0.

l_subrc = '0'.

endif.

else.

l_subrc = '0'.

endif.

check l_subrc = '0'.

***lock mrp prameters table.

CALL FUNCTION 'ENQUEUE_EZ_MRP_PARAMETER'

EXPORTING

MODE_ZMRP_PARAMETER = 'S'

MANDT = SY-MANDT

  • MRP01 =

  • MRP02 =

  • X_MRP01 = ' '

  • X_MRP02 = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

  • EXCEPTIONS

  • FOREIGN_LOCK = 1

  • SYSTEM_FAILURE = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE 'parameter table is lock' TYPE 'E'.

ENDIF.

SELECT * INTO TABLE IT_PARA FROM ZMRP_PARAMETER.

loop at IT_PARA.

****

IF IT_PARA-MRP01 = '1'.

R_WERKS-SIGN = 'I'.

R_WERKS-OPTION = 'EQ'.

R_WERKS-LOW = IT_PARA-MRP03.

COLLECT R_WERKS.

ENDIF.

****

IF IT_PARA-MRP01 = '3'.

R_MATNR-SIGN = 'I'.

R_MATNR-OPTION = 'CP'.

R_MATNR-LOW = IT_PARA-MRP03.

COLLECT R_MATNR.

ENDIF.

***

IF IT_PARA-MRP01 = '4'.

R_MATKL-SIGN = 'I'.

R_MATKL-OPTION = 'CP'.

R_MATKL-LOW = IT_PARA-MRP03.

COLLECT R_MATKL.

ENDIF.

ENDLOOP.

LOOP AT XMSEG INTO WA_MSEG.

IF WA_MSEG-BWART = '101' OR WA_MSEG-BWART = '103'.

IF WA_MSEG-WERKS IN R_WERKS.

IF NOT WA_MSEG-MATNR IN R_MATNR.

SELECT SINGLE * INTO WA_MARA FROM MARA

WHERE MATNR = WA_MSEG-MATNR.

IF NOT WA_MARA-MATKL IN R_MATKL.

**********

read table IT_ZMRP_LOT_SIZE with key werks = wa_mseg-werks

matnr = wa_mseg-matnr.

if sy-subrc = 0.

it_zmrp_lot_size-RECEIVE_SIZE =

it_zmrp_lot_size-RECEIVE_SIZE + wa_mseg-MENGE.

if it_zmrp_lot_size-ALLOW_SIZE <

it_zmrp_lot_size-RECEIVE_SIZE.

  • perform unlock_data.

  • perform display_info.

loop at it_zmrp_lot_size into wa_zmrp_lot_size.

CALL FUNCTION 'DEQUEUE_EZ_ZMRP_LOT_SIZE'

EXPORTING

MODE_ZMRP_LOT_SIZE = 'E'

MANDT = SY-MANDT

WERKS = wa_zmrp_lot_size-werks

MATNR = wa_zmrp_lot_size-matnr.

endloop.

CALL FUNCTION 'DEQUEUE_EZ_MRP_PARAMETER'

EXPORTING

MODE_ZMRP_PARAMETER = 'S'

MANDT = SY-MANDT.

l_msg = wa_mseg-ebeln.

condense l_msg.

concatenate 'num:' l_msg into g_msg.

l_msg = wa_mseg-ebelp.

condense l_msg.

concatenate g_msg 'item' l_msg into g_msg.

concatenate g_msg 'exceed max number'

into g_msg.

MESSAGE g_msg type 'E'.

else.

modify it_zmrp_lot_size.

endif.

else.

select single * into IT_ZMRP_LOT_SIZE from ZMRP_LOT_SIZE

where werks = wa_mseg-werks

and matnr = wa_mseg-matnr.

if sy-subrc <> 0.

  • perform unlock_data.

  • perform display_info.

loop at it_zmrp_lot_size into wa_zmrp_lot_size.

CALL FUNCTION 'DEQUEUE_EZ_ZMRP_LOT_SIZE'

EXPORTING

MODE_ZMRP_LOT_SIZE = 'E'

MANDT = SY-MANDT

WERKS = wa_zmrp_lot_size-werks

MATNR = wa_zmrp_lot_size-matnr.

endloop.

CALL FUNCTION 'DEQUEUE_EZ_MRP_PARAMETER'

EXPORTING

MODE_ZMRP_PARAMETER = 'S'

MANDT = SY-MANDT.

l_msg = wa_mseg-ebeln.

condense l_msg.

concatenate 'num:' l_msg into g_msg.

l_msg = wa_mseg-ebelp.

condense l_msg.

concatenate g_msg 'item' l_msg into g_msg.

concatenate g_msg 'exceed max number'

into g_msg.

MESSAGE g_msg type 'E'.

else.

if it_zmrp_lot_size-ALLOW_SIZE <

it_zmrp_lot_size-RECEIVE_SIZE.

  • perform unlock_data.

  • perform display_info.

loop at it_zmrp_lot_size into wa_zmrp_lot_size.

CALL FUNCTION 'DEQUEUE_EZ_ZMRP_LOT_SIZE'

EXPORTING

MODE_ZMRP_LOT_SIZE = 'E'

MANDT = SY-MANDT

WERKS = wa_zmrp_lot_size-werks

MATNR = wa_zmrp_lot_size-matnr

.

endloop.

CALL FUNCTION 'DEQUEUE_EZ_MRP_PARAMETER'

EXPORTING

MODE_ZMRP_PARAMETER = 'S'

MANDT = SY-MANDT.

l_msg = wa_mseg-ebeln.

condense l_msg.

concatenate 'num:' l_msg into g_msg.

l_msg = wa_mseg-ebelp.

condense l_msg.

concatenate g_msg 'item' l_msg into g_msg.

concatenate g_msg 'exceed max number'

into g_msg.

MESSAGE g_msg type 'E'.

else.

  • perform lock_data.

CALL FUNCTION 'ENQUEUE_EZ_ZMRP_LOT_SIZE'

EXPORTING

MODE_ZMRP_LOT_SIZE = 'E'

MANDT = SY-MANDT

WERKS = it_zmrp_lot_size-werks

MATNR = it_zmrp_lot_size-matnr.

IF SY-SUBRC <> 0.

  • perform unlock_data.

loop at it_zmrp_lot_size into wa_zmrp_lot_size.

CALL FUNCTION 'DEQUEUE_EZ_ZMRP_LOT_SIZE'

EXPORTING

MODE_ZMRP_LOT_SIZE = 'E'

MANDT = SY-MANDT

WERKS = wa_zmrp_lot_size-werks

MATNR = wa_zmrp_lot_size-matnr

.

endloop.

CALL FUNCTION 'DEQUEUE_EZ_MRP_PARAMETER'

EXPORTING

MODE_ZMRP_PARAMETER = 'S'

MANDT = SY-MANDT.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

append it_zmrp_lot_size.

endif.

endif.

endif.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

*****modify

IF it_zmrp_lot_size[] is not initial.

modify zmrp_lot_size from table it_zmrp_lot_size.

endif.

  • perform unlock_data.

loop at it_zmrp_lot_size into wa_zmrp_lot_size.

CALL FUNCTION 'DEQUEUE_EZ_ZMRP_LOT_SIZE'

EXPORTING

MODE_ZMRP_LOT_SIZE = 'E'

MANDT = SY-MANDT

WERKS = wa_zmrp_lot_size-werks

MATNR = wa_zmrp_lot_size-matnr.

endloop.

CALL FUNCTION 'DEQUEUE_EZ_MRP_PARAMETER'

EXPORTING

MODE_ZMRP_PARAMETER = 'S'

MANDT = SY-MANDT.

***************end

first question:

this segment code can't be debug even have set break point.

how to debug this segment.

second question:

use the same condition to execute MIGO_GR,but one usING BDC method with CALL TRANSCTION 'MIGO_GR' will go to this segment code and display message which set in USER EXIT code.

but other use TCODE MIGO_GR to receive goods and will create document successfully.

three question:

have other method will be resolve my issue.

thank you advance!