BAd I MB_MIGO_BADI

作者:郑德鼎 约 6 分钟阅读 更新日期:2024-02-22 2 年前更新 标签:ABAP, MM, 开发, 物料管理

BAdI MB_MIGO_BADI with LINE MODIFY method to change the MIGO GOITEM Structure

Updated May 18, 2018

How to change MIGO by using BAdI MB_MIGO_BADI with LINE_MODIFY method?

We are using the BAdI MB_MIGO_BADI with the LINE_MODIFY method to change the MIGO GOITEM structure but we carry out a goods movement by calling transaction MIGO, and we want to this BAdI should only be processed if new items are added or existing items are changed.

Solution

The BAdI MB_MIGO_BADI with the method LINE_MODIFY is called again in display mode so that customer-defined implementations (of additional tab pages, for example) are also represented here accordingly.  In this case, the system no longer issues message MIGO 050.

Enhancing the documentation of the BAdI MB_MIGO_BADI.

To adjust the documentation manually in advance, proceed as follows

1. Call transaction SE18 for the BAdI MB_MIGO_BADI and choose "Display".

2. In the following screen, choose the "Documentation" button from the menu bar.  A new window containing the BAdI documentation opens.

3. Here, search for the text "Insert / change line (GOITEM)" and choose the link "LINE_MODIFY" that is below it.  You are now in the documentation for the method LINE_MODIFY of the BAdI.

4. Choose "Edit Documentation" and search for the sentence "The LINE_MODIFY method is called if a new line is added to GOITEM, or if an existing line is changed (see also the PAI_DETAIL method with E_FORCE_CHANGE).".

5. Insert the following text below it:  "In addition, the method is also called in display mode; however, no changes are transferred to GOITEM".

6. Choose "Document -> Save -> Active Version", select a suitable correction order, and release and transport the changes.

Former Member

June 14, 2013 6 minute read

How to create a custom TAB for MIGO Item Details

71153,081

Dear all, I have implemented a custom tab in MIGO, you can follow the steps.

My requirement was to add a new tab named “Warranty” in MIGO.

Step1 : Create a custom table to store the data of  “Warranty”  tab

The first four fields should be the key fields, and the rest fields are your required custom fields.

Step 2: create a structure with the custom field you require on the MIGO.

Step 3: open structure GOITEM and append the same custom structure into it as shown below.

Step 4: Create another structure and append the table created in Step-1.

Step 5:  Create a Table type of the structure created in step-4 as shown below.

Step 6: go to SE80 and create a program as shown below. This screen must contain two screen.

Step 7: SE19 -> Badi Name: MB_MIGO_BADI

Press Create Impl. Button and create Implementation: ZMIGO_WARRENTY as shown below.

Step 8: Create a Class : ZCLASS_MIGO_WARRENTY as shown below.

Step 9: Maintain the following attributes in your Class Interface as shown below.

Step 10: Write the following codes for the methods shown below.

(a) for    IF_EX_MB_MIGO_BADI~INIT

METHOD if_ex_mb_migo_badi~init. APPEND gf_class_id TO ct_init.ENDMETHOD.

(b) for   IF_EX_MB_MIGO_BADI~PBO_DETAIL

METHOD if_ex_mb_migo_badi~pbo_detail. DATA: wa_extdata  TYPE zst_warrenty.

DATA :gf_class_id TYPE migo_class_id.

gf_class_id = ‘ZCLASS_MIGO_WARRENTY’.

CHECK i_class_id = gf_class_id.

IF g_no_input IS INITIAL.

e_cprog   = ‘ZSAPMZMM_MIGO_WARENTY’.

e_dynnr   = ‘9001’.                     “External fields: Input

e_heading = ‘Warranty’(001).

ELSE.

e_cprog   = ‘ZSAPMZMM_MIGO_WARENTY’.

e_dynnr   = ‘9002’.                     “External fields: Display

e_heading = ‘Warranty’(001).

ENDIF.

g_line_id = i_line_id.

READ TABLE gt_extdata INTO wa_extdata WITH KEY line_id = g_line_id. IF sy–subrc = 0 AND wa_extdata–mblnr IS NOT INITIAL AND wa_extdata–mjahr IS NOT INITIAL AND wa_extdata–zeile IS NOT INITIAL. SELECT SINGLE * FROM ztb_warrenty

CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF wa_extdata

WHERE mandt = sy–mandt

AND   mblnr = wa_extdata–mblnr AND   mjahr = wa_extdata–mjahr AND   zeile = wa_extdata–zeile.

SET PARAMETER ID: ‘ZWARANTY’ FIELD wa_extdata–zzwarnt,

‘ZWARBEGD’ FIELD wa_extdata–zzwbegd,

‘ZWARENDD’ FIELD wa_extdata–zzwendd.

ELSE.

SET PARAMETER ID: ‘ZWARANTY’ FIELD space,

‘ZWARBEGD’ FIELD space,

‘ZWARENDD’ FIELD space.

ENDIF.ENDMETHOD.

(c) for    IF_EX_MB_MIGO_BADI~PAI_DETAIL

METHOD if_ex_mb_migo_badi~pai_detail.

e_force_change = ‘X’.ENDMETHOD.

(d) for    IF_EX_MB_MIGO_BADI~LINE_MODIFY

METHOD if_ex_mb_migo_badi~line_modify. DATA: ls_extdata  TYPE zst_warrenty.

IF cs_goitem–mblnr IS NOT INITIAL AND cs_goitem–mjahr IS NOT INITIAL AND cs_goitem–zeile IS NOT INITIAL.

ls_extdata–line_id  = i_line_id. ls_extdata–mblnr    = cs_goitem–mblnr. ls_extdata–mjahr    = cs_goitem–mjahr. ls_extdata–zeile    = cs_goitem–zeile. ls_extdata–zzwarnt  = cs_goitem–zzwarnt. ls_extdata–zzwbegd  = cs_goitem–zzwbegd. ls_extdata–zzwendd  = cs_goitem–zzwendd. DELETE gt_extdata WHERE line_id = ls_extdata–line_id.

INSERT ls_extdata INTO TABLE gt_extdata.

ELSE.

ls_extdata–line_id  = i_line_id. ls_extdata–zzwarnt  = cs_goitem–zzwarnt. ls_extdata–zzwbegd  = cs_goitem–zzwbegd. ls_extdata–zzwendd  = cs_goitem–zzwendd. DELETE gt_extdata WHERE line_id = ls_extdata–line_id.

INSERT ls_extdata INTO TABLE gt_extdata.

ENDIF.ENDMETHOD.

(e) for    IF_EX_MB_MIGO_BADI~RESET

METHOD if_ex_mb_migo_badi~reset.

CLEAR: gt_extdata,

g_no_input,

gs_exdata_header,

g_cancel,

g_line_id.ENDMETHOD.

(f) for    IF_EX_MB_MIGO_BADI~POST_DOCUMENT

METHOD if_ex_mb_migo_badi~post_document. DATA: wa_warrenty TYPE ztb_warrenty,

it_warrenty TYPE TABLE OF ztb_warrenty,

wa_mseg     TYPE mseg,

wa_extdata  TYPE zst_warrenty.

LOOP AT it_mseg INTO wa_mseg. READ TABLE gt_extdata INTO wa_extdata WITH KEY line_id = wa_mseg–line_id.

IF sy–subrc = 0.

MOVE-CORRESPONDING wa_mseg TO wa_extdata.

MOVE-CORRESPONDING wa_extdata TO wa_warrenty.

APPEND wa_warrenty TO it_warrenty. ENDIF. ENDLOOP. MODIFY ztb_warrenty FROM TABLE it_warrenty. ENDMETHOD.

(g) for    IF_EX_MB_MIGO_BADI~CHECK_ITEM

METHOD if_ex_mb_migo_badi~check_item. DATA: wa_extdata  TYPE zst_warrenty,

ls_bapiret TYPE bapiret2.

READ TABLE gt_extdata INTO wa_extdata WITH TABLE KEY line_id = i_line_id.

IF wa_extdata–zzwarnt IS INITIAL.

ls_bapiret–type       = ‘E’. ls_bapiret–id         = ‘M7’. ls_bapiret–number     = ‘895’. ls_bapiret–message_v1 = ‘Enter warranty condition’(002). APPEND ls_bapiret TO et_bapiret2. ENDIF. IF wa_extdata–zzwarnt = ‘YES’ AND ( wa_extdata–zzwbegd IS INITIAL OR wa_extdata–zzwendd IS INITIAL OR ( wa_extdata–zzwbegd GT wa_extdata–zzwendd ) ). ls_bapiret–type       = ‘E’. ls_bapiret–id         = ‘M7’. ls_bapiret–number     = ‘895’. ls_bapiret–message_v1 = ‘Enter appropriate warranty Start and End date’(003). APPEND ls_bapiret TO et_bapiret2. ENDIF. ENDMETHOD.

(h) for    IF_EX_MB_MIGO_BADI~MODE_SET

METHOD if_ex_mb_migo_badi~mode_set.

CLEAR : g_no_input.

IF i_action = ‘A04’ .

g_no_input = ‘X’.

ENDIF.

IF i_action = ‘A03’.

g_cancel = ‘X’.

ENDIF.ENDMETHOD.

Note: Leave the other Methods blank. Do not write any thing in that.

Step 11: Open MIGO , you will be able to see the new tab “WARRANTY” as shown below.

The system will store the data of your custom screen into the table created in Step-1.

Thanks

Debdutta Satpathy

FollowLikeRSS Feed

Alert Moderator

Assigned Tags

ABAP Development

Similar Blog Posts

BAdI MB_MIGO_BADI - In the middle of nowhere

By Roberto VaccaOct 06, 2015

An example to call PAL Apriori via AMDP

By Jerome ZhaoFeb 18, 2020

Adding Field in standard Fiori apps of S/4HANA with Custom Fields and Logic

By Masaaki AraiFeb 01, 2020

Related Questions

How to create custom alv table in custom tab of MIGO?

By Andy PataselanoApr 05, 2021

MIGO - MIRO RELATED.

By Former MemberDec 28, 2006

Function Module to get the Purchase Order and MIGO detail for creating MIRO

By sivaraman GFeb 09, 2016

7 Comments

Chandrasekhara Reddy

June 17, 2013 at 5:42 am

Nicely Documented, It really works. My ABAPER tried this.

Thanks

Like 0

Reply

Alert Moderator

Share

Former Member

June 17, 2013 at 6:59 am

Good Doc..

Like 0

Reply

Alert Moderator

Share

Debesh Tiwari

January 18, 2016 at 9:46 am

Very nice document..

Like 0

Reply

Alert Moderator

Share

Former Member

July 5, 2016 at 7:39 pm

Your paper helped me a lot today. Thanks!!!

Like 0

Reply

Alert Moderator

Share

A N

October 2, 2016 at 5:02 pm

Dear Debdutta,

Thanks for sharing document.

I have gone through the process and successfully created custom tab in ITEM Details but unable to SAVE data in ZTABLE ZTB_WARRENTY.

I am unable to the understand the PROGRAM created, to pass the zfield values.

Can you please suggest.

Thanks,

AN

Like 0

Reply

Alert Moderator

Share

Former Member

December 24, 2016 at 5:17 pm

hello everyone , nice sharing , thank you very much.

i have a question about GET PARAMETER, i can not display data when re-open my document. below i added my code.

Like 0

Reply

Alert Moderator

Share

Sunu Thomas

September 22, 2022 at 8:49 am

Thanks for sharing. Very helpful

Like 0

Reply

Alert Moderator

Share

郑德鼎

关于作者:郑德鼎

企业信息化与 SAP 技术顾问,长期专注 SAP ABAP、FI/CO、MM、SD 等模块的技术分享与实战经验总结。查看更多介绍

来源说明:本文内容由「BAdI MB_MIGO_BADI.docx」整理生成,仅用于内部技术分享与学习交流。