Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

MB_MIGO_BADI - Error Message if EKPO-BSTAE = '0004'

Former Member
0 Kudos

Hey,

I am trying to give a error message in the MIGO document using BADI MB_MIGO_BADI. The requirement is if the field in a PO line item (EKPO-BSTAE) has the value '0004', then I just want to send a error message and stop the process of posting.

I found the method IF_EX_MB_MIGO_BADI~CHECK_ITEM, but the field BSTAE is not included in the LS_GOTIEM

How to do this with the BADI MB_MIGO_BADI ?

Thank you very much.

Ferdi

Message was edited by:

Ferdinand Grah

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

see the sample BADI code and do accordingly

BAdI Name: ZMB_CHECK_LINE_BADI (Implementation name) Checking of line items in MIGO

Definition Name: MB_CHECK_LINE_BADI

Interface Name : IF_EX_MB_CHECK_LINE_BADI

Implementing Class: ZCL_IM_MB_CHECK_LINE_BADI

Method : CHECK_LINE

************************************************************************

METHOD if_ex_mb_check_line_badi~check_line .

DATA : return TYPE STANDARD TABLE OF bapiret2 INITIAL SIZE 0 ,

poitem TYPE STANDARD TABLE OF bapimepoitem INITIAL SIZE 0,

poitemx TYPE STANDARD TABLE OF bapimepoitemx INITIAL SIZE 0,

i_ekbe TYPE STANDARD TABLE OF ekbe INITIAL SIZE 0.

DATA : xmkpf1 TYPE mkpf,

xmseg1 TYPE mseg,

w_ekbe TYPE ekbe,

w_ekbe1 TYPE ekbe,

w_ekpo TYPE ekpo,

poitem1 TYPE bapimepoitem,

gv_qty TYPE menge13,

poitemx1 TYPE bapimepoitemx.

IF is_mseg-bwart EQ '105'.

IF is_mseg-lfbnr NE space.

SELECT SINGLE * INTO w_ekbe1 FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

belnr = is_mseg-lfbnr AND

buzei = is_mseg-lfpos AND

gjahr = is_mseg-lfbja.

IF w_ekbe1-grund NE '0005'.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You can take only Accepted Quantity into the stock'

'.If you want to accept this stock,' 'obtain approval of Purchasing manager'.

ENDIF.

CLEAR w_ekbe1.

ENDIF.

SELECT * INTO TABLE i_ekbe FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

( bwart = '105' OR bwart = '106') .

LOOP AT i_ekbe INTO w_ekbe.

IF w_ekbe-bwart EQ '105'.

gv_qty = gv_qty + w_ekbe-menge.

ELSE.

gv_qty = gv_qty - w_ekbe-menge.

ENDIF.

ENDLOOP.

SELECT SINGLE * INTO w_ekpo FROM ekpo WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp.

gv_qty = w_ekpo-menge - gv_qty.

IF is_mseg-menge > gv_qty.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You have already reached the PO quantity' .

ENDIF.

ELSEIF is_mseg-bwart EQ '103' AND is_mseg-grund = '0005'.

SELECT * INTO TABLE i_ekbe FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

( bwart = '103' OR bwart = '104') AND

grund EQ '0005'.

LOOP AT i_ekbe INTO w_ekbe.

IF w_ekbe-bwart EQ '103' .

gv_qty = gv_qty + w_ekbe-wesbs.

ELSE.

gv_qty = gv_qty - w_ekbe-wesbs.

ENDIF.

ENDLOOP.

SELECT SINGLE * INTO w_ekpo FROM ekpo WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp.

gv_qty = w_ekpo-menge - gv_qty.

IF is_mseg-menge > gv_qty.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You cannot exceed the PO quantity' .

ENDIF.

CLEAR w_ekbe1.

ELSEIF is_mseg-bwart EQ '104'.

IF is_mseg-lfbnr NE space.

SELECT SINGLE * INTO w_ekbe1 FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

belnr = is_mseg-lfbnr AND

buzei = is_mseg-lfpos AND

gjahr = is_mseg-lfbja.

IF w_ekbe1-grund <> is_mseg-grund.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You can cancel this document only with'

'Reason code' w_ekbe1-grund.

ENDIF.

CLEAR w_ekbe1.

ENDIF.

ENDIF.

ENDMETHOD.

Regards

Anji

2 REPLIES 2

Former Member
0 Kudos

Hi

see the sample BADI code and do accordingly

BAdI Name: ZMB_CHECK_LINE_BADI (Implementation name) Checking of line items in MIGO

Definition Name: MB_CHECK_LINE_BADI

Interface Name : IF_EX_MB_CHECK_LINE_BADI

Implementing Class: ZCL_IM_MB_CHECK_LINE_BADI

Method : CHECK_LINE

************************************************************************

METHOD if_ex_mb_check_line_badi~check_line .

DATA : return TYPE STANDARD TABLE OF bapiret2 INITIAL SIZE 0 ,

poitem TYPE STANDARD TABLE OF bapimepoitem INITIAL SIZE 0,

poitemx TYPE STANDARD TABLE OF bapimepoitemx INITIAL SIZE 0,

i_ekbe TYPE STANDARD TABLE OF ekbe INITIAL SIZE 0.

DATA : xmkpf1 TYPE mkpf,

xmseg1 TYPE mseg,

w_ekbe TYPE ekbe,

w_ekbe1 TYPE ekbe,

w_ekpo TYPE ekpo,

poitem1 TYPE bapimepoitem,

gv_qty TYPE menge13,

poitemx1 TYPE bapimepoitemx.

IF is_mseg-bwart EQ '105'.

IF is_mseg-lfbnr NE space.

SELECT SINGLE * INTO w_ekbe1 FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

belnr = is_mseg-lfbnr AND

buzei = is_mseg-lfpos AND

gjahr = is_mseg-lfbja.

IF w_ekbe1-grund NE '0005'.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You can take only Accepted Quantity into the stock'

'.If you want to accept this stock,' 'obtain approval of Purchasing manager'.

ENDIF.

CLEAR w_ekbe1.

ENDIF.

SELECT * INTO TABLE i_ekbe FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

( bwart = '105' OR bwart = '106') .

LOOP AT i_ekbe INTO w_ekbe.

IF w_ekbe-bwart EQ '105'.

gv_qty = gv_qty + w_ekbe-menge.

ELSE.

gv_qty = gv_qty - w_ekbe-menge.

ENDIF.

ENDLOOP.

SELECT SINGLE * INTO w_ekpo FROM ekpo WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp.

gv_qty = w_ekpo-menge - gv_qty.

IF is_mseg-menge > gv_qty.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You have already reached the PO quantity' .

ENDIF.

ELSEIF is_mseg-bwart EQ '103' AND is_mseg-grund = '0005'.

SELECT * INTO TABLE i_ekbe FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

( bwart = '103' OR bwart = '104') AND

grund EQ '0005'.

LOOP AT i_ekbe INTO w_ekbe.

IF w_ekbe-bwart EQ '103' .

gv_qty = gv_qty + w_ekbe-wesbs.

ELSE.

gv_qty = gv_qty - w_ekbe-wesbs.

ENDIF.

ENDLOOP.

SELECT SINGLE * INTO w_ekpo FROM ekpo WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp.

gv_qty = w_ekpo-menge - gv_qty.

IF is_mseg-menge > gv_qty.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You cannot exceed the PO quantity' .

ENDIF.

CLEAR w_ekbe1.

ELSEIF is_mseg-bwart EQ '104'.

IF is_mseg-lfbnr NE space.

SELECT SINGLE * INTO w_ekbe1 FROM ekbe WHERE ebeln = is_mseg-ebeln AND

ebelp = is_mseg-ebelp AND

belnr = is_mseg-lfbnr AND

buzei = is_mseg-lfpos AND

gjahr = is_mseg-lfbja.

IF w_ekbe1-grund <> is_mseg-grund.

MESSAGE ID 'ZM_MSG' TYPE 'E' NUMBER '000' WITH 'You can cancel this document only with'

'Reason code' w_ekbe1-grund.

ENDIF.

CLEAR w_ekbe1.

ENDIF.

ENDIF.

ENDMETHOD.

Regards

Anji

Former Member
0 Kudos

Hi Anji,

thank you for your reply !

unfortunately I'am not a developer. So what I want to do is.

Check for ekpo-ebln and ekpo-ebelp if field ekpo-bstae = '0004'

If yes than MESSAGE ID 'Z_XXX' TYPE 'E' NUMBER '000' WITH ....

Therefore I used the BADI MB_MIGO-BADI.

Can you help me again.

Thanks.

Ferdi