Mapping Constants (Runtime)SAP-XI/PI · PDF fileMapping Constants (Runtime) SAP-XI/PI ... The mapping runtime saves the fields as key-value pairs. Mapping API provides string constants
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
This article talks about how to access mapping constant in different mapping programs during runtime (Message, java, xslt mappings), this is applicable to SAP-XI/PI versions 7.0 or 7.1 or 7.3. For more information, visit the SOA Management homepage.
Summary
Mapping programs can access mapping runtime constants; mapping constants are available in message header. The mapping runtime saves the fields as key-value pairs. Mapping API provides string constants to access mapping runtime constants.
Author: Prasad Babu Nemalikanti
Company: Mahindra Satyam
Created on: 26 July 2011
Author Bio
Prasad Babu Nemalikanti, SAP-XI/PI certified consultant has more than 7 years of SAP experience including ,SAP-XI/PI,SAP-MDM, BIW and has good knowledge in ABAP, ALE and Java (certified).Currently working as a Team Lead in Mahindra Satyam prior to this associated with Fujitsu
Global Container Object: .............................................................................................................................................. 4
3. Accessing Mapping Constants by XSLT Mapping .................................................................................... 10
Related Content ................................................................................................................................................ 15
Disclaimer and Liability Notice .......................................................................................................................... 16
Mapping Constants (Runtime) SAP-XI/PI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
Sometimes it may be necessary to access fields in message header (mapping runtime constants) into mapping programs. The mapping constants are saved as key-value pairs. When we use keys to access mapping constants, if keys are changed then the mappings could be invalid. So there are mapping constants are provided to access the mapping constants.
This article describes the accessing of mapping runtime constants from message mapping, and from java mapping with both APIs (AbstractTransformation, StreamTrasformation) and from xslt mapping.
Accessing mapping constants in message mapping can be done in two ways; By “Container” object (“getTransformationParameters” method) and by “GlobalContainer” object (“getParameters” method).
Container Object:
public String messageid(Container container) throws StreamTransformationException
Java mapping can access mapping runtime constants through two different APIs (Netweaver 2004 and 7.0, Netweaver 7.1)
a) Java mapping with “AbstractTransformation” (abstract class)
b) Java mapping with “StreamTrasformationConstants” and “Map” object (interface)
Note: Here Java mapping is pretty simple; we must have seen similar kind of mapping programs in couple of places.
Here the point is accessing mapping constant with help of both available APIs.
Java Code (AbstractTransformation)
There are two classes “InputHeaer” and “OutputHeader” for read and write access of mapping constants. InputHeader to read from header fields of the source message.OutputHeader to set target Header fields.
Note: String message=in.getInputHeader().getMessageID() ; String receiver=in.getInputHeader().getInterface(); String namespace=in.getInputHeader().getInterfaceNamespace(); Likewise there are methods available for all mapping constants.
XSLT mapping can access the mapping runtime constants, but it needs Java archive which implements Java mapping APIs.XSLT mapping requires java mapping APIs (AbstractTransformation or StreamTransformation) to access the mapping runtime constants.
There is no need of java mapping, but it just needs a java class which implements either “AbstractTransformation” or use “StreamTransformationConstants”.
So there are two ways that the java methods can access mapping runtime constants.
1. “AbstractTransformation”: - When “AbstractTransformation” is used by XSLT mapping to get mapping constants, “transform” method must be overridden. There is no mapping logic in the “transform” method; just it has a single line which accesses the MessageID.
Mapping Constants (Runtime) SAP-XI/PI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2.”StreamTransformationConstants”:- XSLT mapping can access mapping constants by triggering java method which uses “StreamTransformationConstants” and “Map” object. This is another way to access mapping constants into xslt mappining program during runtime.
Note: To access Mapping runtime constants into xslt mapping, prior java mapping is not required. Whereas java archive (user defined class) is required to access mapping constants with help of “AbstractTransformation” or “StreamTrasformationConstants” and Map object
Mapping Constants (Runtime) SAP-XI/PI
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
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.