Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

How to create a custom TAB for MIGO Item Details

$
0
0

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

1.JPG

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.

2.JPG

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

3.JPG

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

4.JPG

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

5.JPG

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

6.JPG7.JPG

Step 7:SE19 -> Badi Name: MB_MIGO_BADI

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

8.JPG

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

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

9.JPG

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

10.JPG

 

(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' OR i_action = 'A03' OR i_action = 'A05' OR
     i_action
= 'A02' OR i_action = 'A06' OR i_action = 'A07'.
    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.

11.JPG

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

 

Thanks

Debdutta Satpathy


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>