You are on page 1of 24

Create a map using Oracle XML Gateway Message Designer

POSTED BY ABHIJIT RAY MARCH 25, 2012 16 COMMENTS FILED UNDER DATA DEFINITION, DTD, ELEMENT MAPPING, LEVEL MAPPING, TRANSACTION MAP, XML MESSAGE DESIGNER

Oracle XML Gateway Message Designer is a tool to generate a map file between 2 data structures. The 2 data structures would be a Source and a Target structure. This map will be used within Oracle XML Gateway interfaces and XML Gateway will match the source data it receives with the source data structure provided in the map file. If the source data structure matches with the map source data structure only then XML Gateway commences transforming the file, also defined in the map file, and then XML Gateway comes out with the Target data based on the Target data structure.

Create Database objects

Create a table in Oracle database 1 2 3 4 5 6 7 8 9


CREATE TABLE xx_data ( xxnum VARCHAR2(10), xxtitle VARCHAR2(20), buyerid VARCHAR2(20), buyername VARCHAR2(20), itemnum VARCHAR2(10), itemqty VARCHAR2(10) );

Create a view on top of this table to be used by XML Gateway 1 2 3 4


CREATE VIEW xx_data_v AS SELECT * FROM xx_data

Note: XML Gateway Message Designer is unable to see tables. It can detect views and hence we created a view with the same structure on top of the table.

Create data definition

Open XML Gateway message designer.

Click File > New > Data Definition

Enter Data definition name and description. Select Data Definition type Database

Create a new data definition

Click Next

Enter database details

Enter connectivity details and click Next

Select the view

Select the view XX_DATA_V. Note that the table XX_DATA is not visible to XML Gateway Message Designer.

View selected

Click on the right button to select the view. Click Next.

Select all columns of the view

Select all the columns and click on the right button. Click on Next

Select levels

Select view to form levels. Click Next.

Data definition created

Click on Finish.

Created data definiton

Now the Data definition is created from the view.

Save the data definition by clicking on File > Save

We have now created the source data definition. This means that we have defined the data structure of the XML file that will be sent to the Oracle Applications.

Create a transaction map

Click on File > New > Transaction Map. The mapping wizard opens up.

Wizard started

Click Next.

Enter map name

Enter Map name and description. Click Next

Select existing data definition

We can take the data definition created earlier as the source definition. Instead we shall use an existing DTD for the source XML data as the input to XML Gateway. Hence we shall select new source data definition.

Select option

Click next.

Enter definition name

Enter the source data definition name and description. Select the data definition type as XML. Click Next.

Select DTD created earlier

Select the DTD from your local computer. Enter the required details. We got the run time location of the DTD from Oracle. Click Next.

Select create data definition

For target data definition, we shall create a new one from the database. It will be the same structure as the database table so that the data can be easily inserted. Click Next.

Define target definition

Enter details and click Next.

Enter database details

Enter database connectivity details. Click Next.

Select view

Select the view XX_DATA_V and click Next

Select columns

Select all columns and click Next

Select level

Select level. Click Next.

Finish the wizard

Click Finish. The wizard will exit and the TransactionMap window will open up.

TransactionMap window

Check the source and target definitions. The ItemType on the field level should be properly identified or the mapping will be incorrect.

Correct ItemType

You can see that the node ITEM and DATA have been identified as Elements. You need to change the ItemType value to Level.

ItemType value changed

Check the Target Definition tab.

Target definition tab

The Target definition looks ok as the Level shows on the correct fields. Click on Level Mapping tab to map the nodes.

Level Mapping tab

Drag and drop the nodes Data and Item on XX_DATA_V.

Levels mapped

Now the levels are mapped. In other words the nodes have been mapped. We shall now map the elements contained in the nodes. Click on Element Mapping to map the individual elements.

Element mapping tab

Drag and drop XX_DATA_V from XX_DAT to XX_DATA_V on XX_TARGET to map the levels. Click on Element Mapping. Drag and drop all the fields from the left on to the corresponding fields on the right.

All elements mapped

Let us add some logic into the field BUYERID so that the source value is always added with 10 when it goes to the target. Right click on BUYERID field on the Target and click on Actions.

Available actions

Select the Add function. Select the BUYERID from the Source and add 10 to it. Click OK. Now we need to ensure that the Target data definition enters the data into the database. Right click the Target node, XX_DATA_V, and select Actions. This node corresponds to the database. table/view.

Select database function In the Post Process tab, select Insert Into Database Table. Click ok. Now the data is inserted into the database but XML Gateway does not implicitly commit the data. We have to add this also. Right click on the root node of Target, i.e. TARGET_DEFN, and select Actions.

Execute Procedure selected Select Execute Procedure. Select Assign Parameter Value.

Enter database details

Enter the database details and the procedure name. We have created the procedure, XX_COMMIT, to perform the COMMIT on the data. Click OK on both forms to close. Save the mapping as XX_DAT.xgm.

Your mapping file is now ready.

Load the DTD and the map into the database

The source DTD is,


<!ELEMENT SRC_DATA (DATA, ITEM+)>

1
BUYERID)>

2
PCDATA)>

3
PCDATA)>

4
BUYERID (#PCDATA)>

5
ITEMNUM+, ITEMQTY+)>

6 7 8

ITEMNUM (#PCDATA)> ITEMQTY (#PCDATA)>

Let us load the source DTD into the database,

FTP the xgm file and the source dtd file to Unix. Load the xgm file into the XML Gateway repository using the following command, 1
java oracle.apps.ecx.loader.LoadMap apps appspwd eyepdbg1:1522:PREPATCH xx_map.xgm

appspwd is the apps database password

eyepdbg1 is the server name

1522 is the database port

PREPATCH is the database SID

Load the map file

You will find a log file named, loader.log. Open the file in vi editor in Unis and the log file will look like the following,

Log details in loader.log file

The log file is given below


************************************************ Wed Feb 15 16:27:32 GMT+04:00 2012

1 2

Database Connect String eyepdbg1:1522:PREPATCH

3
UserName apps

4
Connecting...

5
connected.

6
Installed XML Gateway Version: 2.6.0.0

7
Started Processing of the Document

8
Processing Instructions for xmlGateway=> MAP

9 10 11

Map Code : XX_MAP Using Old Map id : 261 Following No.of rows removed for the Map ========================================

12 13 14 15 16 17 18

2 row(s) deleted from ECX_LEVEL_MAPPINGS 6 row(s) deleted from ECX_ATTRIBUTE_MAPPINGS 1 row(s) deleted from ECX_MAPPINGS 3 row(s) deleted from ECX_TRAN_STAGE_DATA 16 row(s) deleted from ECX_OBJECT_ATTRIBUTES 0 row(s) deleted from ECX_PROC_MAPPINGS 2 row(s) deleted from ECX_OBJECTS 4 row(s) deleted from ECX_OBJECT_LEVELS

19
Following No. of rows Inserted for the Map

20
==========================================

21
2 row(s) Processed for ECX_LEVEL_MAPPINGS

22
6 row(s) Processed for ECX_ATTRIBUTE_MAPPINGS

23
1 row(s) Processed for ECX_MAPPINGS

24
3 row(s) Processed for ECX_TRAN_STAGE_DATA

25 26 27 28 29 30 31

16 row(s) Processed for ECX_OBJECT_ATTRIBUTES 0 row(s) Processed for ECX_PROC_MAPPINGS 2 row(s) Processed for ECX_OBJECTS 4 row(s) Processed for ECX_OBJECT_LEVELS Finished Processing the Document

This means that the mapping file has been loaded successfully.

Let us now load the dtd file 1


java oracle.apps.ecx.loader.LoadDTDToClob apps appspwd eyepdbg1:1522:PREPATCH src_dat.dtd SRC_DATA ecx/oag62

SRC_DATA is the root element of the DTD and ecx/oag62 is the location

Check the loader.log file again and at the end of the log file you will see,

Details in loader.log file

This means the DTD has also been loaded properly.

Now we shall create a procedure XX_COMMIT (that had been called in the map file creation) to commit any transaction coming through XML Gateway into the database as XML Gateway does not implicitly commit. 1 2 3 4
create or replace procedure XX_COMMIT is begin commit; end;

The map file is now ready to be used by XML Gateway. You just need to configure Oracle Apps to use this map file . This configuration has been discussed in the next article.