Class com.sap.basis.ukm.GetKeyMapping

The class provides methods for reading key mappings using RFC function module UKM_GET_KEYMAPPINGS. Both single and mass access is supported.

The namespace extensions for the classes of the unified key mapping that are used are declared in the header of the xslt transformation. A GetKeyMapping instance for the required key store is created in the global part of the transformation and stored in a reference variable $ref. Of course the variable can be renamed.

The required mappings are defined in the template with Identifier instances and passed to the GetKeyMapping instance referenced with $ref with method addMapping(). With method getResults(), the flagged mapping requests are executed and the results are passed. They are provided as xml fragment and stored in variable $result. The xslt context must be restored before the first access.

 A complete coding example for querying a key mapping is given below.

<?xml version="1.0" encoding="UTF-8" ?>
 <xsl:transform version="1.1"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:Identifier="java:com.sap.basis.ukm.Identifier"
         xmlns:GetKeyMapping="java:com.sap.basis.ukm.GetKeyMapping">

 <xsl:param name="mappingTrace"/>

 !-- Get a reference to the default key store -->
 <xsl:variable name="ref" select="GetKeyMapping:new($MappingTrace)"/>
 <xsl:template match="/">

 <!-- Create source key -->
 <xsl:variable name="sourceID"
       select="Identifier:new('PartnerGUID', 'QM3_300', 'B123')"/>

  <!-- Create incomplete target key -->
  <xsl:variable name="targetID"
       select="Identifier:new('CustomerID', 'EU3_003')"/>

  <!-- Add mapping request  -->
 <xsl:variable name="void"
       select="GetKeyMapping:addMapping($ref, 'BUS1006',
                                        $sourceID, $targetID)"/>

 <!-- Execute the pending keymapping calls and get the messages -->
 <xsl:variable name="result" select="GetKeyMapping:getResult($ref)"/>

 <!-- Always restore context after calling an extension function -->
 <xsl:for-each select="$result"/>

 <!-- Output messages of the call -->
 <xsl:copy-of select="$result"/>

 </xsl:template>
 </xsl:transform>

 

If such a key mapping with result 'B456' is defined, the results of this call will be:

<MappingResult>

   <Mapping mainContextID="BUS1006">
     <SourceID schemeID="PartnerGUID" clientDefault="" schemeVersionID=""
               schemeAgencyID="QM3_300" schemeAgencySchemeID=""
               schemeAgencySchemeAgencyID="ZZZ">B123</SourceID>
     <TargetID schemeID="CustomerID" clientDefault="X" schemeVersionID=""
               schemeAgencyID="EU3_003" schemeAgencySchemeID=""
               schemeAgencySchemeAgencyID="ZZZ">B456</TargetID>
   </Mapping>

 </MappingResult>

 

If no such key exists, the results of the call are as follows:

<MappingResult>

   <Mapping mainContextID="BUS1006">
     <SourceID schemeID="PartnerGUID" clientDefault="" schemeVersionID=""
               schemeAgencyID="QM3_300" schemeAgencySchemeID=""
               schemeAgencySchemeAgencyID="ZZZ">B123</SourceID>
     <TargetID schemeID="CustomerID" clientDefault="X" schemeVersionID=""
               schemeAgencyID="EU3_003" schemeAgencySchemeID=""
               schemeAgencySchemeAgencyID="ZZZ"/>

   </Mapping>

 </MappingResult>