Create A Map Using Oracle XML Gateway Message Part-3
Create A Map Using Oracle XML Gateway Message Part-3
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.
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.
Enter Data definition name and description. Select Data Definition type Database
Click Next
Select the view XX_DATA_V. Note that the table XX_DATA is not visible to XML Gateway Message Designer.
View selected
Select all the columns and click on the right button. Click on Next
Select levels
Click on Finish.
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.
Click on File > New > Transaction Map. The mapping wizard opens up.
Wizard started
Click Next.
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 the source data definition name and description. Select the data definition type as XML. Click Next.
Select the DTD from your local computer. Enter the required details. We got the run time location of the DTD from Oracle. Click Next.
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.
Select view
Select columns
Select level
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.
The Target definition looks ok as the Level shows on the correct fields. Click on Level Mapping tab to map the nodes.
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.
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.
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 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.
1
BUYERID)>
2
PCDATA)>
3
PCDATA)>
4
BUYERID (#PCDATA)>
5
ITEMNUM+, ITEMQTY+)>
6 7 8
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
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,
1 2
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.
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,
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.