cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Lookup

Former Member
0 Kudos

How to do a jdbc lookup based on a string in the Sender file name?.

For example Sender file name is NYC1010st.csv and CAL2010st.csv

I need to determne dynamically to go to different systems to get data. If NYC then call to System X , If CAL call another system to get data.

My scenario is MATMAS --> XI ---> FTP. Within XI I need to do jdbc look up based on above criteria.

Thanks for any siggestions and help and is appreciated.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ram,

You need find out the filename as mentioned by Michal and once you have the file name information you can use that in a condition to determine the Communication channel to be used for JDBC lookup.

Step 1: Define two communication channels in ID for different DB systems.

Step 2: Get the File name in UDF using the following code


DynamicConfiguration dynConifg = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
						 
String sourceFileName = (String)dynConifg .get(key);

Step 3: check the sourceFileName for NYC1010st.csv or CAL2010st.csv and based on that decide your Communication channel to use for lookup.


if(sourceFileName.equals("NYC1010st.csv")) 
           channel = LookupService.getChannel("BusinessSystemName","CommunicationChannel-DB1"); 
else 
          if (sourceFileName.equals("CAL2010st.csv")) 
                    channel = LookupService.getChannel("BusinessSystemName","CommunicationChannel-DB2"); 

Proceed with rest of the coding and configuration.

Here I am assuming that you know the basics of JDBC lookup.

Regards,

Ananth

bhavesh_kantilal
Active Contributor
0 Kudos

Ram,

For JDBC look up, take a look at this blog,

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

If uou are on SP14 and above, to access the filename in maping, in your sender file adapter, select ADAPTER SPECIFIC IDENTIFIERS and then FILENAME.

Then, in you mapping, you can acess the filename using the following code,

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); 

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

// Get Sourcefilename
String oldfilename=conf.get(key);

Regards,

Bhavesh

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

you can get the filename in the mapping in many ways

(adapter specific identifiers) >= SP14

from adapter module < Sp14

Regards,

michal

Former Member
0 Kudos

Michal, thanks for reply. But How do I correlate the Name I got from File Name to the Server for loookup.

For Example

File Name: NYC1010CS.csv Jdbc adapter should look at Server X

File Nmae: CAL2010CS.csv Jdvc adapter should look at Server Y

etc etc

So based on the file name how should I dynamically determine which server I should goto in Lookup.

Please eloborate as I'm confused and I'm new to Java functions.

As per your message I will get the 3 letter state from file name. Something similar to value mapping does help?