注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

XINBO'S SAP BLOG

你所浪费的今天,是昨天死去的人奢望的明天。你所厌恶的现在,是未来的你回不去的曾经

 
 
 

日志

 
 

Step by step guide on adding a new tab in ME21N using a BADI  

2012-12-28 10:10:07|  分类: Enhancement |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Introduction:  

The requirement is to add below screen fields in the ME21N, ME22N, ME23N (Header Section) …New tab called "Other Data" using a BADI.  

   

Step by step procedure:  

First, add the new fields required in the extension structure for EKKO table (CI_EKKODB). These fields will reflect in the new tab which we are going create in the ME21N screen.  

 

Now, Implement the BADI (ME_GUI_PO_CUST).  

First method: SUBSCRIBE  

DATA: ls_subscriber LIKE LINE OF re_subscribers.

* we want to add a customer subscreen on the Header tab

CHECK im_application = 'PO'.

CHECK im_element = 'HEADER'.

* each line in re_subscribers generates a subscreen. We add one subscreen in this example

CLEAR re_subscribers[].

* the name is a unique identifier for the subscreen and defined in this class definition

ls_subscriber-name = subscreen1.

* the dynpro number to use

ls_subscriber-dynpro = '0001'.

* the program where the dynpro can be found

ls_subscriber-program = 'SAPLZKMMM_KAU86037'.

* each subscreen needs his own DDIC-Structure

ls_subscriber-struct_name = 'CI_EKKODB'.

* a label can be defined

ls_subscriber-label = text-001.

* the position within the tabstrib can be defined

ls_subscriber-position = 13.

* the height of the screen can be defined here. Currently we suport two screen sizes:

* value <= 7 a sevel line subscreen

* value > 7 a 16 line subscreen

ls_subscriber-height = 7.

APPEND ls_subscriber TO re_subscribers.

Here, parameter 'im_element' is defined as 'HEADER' as we are adding new tab in header section of PO. 

Define a function group and take the main program and define it in ls_subscriber-program.

Also define a sub screen with the required fields and assign it to the parameter ls_subscriber-dynpro.  

Then method MAP_DYNPRO_FIELDS  

FIELD-SYMBOLS: <mapping> LIKE LINE OF ch_mapping.

LOOP AT ch_mapping ASSIGNING <mapping>.

CASE <mapping>-fieldname.

WHEN 'ZZPAYMENT_AGRE'. <mapping>-metafield = mmmfd_cust_03.

WHEN 'ZZPROJECT'. <mapping>-metafield = mmmfd_cust_04.

ENDCASE.

ENDLOOP.  

TRANSPORT_FROM_MODEL:

DATA: l_header TYPE REF TO if_purchase_order_mm,

ls_mepoheader TYPE mepoheader,

ls_customer TYPE CI_EKKODB.

*--------------------------------------------------------------------*

* system asks to transport data from the business logic into the view

*--------------------------------------------------------------------*

CASE im_name.

WHEN subscreen1.

* is it an Header? im_model can be header or item.

mmpur_dynamic_cast l_header im_model.

CHECK NOT l_header IS INITIAL.

* transport standard fields

ls_mepoheader = l_header->get_data( ).

* store info for later use

MOVE-CORRESPONDING ls_mepoheader TO dynp_data_pbo.

WHEN OTHERS.

* ...

ENDCASE.    

TRANSPORT_TO_DYNP:

Define a FM 'ZK_KAU86037_PUSH' to push the values.

CASE im_name.

WHEN subscreen1.

CALL FUNCTION 'ZK_KAU86037_PUSH'

EXPORTING

im_dynp_data = dynp_data_pbo.

WHEN OTHERS.

ENDCASE.    

TRANSPORT_FROM_DYNP:

Define another FM 'ZK_KAU86037_POP'.

CASE im_name.

WHEN subscreen1.

CALL FUNCTION 'ZK_KAU86037_POP'

IMPORTING

ex_dynp_data = dynp_data_pai.

IF dynp_data_pai NE dynp_data_pbo.

* something has changed therefore we have to notify the framework

* to transport data to the model

re_changed = mmpur_yes.

ENDIF.

WHEN OTHERS.

ENDCASE.  

TRANSPORT_TO_MODEL:     

DATA: l_header TYPE REF TO if_purchase_order_mm,

ls_mepoheader TYPE mepoheader,

ls_customer TYPE CI_EKKODB,

l_po_header_handle TYPE REF TO cl_po_header_handle_mm.

*--------------------------------------------------------------------*

* data have to be transported to business logic

*--------------------------------------------------------------------*

CASE im_name.

WHEN subscreen1.

* is it an item? im_model can be header or item.

mmpur_dynamic_cast l_header im_model.

CHECK NOT l_header IS INITIAL.

ls_mepoheader = l_header->get_data( ).

* standard fields changed?

IF dynp_data_pbo-zzpayment_agre NE dynp_data_pai-zzpayment_agre

OR dynp_data_pbo-zzproject NE dynp_data_pai-zzproject.

* update standard fields

ls_mepoheader-zzpayment_agre = dynp_data_pai-zzpayment_agre.

ls_mepoheader-zzproject = dynp_data_pai-zzproject.

CALL METHOD l_header->set_data

EXPORTING

im_data = ls_mepoheader.

ENDIF.

WHEN OTHERS.

ENDCASE.  

Then we have to implement one more BADI to display the tab and update the values.

Implement the BADI ME_PROCESS_PO_CUST. This cannot be used multiple times.  

In this, we have methods (PROCESS_HEADER,PROCESS_ITEM).if we need to any validations for the fields we can write the logic here in this methods. In my case I need to check for the document type which I implemented in the method (PROCESS_HEADER).  

FIELDSELECTION_HEADER: I have implemented this method as my requirement is to show the fields for particular document types only.  

Final output:  

 

  评论这张
 
阅读(1576)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017