Upload
ngohanh
View
229
Download
5
Embed Size (px)
Citation preview
SAP
How-To Guide
Master Data Governance
for Material
How To...
Master Data Governance for Material
Extend Model with Complex
Backend Data (e.g. MLAN)
Applicable Releases:
EhP5, EhP6
Version 1.1
July 2012
© Copyright 2012 SAP AG. All rights reserved.
No part of this publication may be reproduced or
transmitted in any form or for any purpose without the
express permission of SAP AG. The information contained
herein may be changed without prior notice.
Some software products marketed by SAP AG and its
distributors contain proprietary software components of
other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are
registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel
Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390,
OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP,
Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix,
i5/OS, POWER, POWER5, OpenPower and PowerPC are
trademarks or registered trademarks of IBM Corporation.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader
are either trademarks or registered trademarks of Adobe
Systems Incorporated in the United States and/or other
countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered
trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame,
WinFrame, VideoFrame, and MultiWin are trademarks or
registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or
registered trademarks of W3C®, World Wide Web
Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems,
Inc., used under license for technology invented and
implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP
NetWeaver, and other SAP products and services
mentioned herein as well as their respective logos are
trademarks or registered trademarks of SAP AG in
Germany and in several other countries all over the world.
All other product and service names mentioned are the
trademarks of their respective companies. Data contained
in this document serves informational purposes only.
National product specifications may vary.
These materials are subject to change without notice.
These materials are provided by SAP AG and its affiliated
companies ("SAP Group") for informational purposes only,
without representation or warranty of any kind, and SAP
Group shall not be liable for errors or omissions with
respect to the materials. The only warranties for SAP
Group products and services are those that are set forth in
the express warranty statements accompanying such
products and services, if any. Nothing herein should be
construed as constituting an additional warranty.
These materials are provided “as is” without a warranty of
any kind, either express or implied, including but not
limited to, the implied warranties of merchantability,
fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including
without limitation direct, special, indirect, or consequential
damages that may result from the use of these materials.
SAP does not warrant the accuracy or completeness of the
information, text, graphics, links or other items contained
within these materials. SAP has no control over the
information that you may access through the use of hot
links contained in these materials and does not endorse
your use of third party web pages nor provide any warranty
whatsoever relating to third party web pages.
SAP NetWeaver “How-to” Guides are intended to simplify
the product implementation. While specific product
features and procedures typically are explained in a
practical business context, it is not implied that those
features and procedures are the only approach in solving a
specific business problem using SAP NetWeaver. Should
you wish to receive additional information, clarification or
support, please refer to SAP Consulting.
Any software coding and/or code lines / strings (“Code”)
included in this documentation are only examples and are
not intended to be used in a productive system
environment. The Code is only intended better explain and
visualize the syntax and phrasing rules of certain coding.
SAP does not warrant the correctness and completeness of
the Code given herein, and SAP shall not be liable for
errors or damages caused by the usage of the Code, except
if such damages were caused by SAP intentionally or
grossly negligent.
Disclaimer
Some components of this product are based on Java™. Any
code change in these components may cause unpredictable
and severe malfunctions and is therefore expressively
prohibited, as is any decompilation of these components.
Any Java™ Source Code delivered with this product is only
to be used by SAP’s Support Services and may not be
modified or altered in any way.
Document History
Document Version Description
1.00 First official release of this guide
1.10 Also relevant for EhP6
Typographic Conventions
Type Style Description
Example Text Words or characters quoted
from the screen. These
include field names, screen
titles, pushbuttons labels,
menu names, menu paths,
and menu options.
Cross-references to other
documentation
Example text Emphasized words or
phrases in body text, graphic
titles, and table titles
Example text File and directory names and
their paths, messages,
names of variables and
parameters, source text, and
names of installation,
upgrade and database tools.
Example text User entry texts. These are
words or characters that you
enter in the system exactly as
they appear in the
documentation.
<Example
text>
Variable user entry. Angle
brackets indicate that you
replace these words and
characters with appropriate
entries to make entries in the
system.
EXAMPLE TEXT Keys on the keyboard, for
example, F2 or ENTER.
Icons
Icon Description
Caution
Note or Important
Example
Recommendation or Tip
Table of Contents
1. Business Scenario............................................................................................................... 1
2. Background Information ..................................................................................................... 1
3. Prerequisites ........................................................................................................................ 1
4. Concept pattern ................................................................................................................... 2
5. Step-by-Step Procedure for example Tax classification ................................................. 3
5.1 Overview ....................................................................................................................... 3
5.2 Value Tables ................................................................................................................. 3
5.2.1 Tax Rate Type (corresponding to TSKM) ........................................................ 3
5.2.2 Tax Type (corresponding to TSTL) .................................................................. 4
5.2.3 Model MM ........................................................................................................ 5
5.2.4 Relation ............................................................................................................ 5
5.2.5 UI Configuration ............................................................................................... 6
5.3 UI BAdI ......................................................................................................................... 7
5.3.1 Enhancement Spot USMD_UI_EVENT2 ......................................................... 7
5.3.1.1 Create new BAdI Implementation
ZIB_MAT_UI_BADI ...................................................... 7
5.3.1.2 Implement new Implementing Class
ZCL_IB_MAT_UI_BADI and Method
IF_EX_USMD_UI_EVENT2~MODIFY_VIEW ............. 7
5.3.1.3 Implement METHOD
zcl_mdg_bs_mat_salestax_aux=>modify_view ........... 8
5.3.2 Example coding for Method modify_view ........................................................ 8
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 1
1. Business Scenario
SAP Master Data Governance for Material (MDG-M) provides business processes to find, create,
change, and mark material master data for deletion. It supports governance of material master data on
a central hub and distribution of material master data to connected operational and business
intelligence systems.
The processes are workflow-driven and can include several approval and revision phases, including
collaboration between all users participating in master data maintenance.
In EhP5/6 MDG-M addresses only descriptive data for the Material but it is possible to extend the data
model. This guide describes how to extend the preconfigured content of Master Data Governance for
Material, contained in the data model MM, with the example ‘Tax Data’.
2. Background Information
There are different possible scenarios for extending the standard MDG Material data model (MM):
a. Extend by existing attributes (from reuse):
Extend the MDGM data model by adding a pre-delivered SAP ERP material master database
field to an MDGM entity as an attribute.
b. Extend by custom attributes (from reuse):
Extend the data model by adding customer defined fields that already exist.
c. Extend by existing entity (from reuse):
Extend the data model by adding an existing entity type.
d. Extend by custom entity (from reuse):
Extend the data model by adding customer-defined entity types that already exist.
e. Extend by existing entity (based on Flex):
The standard data model is extended with a new, flexible entity (as in scenario d) but the data
for this resides not in the SAP ERP database tables but in the MDG generated tables.
For all the scenarios mentioned above, you have to enhance the standard data model either by
additional attributes or additional entities.
In this guide, we extend the model to include the entity type corresponding to MLAN. To include the
MVKE (Sales Data) you can use the Extensibility Guide, chapter ‘Extend by existing entity from reuse’.
There is additional work required to include the tax data into the MM model. For example, you need to
derive the countries and tax types from the distribution chains.
3. Prerequisites
Due to complex value range tables in the backend, it’s not possible to model attributes/type 3 entities
for certain fields (for example MLAN, MARC-PRCTR …). Root cause is that value range tables have
additional key fields that can’t be modeled in the MDG-M data model.
For example: You have already extended your model with a new entity and attributes for MVKE (Sales
Data). You want to add tax classification data (table MLAN). The attributes of the MLAN table have
complex value range tables.
More information
Documentation for MDG:
http://help.sap.com/erp2005_ehp_06/helpdata/de/5c/f65567c37e4f83a146f9dff216db7b/frameset.htm
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 2
Enhancement of Master Data Governance Content:
EhP5: http://help.sap.com/erp2005_ehp_05/helpdata/EN/ab/05f68761744157b40f81af8689b700/frameset.htm
EhP6: http://help.sap.com/erp2005_ehp_06/helpdata/EN/ab/05f68761744157b40f81af8689b700/frameset.htm
MDG Extensibility Guide’s:
http://scn.sap.com/docs/DOC-7858
4. Concept pattern
As it is not possible to reuse the data elements/domains/value range tables from the reuse area, you
need to create MDG-M specific copies of these object.
You then need to remove/replace all key fields that can’t be modeled in MDG-M.
Based on these copies, it’s then possible to create attributes or entities of type 3.
This implies double maintenance for the content of the value range table. Bear in mind that only a
subset of the data can be copied, as the copied value range table has less key fields than the original
table.
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 3
5. Step-by-Step Procedure for example Tax
classification
5.1 Overview
You want to maintain the sales tax data in MDG-M. You have to extend the model, the UI, and code a
BAdI. This solution supports also more than one tax types per country.
5.2 Value Tables
The backend tables T685/TSTL/TSKM can’t be used to define Type 3 entities for tax data. Therefore
create new data elements, domains, and value range tables to have the customizing data available in
MDG model.
This means double maintenance of data in tables TSTL/TSKM. The data must be maintained also in
the new Z-tables.
5.2.1 Tax Rate Type (corresponding to TSKM)
Copy TSKM. Example:
TSKM ZIB_TSKM
Derive every TALAND
for the given TATYP
via TSTL
TALND
TATYP TATYP
TAXKM TAXKM
Note: One table entry in TSKM maps to one or more table entries in ZIB_TSKM
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 4
5.2.2 Tax Type (corresponding to TSTL)
Copy TSTL, but delete LFDNR, STPRZ and make TATYP key. Example:
TSTL ZIB_TSTL_TAB
TALAND TALND
LFDNR -
TATYP TATYP
STPRZ -
Note: One table entry in TSTL maps to exactly one table entry in ZIB_TSTL_TAB
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 5
5.2.3 Model MM
Enhance the model with new Entities:
5.2.4 Relation
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 6
5.2.5 UI Configuration
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 7
5.3 UI BAdI
5.3.1 Enhancement Spot USMD_UI_EVENT2
5.3.1.1 Create new BAdI Implementation ZIB_MAT_UI_BADI
5.3.1.2 Implement new Implementing Class ZCL_IB_MAT_UI_BADI
and Method IF_EX_USMD_UI_EVENT2~MODIFY_VIEW
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 8
5.3.1.3 Implement METHOD
zcl_mdg_bs_mat_salestax_aux=>modify_view
….
5.3.2 Example coding for Method modify_view
METHOD modify_view.
* Add the still unmaintained sales taxes (country and tax type):
* - Read the distribution chains for this material
* - With the distribution chains, derive the countries and tax types
* - Check which countries / tax types are not yet maintained for the material
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 9
* - Add them
* Note: Doesn't remove countries / tax types if a distribution chain was removed
* so as not to loose any tax classification data the customer has maintained
* -> These will be dropped on activation anyway
TYPES: BEGIN OF ty_dchain,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
END OF ty_dchain.
TYPES: BEGIN OF ty_tax,
aland TYPE aland,
lfdnr TYPE tafol,
tatyp TYPE tatyp,
END OF ty_tax.
DATA: ls_new_sltax TYPE zxx_s_mm_pp_zem_sltax.
DATA: lr_model TYPE REF TO if_usmd_model_ext.
DATA: lr_mvke TYPE REF TO data.
DATA: lt_sel TYPE usmd_ts_sel.
DATA: ls_sel TYPE usmd_s_sel.
DATA: lv_matnr TYPE matnr.
DATA: lt_msg TYPE usmd_t_message.
DATA: ls_key_field TYPE usmd_s_value.
DATA: ls_dchain TYPE ty_dchain.
DATA: lt_dchain TYPE STANDARD TABLE OF ty_dchain.
DATA: ls_tax TYPE ty_tax.
DATA: lt_tax TYPE STANDARD TABLE OF ty_tax.
DATA: ls_tvko TYPE tvko.
DATA: lt_steuer TYPE STANDARD TABLE OF mg03steuer.
DATA: ls_steuer TYPE mg03steuer.
FIELD-SYMBOLS: <lt_sltax> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <ls_sltax> TYPE any.
FIELD-SYMBOLS: <lt_mvke> TYPE ANY TABLE.
FIELD-SYMBOLS: <ls_mvke> TYPE any.
FIELD-SYMBOLS: <data> TYPE usmd_sx_entity_data.
FIELD-SYMBOLS: <vkorg> TYPE vkorg.
FIELD-SYMBOLS: <vtweg> TYPE vtweg.
FIELD-SYMBOLS: <aland> TYPE aland.
FIELD-SYMBOLS: <tatyp> TYPE tatyp.
FIELD-SYMBOLS: <new_sltax> TYPE any.
CONSTANTS: lc_mvke TYPE usmd_fieldname VALUE 'ZCDMVKE'.
CONSTANTS: lc_vkorg TYPE usmd_fieldname VALUE 'ZCDVKORG'.
CONSTANTS: lc_vtweg TYPE usmd_fieldname VALUE 'ZCDVTWEG'.
CONSTANTS: lc_sltax TYPE usmd_entity VALUE 'ZEM_SLTAX'.
CONSTANTS: lc_ctry TYPE usmd_fieldname VALUE 'ZEM_CTRY'.
CONSTANTS: lc_tatyp TYPE usmd_fieldname VALUE 'ZEM_TATYP'.
* Add sales tax data to CT_DATA
READ TABLE ct_data ASSIGNING <data> WITH KEY entity = lc_sltax.
CHECK sy-subrc = 0.
ASSIGN <data>-r_data->* TO <lt_sltax>.
CHECK <lt_sltax> IS ASSIGNED.
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 10
* 1. Get all sales orgs from MVKE entity of this material
CALL METHOD cl_usmd_model_ext=>get_instance
EXPORTING
i_usmd_model = if_mdg_bs_mat_gen_c=>gc_model_mm
IMPORTING
eo_instance = lr_model.
CALL METHOD lr_model->create_data_reference
EXPORTING
i_fieldname = lc_mvke
i_struct = lr_model->gc_struct_key_attr "gc_struct_key
if_table = abap_true
i_tabtype = lr_model->gc_tabtype_sorted
IMPORTING
er_data = lr_mvke.
ASSIGN lr_mvke->* TO <lt_mvke>.
READ TABLE it_key_field INTO ls_key_field
WITH KEY fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material.
lv_matnr = ls_key_field-value.
ls_sel-fieldname = if_mdg_bs_mat_gen_c=>gc_fieldname_material.
ls_sel-sign = 'I'.
ls_sel-option = 'EQ'.
ls_sel-low = lv_matnr.
INSERT ls_sel INTO TABLE lt_sel.
CLEAR <lt_mvke>.
CALL METHOD lr_model->read_char_value
EXPORTING
i_fieldname = lc_mvke
it_sel = lt_sel
if_edition_logic = abap_false
i_readmode = if_usmd_model_ext=>gc_readmode_default
if_use_edtn_slice = abap_false
IMPORTING
et_data = <lt_mvke>
et_message = lt_msg.
APPEND LINES OF lt_msg TO ct_message.
* 2. get the countries and tax types (includes reading 'company code' for d
istribution chain)
LOOP AT <lt_mvke> ASSIGNING <ls_mvke>.
ASSIGN COMPONENT lc_vkorg OF STRUCTURE <ls_mvke> TO <vkorg>.
ls_dchain-vkorg = <vkorg>.
ASSIGN COMPONENT lc_vtweg OF STRUCTURE <ls_mvke> TO <vtweg>.
ls_dchain-vtweg = <vtweg>.
INSERT ls_dchain INTO TABLE lt_dchain.
ENDLOOP.
LOOP AT lt_dchain INTO ls_dchain.
CALL FUNCTION 'TVKO_SINGLE_READ'
EXPORTING
vkorg = ls_dchain-vkorg
IMPORTING
wtvko = ls_tvko
EXCEPTIONS
OTHERS = 1.
EhP5 How To... MDG-M: Extent with Tax Data (e.g. MLAN)
July 2012 11
CHECK sy-subrc = 0.
CALL FUNCTION 'STEUERTAB_IDENTIFY'
EXPORTING
vkorg = <vkorg>
bukrs_vkorg = ls_tvko-bukrs
vtweg = ls_dchain-vtweg
TABLES
steuertab = lt_steuer
EXCEPTIONS
OTHERS = 1.
CHECK sy-subrc = 0.
LOOP AT lt_steuer INTO ls_steuer.
MOVE-CORRESPONDING ls_steuer TO ls_tax.
INSERT ls_tax INTO TABLE lt_tax.
ENDLOOP.
ENDLOOP.
SORT lt_tax.
DELETE ADJACENT DUPLICATES FROM lt_tax.
* 3. Check if already in CT_DATA -> tax data exists, don't add as new row
LOOP AT <lt_sltax> ASSIGNING <ls_sltax>.
ASSIGN COMPONENT lc_ctry OF STRUCTURE <ls_sltax> TO <aland>.
ASSIGN COMPONENT lc_tatyp OF STRUCTURE <ls_sltax> TO <tatyp>.
DELETE lt_tax WHERE aland = <aland> AND tatyp = <tatyp>.
ENDLOOP.
* 4. Add the leftovers to table sltax
LOOP AT lt_tax INTO ls_tax.
INSERT INITIAL LINE INTO TABLE <lt_sltax> ASSIGNING <new_sltax>.
ls_new_sltax-material = lv_matnr.
ls_new_sltax-zem_ctry = ls_tax-aland.
ls_new_sltax-zem_tatyp = ls_tax-tatyp.
MOVE-CORRESPONDING ls_new_sltax TO <new_sltax>.
ENDLOOP.
ENDMETHOD.
www.sdn.sap.com/irj/sdn/howtoguides