PI Mapping Runtime can require external data for serveral reasons. Most common are different names for same unities in different systems. For example material classes vary often as well as names for organizations. A mapping program requires in such cases an access to a table where the values from different systems are correlated. There are quite different strategies to implement such a scenario:
Description of the scenario
The external data (correlation of different values) are stored in SAP ECC z-table. By any change of the table content an ABAP program calls a proxy, which replicates the whole table content. There wont be any performance issues if the data are not changed too often and if this are not too much data. This preconditions shouldnt be a problem in the most cases. The full table replication is much easier than a delta load and can be implemented within a few hours.
The data are replicated to Java Runtime Mapping Cache, they can be controlled from Runtime Workbench. A standard function from Message Mapping can make use of the correlated values, the Runtime performance for this sceanrio is better than for any scenario with lookup.
Suppose we have different purchase organizations in a SAP system and a third party system. We are planning to add later organizations and we might want to add another third party system in future. To exchange messages we need to map that organizations by an external table.
The mapping table is created at the SAP system (transaction SE11).
The context is individual for our mapping case (and therefore for our scenario and our third party system). The context and at least one of the mapping values should be key of the table.
The function Utilities / Table Maintenance Generator at SE11 allows to create a quick controlled table maintenance from SM30). We can choose directly a Authorization Group for a control of access. The Function Group, which later will be extended, must be in the customers namespace. From this dialog we can jump to the event handling: Environment / Modification / Events
An event can be defined in that step, for example "02 - After saving in the database", and a FORM routine what should be called if that event was raised. A own FORM should be typed in here, which will be created in the next step.
A new include needs to created in the Function Group (SE80), what was typed in at the Table Maintenance Dialog. It has to be in the customers namespace. During the activation there could popup some confusing messages which can be ignored. The include just contains the FORM routine from the last step.
With the SAP BASIS Software Component two ABAP outbound proxies were delivered (transaction SPROXY). In our example the synchronous proxy is used.
It can be used to send messages directly (as XML) to the PI Integration Engine. The view tabs are very helpful during implementation of the ABAP program (the FORM) routine. They provide an overview about the structure and by clicking on an element the type can be copied from "ABAP Name Ref.".
Source Code of FORM routine:
*&---------------------------------------------------------------------*
*& Include ZZMM_PURCH_ORGS_EVENTS
*&---------------------------------------------------------------------*
FORM f_pi_export_zzmm_purch_orgs.
*----------------------------------------------------------------------*
* DATA DECLARATION *
*----------------------------------------------------------------------*
DATA:
* error text application error
l_appl_fault_text TYPE string,
* One context for Value Mapping Replication
l_context TYPE zz_context,
*----------------------------------------------------------------------*
* STRUCTURES *
*----------------------------------------------------------------------*
* request type for proxy
lwa_output TYPE svmr_value_mapping_replication,
* reponse type for proxy
lwa_input TYPE svmr_value_mapping_rep_resp,
* one item in proxy structure
lwa_item TYPE svmr_value_mapping_rep_item,
* Line of table ZZMM_PURCH_ORGS
BEGIN OF lwa_purch_orgs,
context TYPE zz_context,
sap_purch_org TYPE vkorg,
thrd_party_org TYPE zz3rdparty_org,
END OF lwa_purch_orgs,
*----------------------------------------------------------------------*
* INTERNAL TABLES *
*----------------------------------------------------------------------*
* internal table like transparent table
lit_purch_orgs LIKE TABLE OF lwa_purch_orgs,
* context entries in transp table zzmm_purch_orgs
lit_contexts TYPE TABLE OF zz_context,
*----------------------------------------------------------------------*
* OBJECTS definitions *
*----------------------------------------------------------------------*
* standard proxy for value mapping replication (synchronous)
lo_vmr_proxy TYPE REF TO co_svmr_value_mapping_rep_sync,
* Exception class for Application Integration: Technical Error
lo_sys_fault TYPE REF TO cx_ai_system_fault,
* Exception class for Application Integration: Application Error
lo_appl_fault TYPE REF TO cx_ai_application_fault,
* Exception class for Application Errors
lo_vmr_fault TYPE REF TO cx_svmr_value_mapping_rep.
*----------------------------------------------------------------------*
* SELECTION SCREEN *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* START OF SELECTION *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Main logic *
*----------------------------------------------------------------------*
*-------------------------------------Fill container for delete operation
SELECT DISTINCT
context
FROM
zzmm_purch_orgs
INTO TABLE
lit_contexts.
LOOP AT lit_contexts INTO l_context.
lwa_item-operation = 'DeleteContext'.
lwa_item-context = l_context.
APPEND lwa_item TO lwa_output-value_mapping_replication-item.
ENDLOOP.
*------Transfer with ABAP outbound proxy via Java inbound proxy to Java Runtime Cache
CREATE OBJECT lo_vmr_proxy.
TRY.
CALL METHOD lo_vmr_proxy->execute_synchronous
EXPORTING
output = lwa_output
IMPORTING
input = lwa_input.
CATCH cx_ai_system_fault INTO lo_sys_fault.
WRITE:/ lo_sys_fault->errortext.
CATCH cx_svmr_value_mapping_rep INTO lo_vmr_fault.
WRITE:/ lo_vmr_fault->standard-fault_text.
CATCH cx_ai_application_fault INTO lo_appl_fault.
CALL METHOD lo_appl_fault->if_message~get_text
RECEIVING
result = l_appl_fault_text.
WRITE:/ l_appl_fault_text.
ENDTRY.
IF sy-subrc = 0.
WRITE:/ 'Cache was succesfully deleted with status: ', lwa_input-status.
ELSE.
WRITE:/ 'Old PI cache data could not be deleted, action cancelt'.
LEAVE PROGRAM.
ENDIF.
CLEAR: lwa_item, lwa_output.
*-------------------------------------Fill container for insert operation
lwa_item-operation = 'Insert'.
lwa_item-identifier-scheme = 'PurchaseOrg'.
* DB READ
SELECT
context
sap_purch_org
thrd_party_org
FROM
zzmm_purch_orgs
INTO TABLE
lit_purch_orgs.
IF sy-subrc <> 0.
WRITE:/ 'DB table ZZMM_PURCH_ORGS could not be read, insert to Java cache not possible.'.
LEAVE PROGRAM.
ENDIF.
LOOP AT lit_purch_orgs INTO lwa_purch_orgs.
* Context for pair of values
lwa_item-context = lwa_purch_orgs-context.
* create a guid for a pair of values
CALL FUNCTION 'ICF_CREATE_GUID'
IMPORTING
id = lwa_item-group_id.
* Insert 3rd Party org
lwa_item-identifier-agency = '3rdParty'.
lwa_item-identifier-value = lwa_purch_orgs-thrd_party_org.
APPEND lwa_item TO lwa_output-value_mapping_replication-item.
* Insert SAP org
lwa_item-identifier-agency = 'SAP'.
lwa_item-identifier-value = lwa_purch_orgs-sap_purch_org.
APPEND lwa_item TO lwa_output-value_mapping_replication-item.
ENDLOOP.
TRY.
CALL METHOD lo_vmr_proxy->execute_synchronous
EXPORTING
output = lwa_output
IMPORTING
input = lwa_input.
CATCH cx_ai_system_fault INTO lo_sys_fault.
WRITE:/ lo_sys_fault->errortext.
CATCH cx_svmr_value_mapping_rep INTO lo_vmr_fault.
WRITE:/ lo_vmr_fault->standard-fault_text.
CATCH cx_ai_application_fault INTO lo_appl_fault.
CALL METHOD lo_appl_fault->if_message~get_text
RECEIVING
result = l_appl_fault_text.
WRITE:/ l_appl_fault_text.
ENDTRY.
IF sy-subrc = 0.
WRITE:/ 'Cache was succesfully updated with status: ', lwa_input-status.
ELSE.
WRITE:/ 'New values couldnt be updated at PI'.
LEAVE PROGRAM.
ENDIF.
**----------------------------------------------------------------------*
** END OF SELECTION *
**----------------------------------------------------------------------*
*
*
ENDFORM. "f_pi_export_zzmm_purch_orgs
The Java inbound proxies on the Integration Server can easily be activated by calling a simple URL:
Asynchronous: http://:/ProxyServer/register?ns=http://sap.com/xi/XI/System&interface=ValueMappingReplication &bean=localejbs/sap.com/com.sap.xi.services/ValueMappingApplication &method=valueMappingReplication
Synchronous: http://:/ProxyServer/register?ns=http://sap.com/xi/XI/System&interface=ValueMappingReplicationSynchr... &bean=localejbs/sap.com/com.sap.xi.services/ValueMappingApplicationSynchronous &method=valueMappingReplicationSynchronous
The proxy replication can be monitored at transaction SXMB_MONI either at SAP and at PI. The values are available at Runtime Workbench / Cache Monitoring / Cache Instance: Mapping Runtime Cache, CAche Object: Value Mapping Groups
Value Mappings can maintained with standard function "Value Mapping". The context must be typed in, as well the Schema ("PurchaseOrg" for our example). The organizations are mapped by the typed in values for source and target agency. The behaviour regarding exceptions of the function can be maintained: Source value, default value or runtime exception
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
11 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 |