14
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 SMT (Service Mapping Tool) Applies to: This document applies to SAP versions ECC 6.0. For more information, visit the ABAP homepage . Summary This article contains the guidelines for using the SMT (Service mapping Tool) Mapping. Main purpose this is data mapping in interfaces. Through SMT Mapping we can simply map fields in an input structure to output structure. It will reduce the coding and enhance the performance of the code Author: Prasanth.P Company: Applexus Software Solutions (P) Ltd Created on: 10 March 2011 Author Bio Prasanth P is working as SAP ABAP HR with Applexus Software Solutions (P) Ltd. He is having expertise in various Implementation, Support and Rollout Projects across various countries.

SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

Embed Size (px)

Citation preview

Page 1: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 1

SMT (Service Mapping Tool)

Applies to:

This document applies to SAP versions ECC 6.0. For more information, visit the ABAP homepage.

Summary

This article contains the guidelines for using the SMT (Service mapping Tool) Mapping. Main purpose this is data mapping in interfaces. Through SMT Mapping we can simply map fields in an input structure to output structure. It will reduce the coding and enhance the performance of the code

Author: Prasanth.P

Company: Applexus Software Solutions (P) Ltd

Created on: 10 March 2011

Author Bio

Prasanth P is working as SAP ABAP HR with Applexus Software Solutions (P) Ltd. He is having expertise in various Implementation, Support and Rollout Projects across various countries.

Page 2: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 2

Table of Contents

Introduction ......................................................................................................................................................... 3

Creating Package Groups ............................................................................................................................... 3

Assigning Packages ........................................................................................................................................ 4

Create Mapping .................................................................................................................................................. 6

Create Mapping Steps .................................................................................................................................... 7

Using SMT Mapping in Code ............................................................................................................................ 12

Initialize smt engine ....................................................................................................................................... 12

Map data ....................................................................................................................................................... 12

Related Content ................................................................................................................................................ 13

Disclaimer and Liability Notice .......................................................................................................................... 14

Page 3: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 3

Introduction

SMT Mapping we can do through the transaction code SMT. Before doing the mapping we need to create a package group. This created package group we want to specify while creating the mapping. In the creation of mapping we need to specify each mapping as mapping steps. The SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field transformations, complex transformations and field checks. Possible applications of the tool include: preparation of data for further actions, conversions of Enterprise Service data to an SAP-internal format, and vice versa. The SMT supports specific requirements for service implementations, such as extended XML handling or field checks. The SMT executes standard mappings before extensions. Any checks that you have activated for overwriting fields are never active for extensions.

Creating Package Groups

SMT – Menu

Page 4: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 4

Select the menu item ‟ define package groups‟

Check the package group whether it is exists already

If does not exists, press new entries button and create a new package group

Assigning Packages

In the Tree Menu Select the package group and double click on packages

Page 5: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 5

Click „new entries‟ and give the packages name in the table control

Enter 'GMT_TRANSFORMATION' (Mandatory) and also enter your custom created package

Press save button

Package group creation was completed

Page 6: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 6

Create Mapping

Click the second option “Create and edit mappings”

Now the web dynpro screen opens

Please enter the Mapping name, description , Package group and press enter button

Page 7: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 7

Create Mapping Steps

Now we need to define mapping steps

Enter mapping step name,description,source ,target structures and press enter button

Select the mapping step and press the details button in the table control

Page 8: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 8

Please select the mapping transformations tab

Please select the field mapping record in the table control

Page 9: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 9

Now the source and target structure with fields are displayed on the screen

Select the fields which we have to map and press map button

Page 10: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 10

Do the above step for all fields which we want to map

And finally press the close button then it will show save dialogue, save the mapping and exit

Page 11: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 11

Press the save button of mapping steps screen

Page 12: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 12

Using SMT Mapping in Code

Refer the below while writing SMT code in the program

Step 1: first it will initialize smt engine

Step2: Then it will map the source to target

DATA: lo_smt_wcdvl_data TYPE REF TO cl_smt_engine,

lx_smt_error TYPE REF TO cx_smt_error,

lo_smt_protocol TYPE REF TO cl_smt_protocol.

Initialize smt engine

TRY.

CREATE OBJECT lo_smt_wcdvl_data

EXPORTING

i_mapping = zcl_constants_58693=>c_mapping_name1

i_mapping_step = zcl_constants_58693=>c_mapping_step1

i_context = space

i_extended_xml_handling = abap_true

i_with_prefetch = abap_false.

CATCH cx_smt_error INTO lx_smt_error.

lo_smt_protocol = lx_smt_error->a_protocol.

CALL METHOD lo_smt_protocol->get_messages_as_bapiret

IMPORTING

et_message = lt_message.

APPEND LINES OF lt_message TO et_return.

RAISE EXCEPTION TYPE cx_sapplco_standard_msg_fault.

ENDTRY.

Map data

TRY.

LOOP AT ls_input-create_well_completion_volume-well_completion_volume ASSIGNING

<ls_input>.

CLEAR ls_data_out.

CALL METHOD lo_smt_wcdvl_data->execute

EXPORTING

i_source = <ls_input>

CHANGING

ch_target = ls_data_out.

APPEND ls_data_out TO et_data_out.

ENDLOOP.

CATCH cx_smt_error INTO lx_smt_error.

lo_smt_protocol = lx_smt_error->a_protocol.

CALL METHOD lo_smt_protocol->get_messages_as_bapiret

IMPORTING

et_message = lt_message.

APPEND LINES OF lt_message TO et_return.

RAISE EXCEPTION TYPE cx_sapplco_standard_msg_fault.

ENDTRY.

Page 13: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 13

Related Content

Service Mapping Tool (SMT)

Insurance Claim Handling 3

For more information, visit the ABAP homepage

Page 14: SMT (Service Mapping Tool) SMT is a program that enables you to fill target structures by using sets of source structures (in ABAP). It supports: simple mappings, mappings with field

SMT (Service Mapping Tool)

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG 14

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.